To provide execution environment during Python development
When I prepare test environment for multiple Python projects, it was a bit troublesome to prepare / update each environment.
By using Docker, provide consistent way to prepare test environment.
- Copy
build_pydev.batandDockerfileto your module's directory- see "Requirements" for details
- Build image (whennever you update code, do this step again)
- run
build_pydev.bat ${module_name}
- run
- Example usage
- Run test
docker run pydev_${module_name} pytest
- Jupyter (note notebooks are just created in the container and will not be saved by default)
docker run -p ${port}:8888 pydev_${module_name}
- General interactive shell
docker run -i -t pydev_${module_name} /bin/bash- e.g. upload built wheel to pypi
python3 -m twine upload --repository pypi dist/*
- Try Flask app
docker run -p ${port}:5000 pydev_${module_name} /bin/bash- Then use
/home/neo/venv/bin/flaskto launch your Flask app (requirements.txt should haveflask)
- Run test
- Copy everything in current directory in container
- Install dependent packages by your
requirements.txt- We split dependent module installation and your module installation to save building time
- Install your package by your
setup.py- Tips: You can use
pkg_resources.parse_requirementsto specify dependent packages from requirements.txt
- Tips: You can use
When you build image, current directory must have
Dockerfileandbuild_pydev.batin this repository- Following files for your Python package
./requirements.txtwhich describes all the dependent Python libraries./setup.pyand./README.mdto install your module