Skip to content

Instantly share code, notes, and snippets.

@corymosiman12
Last active December 28, 2020 20:37
Show Gist options
  • Save corymosiman12/26fb682df2d36b5c9155f344eccbe404 to your computer and use it in GitHub Desktop.
Save corymosiman12/26fb682df2d36b5c9155f344eccbe404 to your computer and use it in GitHub Desktop.
Setups

Using Poetry

Once poetry is installed:

  • poetry config virtualenvs.in-project true setting to create a .venv dir in your project and install dependencies there (similar to .bundle/install)
  • Clone this repo, cd into it
  • pyenv local 3.7.4
  • poetry install:
    • add --no-dev flag if don't want development requirements
    • add --no-root if don't want to install the current project
  • poetry run pre-commit install install git hooks
  • poetry run pre-commit run --all-files run pre-commit through poetry
  • poetry add [package] adds package as dependency, specify --dev flag if dev dependency
  • poetry shell enter a virtual environment through poetry

Poetry and Tox

Tox will create seperate virtual environments for testing with different python versions. A tox.ini file should like like this in the root directory of your project.

[tox]
isolated_build = true
envlist = python3.6, python3.8

[testenv]
whitelist_externals = poetry
commands =
    poetry install -v
    poetry run pytest tests/
    poetry run pre-commit run -a

Then you should be able to do the following:

git clone ...my-repo...
cd my-repo
poetry run tox

Releasing

  1. Merge all branches into develop, make sure tests pass
  2. Update the version (assume version is 0.1.2): poetry version 0.1.2
  3. Update the version test file (i.e. my-repo/tests/test_version.py) to match the above version
  4. Make sure tests pass: poetry run tox
  5. Merge develop into main (previously, master), make sure tests pass
  6. Create a tag: git tag 0.1.2
  7. Build: poetry build
  8. Publish poetry publish (this will push to pypi)
  9. Create a new release on the Github repository using the tag and link to PyPI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment