Continuous Integration and Continuous Deployment with Python
CircleCI works well for Python projects. We run automatic inference on each build to determine your dependencies and test commands. If we don’t infer all of your settings, you can also add custom configuration to a circle.yml file checked into your repo’s root directory.
When CircleCI detects Python, we automatically use
virtualenv to create an isolated Python environment.
If you don’t want to use the default, you can specify your version in
machine: python: version: pypy-2.2.1
If you need to use multiple Python versions simultaneously, you can make them available as follows:
machine: post: - pyenv global 2.7.12 3.4.4
These will be available as python2.7 and python3.4
Please contact us if other versions of Python would be of use to you.
CircleCI will set up
virtualenv if you specify your Python version in your
This can be useful if we didn’t automatically detect that you’re using Python.
Package managers and dependencies
CircleCI automatically installs your dependencies using either
pip when we find
distutils when we find a
setup.py file. You can
also add custom dependencies commands from
circle.yml, for example:
dependencies: pre: - pip install PIL --allow-external PIL --allow-unverified PIL
CircleCI has pre-installed more than a dozen databases and queues, including PostgreSQL and
MySQL. If needed, you can
manually set up your test database from your
CircleCI automatically runs test commands when certain files are detected:
manage.pycontains a testing section
setup.pycontains a testing section
Be aware that if you are testing a framework that has generated static assets, i.e. CSS files
that are created using SASS, you will need to trigger their generation. For example, with Django
you can tell
manage.py to gather up the static assets and prevent “file not found” testing errors:
test: pre: - ./manage.py collectstatic --no-input
You can add custom test commands from your
test: override: - ./my_testing_script.sh
We can automatically parallelize both standard Python tests run with nose and Django tests. However, the mechanisms to collect the tests only see class-style tests, not bare-function nose-style tests.
CircleCI has first-class support for deployment
with Fabric or Paver. To set up deployment after green builds, you can add
commands to the deployment section of your
deployment: production: branch: master commands: - fab deploy
Troubleshooting for Python
Problems? Check out our Python troubleshooting information:
If you are still having trouble, please contact us and we will be happy to help.