Python

Cookbooks

Build and Packaging

Prerequisites

  • python3 -m pip install --upgrade build - install or upgrade the build system
  • python3 -m pip install --upgrade twine - install or upgrade the uploader
    • python3 -m pip install --upgrade build twine - everything in one go

Build

  • pip3 install -e ".[tests,dev]" - install deps from a setup.cfg file
  • python3 -m venv --copies env - create a new venv in env (--copies)
    • source env/bin/activate - activate the env
    • deactivate - deactivate the env
  • python3 -m build - build a distribution from source
  • python3 -m twine upload --repository testpypi dist/* - upload to test repository
  • python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-pkg - install using Pip from the test repository
  • python3 -m pip install -e <path> - install a source tree into PIP3 as if it was an installed package

Pip3

  • pip3 install --user django==2.2.1 - install specific version of something
  • pip3 install --editable . - install current package into a venv so it can be used as if it was installed (but edits are reflected immediately)