Skip to content

Instantly share code, notes, and snippets.

@djbower
Last active March 27, 2024 09:46
Show Gist options
  • Select an option

  • Save djbower/e9538e7eb5ed3deaf3c4de9dea41ebcd to your computer and use it in GitHub Desktop.

Select an option

Save djbower/e9538e7eb5ed3deaf3c4de9dea41ebcd to your computer and use it in GitHub Desktop.

Interoperability of Poetry and pip

Poetry and pip can be used to install Python packages, and both can parse information in pyproject.toml located in the root directory of the Python package. It is desirable to construct a Python package that supports both poetry install as well as pip install, since developers will probably prefer to use poetry whereas end users will prefer to use pip. Support for both Poetry and pip can be facilitated with a few caveats:

  1. pip recognises the dependencies in [tool.poetry.dependencies], but it does not (yet) recognise group dependencies. This means that if you use pip to install the package, you may need to install additional packages in order to run tests (pytest) and compile documentation (sphinx, etc.).
  2. If you are working with the source code of a Python package directly (rather than installing the package as a dependency of another package), note that pip install will not copy any compiled shared library objects into the source directory of the package (which by convention is usually named after the package). Instead, you should copy the library file manually into the source directory. This is only relevant if the package uses a build script to compile code using Cython or similar.

Both Poetry and pip continue to undergo active development so it is foreseeable that the gap between Poetry and pip will continue to close; hence I will endevour to keep this gist up-to-date.

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