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.
Founder / Fractional CTO

Nicholas Nadeau is a fractional CTO who empowers teams to build innovative, next-generation technologies. Stay informed on cutting-edge hard tech trends - subscribe to my newsletter. Ready to innovate? Discover my services and accelerate your growth.