List Info

Thread: relocatable Python framework?




relocatable Python framework?
country flaguser name
United States
2007-09-18 23:31:11
Hello all!

I maintain a scientific data-analysis application that my
team has  
ported to the Macintosh. It's a bunch of C++ strung together
with  
Python, and so far that's worked really well.

I want to package this collection of C++ and Python into a
Macintosh  
application. And I want the Python framework to go inside
the  
application. We'd start via a shell script that calls the
Python  
inside our application package.

I've got all the other frameworks and libs set up as
relocatable  
objects. But Python is not playing along.

Maybe the user will drag our app bundle to /Applications,
but maybe  
not. I can't know where everything is until run-time.

How to I ship the Python framework as a relocatable package
inside  
our application?

Thanks!


  - boyd

Boyd Waters
programmer
national radio astronomy observatory
http://www.aoc.nrao.
edu/~bwaters

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: relocatable Python framework?
country flaguser name
Netherlands
2007-09-19 00:11:55
On 19 Sep, 2007, at 6:31, Boyd Waters wrote:

> Hello all!
>
> I maintain a scientific data-analysis application that
my team has
> ported to the Macintosh. It's a bunch of C++ strung
together with
> Python, and so far that's worked really well.
>
> I want to package this collection of C++ and Python
into a Macintosh
> application. And I want the Python framework to go
inside the
> application. We'd start via a shell script that calls
the Python
> inside our application package.
>
> I've got all the other frameworks and libs set up as
relocatable
> objects. But Python is not playing along.
>
> Maybe the user will drag our app bundle to
/Applications, but maybe
> not. I can't know where everything is until run-time.
>
> How to I ship the Python framework as a relocatable
package inside
> our application?

You'll have to rewrite the loader commands of at least the
command- 
line interpreter. I guess the easiest way to do that is to
use a .app  
bundle and macho_standalone (part of macholib): Create a
(dummy) .app  
bundle by hand and use sys.executable (not the python
command) as the  
executable of that application bundle. Then use
macho_standalone to  
copy all libraries and frameworks used by the application
into the  
application bundle, this will rewrite the loader command's
as well.

It might be possible to use py2app to do all the work, that
depends on  
how you application is set up.

Ronald
>
>
> Thanks!
>
>
>  - boyd
>
> Boyd Waters
> programmer
> national radio astronomy observatory
> http://www.aoc.nrao.
edu/~bwaters
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: relocatable Python framework?
country flaguser name
United States
2007-09-19 09:34:39
On Sep 18, 2007, at 11:11 PM, Ronald Oussoren wrote:

>
> On 19 Sep, 2007, at 6:31, Boyd Waters wrote:
>
>> Maybe the user will drag our app bundle to
/Applications, but maybe
>> not. I can't know where everything is until
run-time.
>>
>> How to I ship the Python framework as a relocatable
package inside
>> our application?
>
> You'll have to rewrite the loader commands of at least
the command- 
> line interpreter. I guess the easiest way to do that is
to use  
> a .app bundle and macho_standalone (part of macholib):
Create a  
> (dummy) .app bundle by hand and use sys.executable (not
the python  
> command) as the executable of that application bundle.
Then use  
> macho_standalone to copy all libraries and frameworks
used by the  
> application into the application bundle, this will
rewrite the  
> loader commands as well.


Thanks very much, Ronald!

Not sure I understood all that, but I know where to dig
now...

I see this in the comments in Modules/main.c:

> See Lib/plat-mac/bundlebuiler.py for details about the
bootstrap
> 	   script.


I had thought this was a trivial matter, but now I see that
it is a  
bit involved.

Our application already sets up the Python interpreter from
a C++  
wrapper, so I suppose we already have a place to add hooks.
Hmm.

If I come up with anything simple and clever, I'll post back
to the  
list.

(If I come up with something embarrassing and stupid, maybe
I'll keep  
it to myself...)

- boyd

  Boyd Waters
  programmer mac guy
  National Radio Astronomy Observatory
  http://www.aoc.nrao.
edu/~bwaters


_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: relocatable Python framework?
country flaguser name
United States
2007-09-19 11:27:07
Boyd Waters wrote:
>>> Maybe the user will drag our app bundle to
/Applications, but maybe
>>> not. I can't know where everything is until
run-time.

Is your goal something that looks and acts like a regular
single 
stand-alone application? If so, then why not just use
py2app?

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barkernoaa.gov
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: relocatable Python framework?
country flaguser name
United States
2007-09-19 12:19:33
On Sep 19, 2007, at 10:27 AM, Christopher Barker wrote:

> Is your goal something that looks and acts like a
regular single  
> stand-alone application? If so, then why not just use
py2app?

Good question!

I will try to inhale py2app documentation, maybe it will
help.

My short answer to "why not py2app" is that this
is not just a Python  
application. It's a large C++ system. There are Qt
applications in  
there as well.

The primary user interface at the moment is an extension to
the  
IPython shell, launched by a C++ executable that sets up our
Python  
library path and wraps Python_Main.

I run against a Python 2.5.1 framework build that I have
installed  
in /opt/casa/lib, along with another 100 megabytes of
open-source  
fun, built with MacPorts, that uses /opt/casa as $. 
(Our  
application is called CASA.) Altogether it is 250 megabytes
on disk...

The previous three releases of this system have been a
completely  
self-contained directory tree that is installed in
/opt/casa/ --  
actually in /opt/casa/$version -- and that works great. But
I would  
like to take that self-contained thing to the next level,
and allow  
the user to install the directory tree in an arbitrary
location. A  
draggable application.


My current whack at a Mac application bundle is an
AppleScript  
"bundle" that simply calls Terminal and tells is
to execute the  
wrapper shell script that starts up our Python_Main
wrapper.


So far we've been able to get away with a single code base,
Qt for  
the GUI, no Mac-specific stuff in our system. I can write
simple  
Objective-C applications but I'm the only member of the team
who  
might do so, and we want to avoid doing so if we can in
order to  
minimize the maintenance cost of the platform. The
developers here  
like the Mac as a platform but it's a Linux code base, Linux
is our  
primary deployment target.

I was hoping that I could simply set PYTHONEXECUTABLE or
PYTHONHOME  
in my launcher shell script to set the path to Python at
run-time.

Keep those cards and letters coming!

Thanks!

  - boyd

Boyd Waters
National Radio Astronomy Observatory
http://www.aoc.nrao.
edu/~bwaters
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Re: relocatable Python framework?
user name
2007-09-19 12:32:13
which QT? tolltech's qt3 or qt4 (or quicktime? ... jk)
QT is trying to be as platform independent as possible. how about puting python.frameworks in  $appdir/resources/frameworks/python2.5.framework and building against that framework before you package it.
Re: relocatable Python framework?
user name
2007-09-19 12:35:50
which QT? tolltech's qt3 or qt4 (or quicktime? ... jk)
QT is trying to be as platform independent as possible. how about puting python.frameworks in  $appdir/resources/frameworks/python2.5.framework and building against that framework before you package it.
Re: relocatable Python framework?
country flaguser name
United States
2007-09-19 12:46:45
On Sep 19, 2007, at 11:32 AM, Nehemiah Dacres wrote:

> which QT? tolltech's qt3 or qt4 (or quicktime? ... jk)

Qt 4.3.1


>  how about puting python.frameworks in 
$appdir/resources/ 
> frameworks/python2.5.framework and building against
that framework  
> before you package it.

This is exactly it -- I was able to (manually) run
install_name_tool  
against the Qt frameworks that I'd built so that I could put
them  
inside my application bundle. I used loader_path in order to
make  
the Qt frameworks relocatable.

But I have found no documentation for doing the same thing
with the  
Python.framework -- and it seems that such would not be
sufficient,  
in any case.

I have set the PYTHONEXECUTABLE environment variable but
that does  
not work. I found out about this environment variable by
reading the  
Python source code.

Someone else must have included Python inside an application
bundle.  
I think that OpenOffice does this...

- boyd

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIGpython.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )