Publishing a Package to PyPI using Travis
SRE has indicated that we should not be building new functionality on Travis, but should instead be using GitHub Actions. This section may fall out of date from disuse.
A guide to publishing a package to PyPI using Travis. You should publish packages on which your team relies to PyPI instead of installing them from GitHub.
P.S. It's pronounced "Pie-P-Eye"
Step-by-step guide
- If you're not familiar with how to package a Python module and and share it on PyPI, get your bearings by reading this guide.
- Write a setup.py for your package.
- Make sure you:
- Indicate a license type, AGPL or Apache (
license
). Link to which license you should use: /wiki/spaces/OPEN/pages/13959332 - Indicate which packages your package requires in order to run (
install_requires
) - Use "edX" as the package author (
author
) - Use "oscm@edx.org" as the package author's email address (
author_email
)
- Indicate a license type, AGPL or Apache (
- A simple example is here.
- If your package includes console scripts, see this example.
- Make sure you:
- Test your setup.py by publishing your package to the PyPI staging server.
- Create an account at https://testpypi.python.org/pypi.
- Follow the instructions in the guide linked above.
- There is a job which can create your .travis.yml credentials and publish to PyPI here: https://tools-edx-jenkins.edx.org/job/travis_credentials_jobs/job/publish_to_PyPI/build?delay=0sec
- After credentials are updated in .travis.yml, to publish a new version of your package to PyPI, update the version in setup.py, then push a corresponding tag to GitHub.
- You're done! Don't forget to update your requirements files so that they install your package from PyPI.
Find your package at https://pypi.python.org/pypi/[package-name]/[version]
Troubleshooting
If your tag is in GitHub, but is not starting a build in Travis, or if you are deploying from too many sub-builds in Travis, see the following changes to .travis.yml.
Related articles