Setup virtualenv and packages locally without sudo/root
I wanted to create a deployable package into production machines in which I neither have root access nor sudo and also they are firewalled so something simple such as getting pip installation etc is not going to work since the ports are blocked outwards as well.
I usually have ssh and scp access to the machine so I can place files on the server but anything else is pretty locked down.
So after some web research, I came across the following which helped with scripting a solution:
Couple of notes:
- At the end of this setup, it would have installed a virtualenv with the tools that were packaged in the setup script's directory.
- We will have the use of pip to make it easier for subsequent installs.
- However, pip may or may not work to download packages if the system is constrained (with either network firewalling or automatic proxies - I could not figure a way past auto proxies).
- You have to provide any required packages as well as provide correct versions of packages.
- This will be a fully isolated setup.
- Get virtualenv.py from : https://raw.github.com/pypa/virtualenv/master/virtualenv.py
- Get pip from: https://pypi.python.org/pypi/pip#downloads
- Get setuptools from https://pypi.python.org/pypi/setuptools, the download is towards the bottom (clicking on download button didn't work for me).
https://pypi.python.org/packages/source/s/setuptools/setuptools-17.1.1.zip - Get additional packages as tar.gz format from pypi etc. and place them into pypackage directory
- Setup the virtual env: (setting up to homedir/myenv shown below)
- Activate this environment (note the leading 'dot' is required with space following)
- Unpack the pip to some folder (not the virtual env folder):
- Unpack the setuptools directory:
- cd to the unpacked directory and setup pip into virtual env:
cd setuptools-17.1.1 python setup.py build python setup.py install
- cd to the unpacked directory and setup pip into virtual env:
python $SCRIPTDIR/virtualenv.py --no-setuptools ~/myenv
. ~/myenv/bin/activate
tar xvzf pip-7.0.3.tar.gz
unzip setuptools-17.1.1.zip
cd pip-7.0.3 python setup.py build python setup.py install
pip install <path to tar.gz>And it will install into the virtual environment.
No comments:
Post a Comment