Reputation: 331
I need to install python 2.7 and 3.4 for linux/unix (built from source) into a directory on the network other than the location from which it will ultimately be used.
I.e. the directory containing the installation must be portable and self-contained.
Thus, it seems like things such as the "installation-dependent default" sys.path should be defined relative to the current location of the python installation.
However, --prefix and --exec_prefix require absolute paths.
For example: I might create the installation in "/stage/tools/python", then copy the "python" directory to "/tools/knights/ni". If I then invoke "/tools/knights/ni/$platform/bin/python", python should find everything it needs from its installation under "/tools/knights/ni/"
How can I do a portable, self-contained install?
Thanks much for any guidance.
Upvotes: 1
Views: 4129
Reputation: 32497
You will probably not be able to do portable (as in: works across different OS versions, archs), but virtualenv
can help you create self-contained installations.
Virtualenv has a --relocatable
option that solves the case if the mountpoints differ, but it has issues according to the documentation, and I never used it. However, virtualenv is sort of a hack that forces Python to do something it was not designed to do (being moved to a self-contained directory) and you always end up shooting yourself in the foot with it.
What I would have preferred is to just do a pip freeze > requirements.txt
to easily install all the dependencies. That, and/or Docker. If you need to patch Python itself or have a custom build configuration, I have preferred to just let the users do ./configure && make && make install
themselves.
Upvotes: 1