Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info

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.

...

  1. 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.
  2. Write a setup.py for your package.
    1. Make sure you:
      1. Indicate a license type, AGPL or Apache (license). Link to which license you should use: /wiki/spaces/OPEN/pages/13959332
      2. Indicate which packages your package requires in order to run (install_requires)
      3. Use "edX" as the package author (author)
      4. Use "oscm@edx.org" as the package author's email address (author_email)
    2. A simple example is here.
    3. If your package includes console scripts, see this example.
  3. Test your setup.py by publishing your package to the PyPI staging server.
    1. Create an account at https://testpypi.python.org/pypi.
    2. Follow the instructions in the guide linked above.
    The first upload of your package has to be done manually.
  4. Get the pypi edX credentials from devops, or ask them to do these steps
  5. Install twine, build a kit, and upload it:

    Code Block
    pip install twine wheel
    python setup.py sdist bdist_wheel
    twine upload -u edX -p Q6GQT_THE_PASSWORD_6H8DF dist/*
    Modify your repo's Travis configuration so that a source distribution and a wheel for your package are published when new tags are pushed to master.

    Contact DevOps to get credentials for the edX PyPI account. Use the Travis CI command line client to encrypt the password: 

    Code Block
    languagebash
    travis encrypt --add deploy.password
  6. An example .travis.yml is here.
  7. Travis documentation on PyPI deployment.
  8. To 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
  9. 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.
  10. You're done! Don't forget to update your requirements files so that they install your package from PyPI.

...