Docker container with many Python versions. Especially for Virtualenv and Tox usage.
1.7K
This container provides several versions of Python for creating separated Python environments via virtualenv. This container is particularly well suited to use tox with multiple Python versions.
The following Python versions are installed:
This container uses Fedora since this distribution allows to install multiple Python versions in a very simple way.
In most cases, you want to run a project with differents Python versions. Your project should be mapped to the /var/project directory of the container:
$ docker run -it --rm -v /path/to/your/project:/var/project lvo9/python-virtualenv bash
The following environments are generated by default:
/var/environments/py27/var/environments/py34/var/environments/py35/var/environments/py36/var/environments/py37For instance, let's use Python 3.5 environment; according to the virtualenv documentation:
[root@0800a40e232f project]# source /var/environments/py35/bin/activate
(py35) [root@0800a40e232f project]# python --version # will display Python 3.5.6
You can now test your project with Python 3.5. To quit current virtual environment:
(py35) [root@0800a40e232f project]# deactivate
Of course, you can create as many environments as you need (to work with many versions of a library for instance). For creating another Python 3.5 virtual environment:
[root@0800a40e232f project]# virtualenv -p /usr/bin/python3.5 /var/environments/py35_custom
When creating extra virtual environments (or if you modify the existing ones), you should create a docker volume. If you don't do so, your new and/or customized environments will be lost when you close the container. Let's bind the environments folder to a directory of your host machine:
$ docker run -it --rm -v /path/to/your/project:/var/project -v /path/to/backup/environments:/var/environments lvo9/python-virtualenv bash
Tox is preinstalled in the container. According to the Python versions installed, you can have the following environment list in your tox.ini:
[tox]
envlist = py27,py34,py35,py36,py37
Content type
Image
Digest
Size
352.5 MB
Last updated
over 7 years ago
docker pull lvo9/python-virtualenv