I'm working on a python
script which takes care to migrate a mysql
database with a certain schema / structure, into a postgresql
database with a different structure.
During the development phase I was working inside a Virtual Machine(CentOS7
) with all my environment correctly set up.
Currently I'm in the testing phase, and I'm trying to run the script in a real server for the first time, but I'm already facing troubles caused by different environment (python version, or python-modules version incompatibility).
Since I will have to execute this script into many servers(All of them will be GNU/Linux servers, most of them CentOS, some Debian), I'm looking for a way to integrate python, and all the python-modules (dependencies) directly into my script, a sort of portable version of python, if you know what I mean.
E.g. I would like to integrate into my script package the following elements/binaries:
- Python 2.7.5
- mysql-connector-python-2.1.3-1
- python-psycopg2
Best Answer
virtualenv
is probably what you are looking for. See http://docs.python-guide.org/en/latest/dev/virtualenvs/:If you want to move your environment:
From my experience, virtualenvs can be created and managed for both python2 and python3 (on my system, I have both
virtualenv
andvirtualenv3
)Note that virtualenv does not itself provide the python interpreter. It allows you to create isolated environments where a python interpreter is already available.
IMHO, bundling python binaries into your script would not only make your package much bigger, it would in fact make your script less portable as the binaries would be compiled for the specific OS and glibc. If someone wanted to use the script on a different (linux) OS/architecture it would not be possible unless you provided a package for that version.