Testing Python Packages with Docker

Package management is hard. Sometimes in Python package development, your local (development) environment may behave a little differently than a deployment target. Below is a simple method I use to replicate a clean environment and test Python package installs and tests.

docker run -v `pwd`:`pwd` -w `pwd` python pip install .
docker run -v `pwd`:`pwd` -w `pwd` python python setup.py install
docker run -v `pwd`:`pwd` -w `pwd` python python setup.py test

First, we bind the current directory to our container (-v) and switch our working directory (-w). Second, we run our commands.

Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.

Nicholas Nadeau is the CTO at Halodi Robotics, leading their mission of bringing safe and capable humanoid robots to everyone.