Python 2.6.1 @executable_path

  • Thread starter googler.1.webmaster
  • Start date
G

googler.1.webmaster

Hi!

I asked something similar a few days ago. Is it possible to compile
Python 2.6.1 with a dynamic path?
I don't know how the configure command would look like.

This is my current configure command for the default /Library/
Frameworks/ path:

../configure --with-framework-name=Python --with-universal-archs=all --
enable-framework --enable-universalsdk=/

Can anyone help me?
Thanks.
 
G

googler.1.webmaster

I want to embedd it into another app so on the 'customers'-mac I want
to put python into a subdirectory of my app.
bye
 
G

googler.1.webmaster

I want to embedd it into my app so on the 'customers'-mac I want
to put python into a subdirectory of my app.

and with the configure command above, that will not work
because the library has to be on every system in /Library/Framework/
so I found out that @executable_path is replaced by the path of the
app.
bye
 
G

googler.1.webmaster

Thanks for the link but I don't want to do a make a python script as
an applicatin, I want to embedd python into a C++ app so thats the
reason why I have to compile Python.
 
G

googler.1.webmaster

hmm.. very strange. Is it so complicated to compile python that I can
move the framework to the app folder?
hmm. thats really strange :-(


/myapp.app
/subfolder/Python.framework

any suggestions? Thank you very muc.
 
M

Michael Torrie

Thanks for the link but I don't want to do a make a python script as
an applicatin, I want to embedd python into a C++ app so thats the
reason why I have to compile Python.

If you are embedding python, then all you have to do is stick the python
modules you need in somewhere in the resources folder, along with the
dynamic link library that you built. Then you fix up your executable to
be able to find the dynamic link library (been a while since I made app
bundles in general... followed the Qt docs if I recall). When your app
goes to initialize python, just use python api calls to set the python
path that it will use to find the import modules. You should be able to
programmatically determine this (see apple docs I guess).

In short, you can do it all with the python C api, programmatically in
your exe, once you've taken care of the initial link against the python
dynlib.
 
G

googler.1.webmaster

Hi! :)

Thank you. I found PySys_SetPythonHome() to set the path where the lib
folder of Python is, but I guess they are not really implemented
because they are fixed compiled for an absolute path, aren't they?

Thats the whole problem. Do you have a suggestoin for the command line
how I can build it?


Thanks
 
G

googler.1.webmaster

Thank you, I found PySys_SetPythonHome() to set the path where the lib
folder of Python is, but I guess they are not really implemented
because they are fixed compiled with an absolute path, aren't they?

Thats the problem. I hadn't compiled Python and I don't know if I
should
compile it as a dylib file or a framework? hmm. I know how to create a
framework but compiling as a dylib hadn't worked yet. :-(

Thanks
 
M

Michael Torrie

Thank you, I found PySys_SetPythonHome() to set the path where the lib
folder of Python is, but I guess they are not really implemented
because they are fixed compiled with an absolute path, aren't they?

I'm afraid I'm not following you here. What is fixed compiled with an
absolute path? What path are you talking about here? Linker path?
Python default path for importing modules?

Please read the documentation on embedding python and you'll see that
you can initialize python and tell it to look anywhere for import
modules. This is really all you have to do. In fact, if you import the
built-in "sys" module, you can, from C++, add your Resource folder path
to the sys.path dictionary (using api calls) and dynamically affect
where python will import from. I did this once when I had a case where
the user could place his plugin in an arbitrary spot. Hence I had to
dynamically add the location to the path.

If you are embedding python in your app, I would expect you to be
familiar with the python apis.
Thats the problem. I hadn't compiled Python and I don't know if I
should
compile it as a dylib file or a framework? hmm. I know how to create a
framework but compiling as a dylib hadn't worked yet. :-(

I'm very confused as previously you were talking about compiling python
and now you're talking about not compiling python. Although it doesn't
matter, since a framework file is a dylib file.

In any case if you don't know how to set the linker paths (to relative)
in App bundles, you'll want to consult apple docs, and the various apple
e-mail lists.
 
G

googler.1.webmaster

yeap, okay, its just the beginning so I didn't know that the framework
is still the dylib file.
Well, I only want to compile python and put the framework in the
subdirectory. Thats all.
And the current state is, that the framework is not found because the
path of the compiled Python
library is hardcoded so when I move it from /Library/Frameworks/ to my
app folder it isn't found
when I start my app.

I found a ressource that I have to compile it with a dynamic path flag
like LDFLAGS="-install_name,@executable_path/../Frameworks" to put it
in the Framework of my app. maybe you know where my problem is. hm.

bye
 
M

Michael Torrie

yeap, okay, its just the beginning so I didn't know that the framework
is still the dylib file.
Well, I only want to compile python and put the framework in the
subdirectory. Thats all.
And the current state is, that the framework is not found because the
path of the compiled Python
library is hardcoded so when I move it from /Library/Frameworks/ to my
app folder it isn't found
when I start my app.

Okay, that last sentence finally started to make some sense. Basically
you can fixup your executable and any libraries you need to have the
"@executable_path" part *after* the fact. This is not about python, but
see this excellent document on bundling Qt apps which explains how this
is done:

http://doc.trolltech.com/4.3/deployment-mac.html

It will tell you every thing you need to know about making it so app
bundles can include and link against libraries and frameworks inside the
app bundle itself. The keys are "otool" and "install_name_tool."
I found a ressource that I have to compile it with a dynamic path flag
like LDFLAGS="-install_name,@executable_path/../Frameworks" to put it
in the Framework of my app. maybe you know where my problem is. hm.

Yeah that sounds like one way to do it.
 
G

googler.1.webmaster

Hi!

Woow, thanks. The unix command install_name_tool solved my problem.
Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top