Reputation: 1485
looking for some advice and best practice guidance with the following situation. I have a python application that is run from source and has all dependencies included. When using PIL some issues arise. Different python versions need different PIL sources and 64 bit and 32 bit need different version.
We have decided we want to support:
Python 2.4 64 bit
Python 2.4 32 bit
Python 2.7 64 bit
Python 2.7 32 bit
I will have to locate the necessary source packages and include them all. The question is what is the best way to import them? Do I check python version and OS version and import different PIL versions based on that (can you if, else import stuff?) or can I import once for all?
Hope that all makes sense. Thanks
Upvotes: 2
Views: 126
Reputation: 92627
I'm going to take the opposite direction of @alan's answer and not recommend you even distribute your 4 hard-coded environments like that.
If you are distributing source code directly, then you shouldn't be including prebuilt dependencies at all. Create some kind of setup.py to have the dependencies downloaded and installed. Or consider packaging your app into a self-contained executable
Your package could contain the setup files for PIL locally so a download wouldn't be needed, but they should get built by the actual end-user to match their architecture. There is no point in trying to make your application figure all of this out and point to one of many precompiled packages.
You can also take a look at py2exe, py2app, and pyinstaller if you want to go the route of creating self-executable packages for different systems that contain their entire environment.
Upvotes: 2
Reputation: 4852
Have you heard of virtualenv? http://pypi.python.org/pypi/virtualenv
From your stated requirements, I believe it will do what you need. It was created specifically to solve the problem of installing and maintaining different environments for different versions of Python and different packages installed for each version.
Take a look and see if it does what you need, though I believe you would need two different boxes (or VMs) to separate the 32- and 64-bit environments.
At any rate, once you have your four environments set up, you would just activate an enviroment and the import PIL
statement in Python code running in that environment would get the proper library.
Upvotes: 0