tags:

views:

66

answers:

2

I've come across this question but I don't like the solution that is presented. Shell scripting is operating system dependent.

Is there a python solution to this problem?

I'm not looking for python to machine code compilers, just a way to modify the include paths with python.

+3  A: 

Generally speaking, python follows the paths in sys.path when trying to resolve library dependencies. sys.path is a list, and it is searched in order. If your application modified sys.path on load to put its own library paths at the front, this should do the trick.

This section from the python docs has a good explanation of how python finds its dependencies: http://www.python.org/doc/2.5.2/ref/import.html.

Jarret Hardie
Dammit Jim! Yes, I do mean sys.paths. First I wrote sys.paths. Then I edited it to sys.modules. Now back to sys.paths. Don't mind me... just being silly this morning it seems. Thanks for pointing this out.
Jarret Hardie
+2  A: 

Well, as far as I know there are many different pieces of advice on how to do it.

Here are 2 approaches that may help you distribute your app

I/

. include all dependencies in my project directory structure

. manipulate the sys.path to make sure that the app is always looking in my dir structure before looking into the system available modules

(Disclaimer: this solution might not work if C libs are involved)

II/

Another approach is using a tool like EasyInstall and eggs. This solution might be a bit more complex, but it will offer you a lot of freedom on how to configure your app and its dependencies (plus it will work with C dependencies).

./alex

alexpopescu
I'm going to have to look into using eggs.
epochwolf