Skip to content

Instantly share code, notes, and snippets.

@richardcornish
Last active August 10, 2023 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardcornish/57676aca2cf46e623027479fa8ed739b to your computer and use it in GitHub Desktop.
Save richardcornish/57676aca2cf46e623027479fa8ed739b to your computer and use it in GitHub Desktop.
Python packaging cheatsheet

Create

First time only.

mkdir myproject
cd myproject/
python -m venv venv
source venv/bin/activate
git clone git@github.com:username/myproject.git
cd myproject/
python setup.py install

Activate environment

source venv/bin/activate

Install dependencies

First time only!

pip install django black tox sphinx sphinx-autobuild sphinx_rtd_theme wheel twine

Update

Make changes.

Test

django-admin test myproject.tests --settings="myproject.tests.settings"

Lint

black .

Document

sphinx-autobuild docs/ docs/_build_html

Make changes to docs/<file>.rst. Confirm at 127.0.0.1:8000.

Commit

git add .
git commit -m "Added feature"
git push origin main

Integrate

Confirm continuous integration results.

Commit

nano setup.py  # change point release
git add .
git commit -m "Bumped version"
git push origin main

Release

python setup.py sdist bdist_wheel  # maybe use `python -m build` instead?
twine check dist/*
twine upload -r testpypi dist/*
twine upload dist/*

Exit environment

deactivate

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment