r/Python • u/[deleted] • Apr 08 '13
How are python apps deployed to production especially those that are developed in a virtualenv? What are the best practices?
I have always insisted that in production systems we can not have gcc and devel packages installed. But these days I end up installing such development packages in produciton systems because the software deploy for virtualenvs require pip which in turn require access to the internet [ok I solved this part with a pypi local mirror]. How are you guys/girls doing it? I have thought of tar.gz the whole virtualenv and simply ensure that the required libs the virtualenv is built with is installed in production. Has anyone done this or has everyone resigned to the fact that in these days of pip and rvm , we agree to have compilers and devel packages in our production systems?
127
Upvotes
6
u/westurner Apr 08 '13 edited May 23 '13
It can. After running test suite(s), a build script (e.g. tox and/or buildout) can produce 'build artifacts' which can be
eggs
bundles
wheels
OS packages like DEB and RPM
archives of platform-specific virtualenvs
A configuration management script/system can be then be updated to pull the latest version from a package archive/repository. In some environments, it is safer to pin specific versions than to always pull the latest version. A manual package signing step can help with this.
Fabric is useful for automating scp/rsync push deployments and application configuration (e.g.
rm *.pyc). There is a context manager for sudo in fabric.Build
Test
Review
Sign
Deploy: push or pull
Test
https://en.wikipedia.org/wiki/DevOps
https://python-guide.readthedocs.org/en/latest/scenarios/admin.html
https://python-guide.readthedocs.org/en/latest/scenarios/ci.html
https://python-guide.readthedocs.org/en/latest/shipping/packaging.html
https://python-guide.readthedocs.org/en/latest/shipping/freezing.html
http://www.pip-installer.org/en/latest/usage.html#pip-freeze
http://www.pip-installer.org/en/latest/usage.html#pip-wheel
http://guide.python-distribute.org/specification.html#development-releases
PEP 301: Package Index and Metadata for Distutils (2002)
PEP 345: Metadata for Python Software Packages 1.2 (2005)
PEP 386: Changing the version comparison module in Distutils (2010)
PEP 427: The Wheel Binary Package Format 1.0 (2012)
PEP 440: Version Identification and Dependency Specification (2012) [DRAFT]
PEP 426: Metadata for Python Software Packages 2.0 (2012) [DRAFT]
compoze "provides a set of tools for managing private / project-specific package indexes."