Python dependency management and packaging made easy.

Overview

Poetry: Dependency Management for Python

Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right stack everywhere.

Poetry Install

It supports Python 2.7 and 3.5+.

Note: Python 2.7 and 3.5 will no longer be supported in the next feature release (1.2). You should consider updating your Python version to a supported one.

Tests Status

The complete documentation is available on the official website.

Installation

Poetry provides a custom installer that will install poetry isolated from the rest of your system by vendorizing its dependencies. This is the recommended way of installing poetry.

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

Alternatively, you can download the get-poetry.py file and execute it separately.

The setup script must be able to find one of following executables in your shell's path environment:

  • python (which can be a py3 or py2 interpreter)
  • python3
  • py.exe -3 (Windows)
  • py.exe -2 (Windows)

If you want to install prerelease versions, you can do so by passing --preview to get-poetry.py:

python get-poetry.py --preview

Similarly, if you want to install a specific version, you can use --version:

python get-poetry.py --version 0.7.0

Using pip to install poetry is also possible.

pip install --user poetry

Be aware, however, that it will also install poetry's dependencies which might cause conflicts.

Updating poetry

Updating poetry to the latest stable version is as simple as calling the self update command.

poetry self update

If you want to install prerelease versions, you can use the --preview option.

poetry self update --preview

And finally, if you want to install a specific version you can pass it as an argument to self update.

poetry self update 1.0.0

Note:

If you are still on poetry version < 1.0 use `poetry self:update` instead.

Enable tab completion for Bash, Fish, or Zsh

poetry supports generating completion scripts for Bash, Fish, and Zsh. See poetry help completions for full details, but the gist is as simple as using one of the following:

# Bash
poetry completions bash > /etc/bash_completion.d/poetry.bash-completion

# Bash (Homebrew)
poetry completions bash > $(brew --prefix)/etc/bash_completion.d/poetry.bash-completion

# Fish
poetry completions fish > ~/.config/fish/completions/poetry.fish

# Fish (Homebrew)
poetry completions fish > (brew --prefix)/share/fish/vendor_completions.d/poetry.fish

# Zsh
poetry completions zsh > ~/.zfunc/_poetry

# Zsh (Homebrew)
poetry completions zsh > $(brew --prefix)/share/zsh/site-functions/_poetry

# Zsh (Oh-My-Zsh)
mkdir $ZSH_CUSTOM/plugins/poetry
poetry completions zsh > $ZSH_CUSTOM/plugins/poetry/_poetry

# Zsh (prezto)
poetry completions zsh > ~/.zprezto/modules/completion/external/src/_poetry

Note: you may need to restart your shell in order for the changes to take effect.

For zsh, you must then add the following line in your ~/.zshrc before compinit (not for homebrew setup):

fpath+=~/.zfunc

Introduction

poetry is a tool to handle dependency installation as well as building and packaging of Python packages. It only needs one file to do all of that: the new, standardized pyproject.toml.

In other words, poetry uses pyproject.toml to replace setup.py, requirements.txt, setup.cfg, MANIFEST.in and the newly added Pipfile.

[tool.poetry]
name = "my-package"
version = "0.1.0"
description = "The description of the package"

license = "MIT"

authors = [
    "Sébastien Eustace <[email protected]>"
]

readme = 'README.md'  # Markdown files are supported

repository = "https://github.com/python-poetry/poetry"
homepage = "https://github.com/python-poetry/poetry"

keywords = ['packaging', 'poetry']

[tool.poetry.dependencies]
python = "~2.7 || ^3.2"  # Compatible python versions must be declared here
toml = "^0.9"
# Dependencies with extras
requests = { version = "^2.13", extras = [ "security" ] }
# Python specific dependencies with prereleases allowed
pathlib2 = { version = "^2.2", python = "~2.7", allow-prereleases = true }
# Git dependencies
cleo = { git = "https://github.com/sdispater/cleo.git", branch = "master" }

# Optional dependencies (extras)
pendulum = { version = "^1.4", optional = true }

[tool.poetry.dev-dependencies]
pytest = "^3.0"
pytest-cov = "^2.4"

[tool.poetry.scripts]
my-script = 'my_package:main'

There are some things we can notice here:

  • It will try to enforce semantic versioning as the best practice in version naming.
  • You can specify the readme, included and excluded files: no more MANIFEST.in. poetry will also use VCS ignore files (like .gitignore) to populate the exclude section.
  • Keywords (up to 5) can be specified and will act as tags on the packaging site.
  • The dependencies sections support caret, tilde, wildcard, inequality and multiple requirements.
  • You must specify the python versions for which your package is compatible.

poetry will also detect if you are inside a virtualenv and install the packages accordingly. So, poetry can be installed globally and used everywhere.

poetry also comes with a full fledged dependency resolution library.

Why?

Packaging systems and dependency management in Python are rather convoluted and hard to understand for newcomers. Even for seasoned developers it might be cumbersome at times to create all files needed in a Python project: setup.py, requirements.txt, setup.cfg, MANIFEST.in and the newly added Pipfile.

So I wanted a tool that would limit everything to a single configuration file to do: dependency management, packaging and publishing.

It takes inspiration in tools that exist in other languages, like composer (PHP) or cargo (Rust).

And, finally, I started poetry to bring another exhaustive dependency resolver to the Python community apart from Conda's.

What about Pipenv?

In short: I do not like the CLI it provides, or some of the decisions made, and I think we can make a better and more intuitive one. Here are a few things that I don't like.

Dependency resolution

The dependency resolution is erratic and will fail even if there is a solution. Let's take an example:

pipenv install oslo.utils==1.4.0

will fail with this error:

Could not find a version that matches pbr!=0.7,!=2.1.0,<1.0,>=0.6,>=2.0.0

while Poetry will get you the right set of packages:

poetry add oslo.utils=1.4.0

results in :

  - Installing pytz (2018.3)
  - Installing netifaces (0.10.6)
  - Installing netaddr (0.7.19)
  - Installing oslo.i18n (2.1.0)
  - Installing iso8601 (0.1.12)
  - Installing six (1.11.0)
  - Installing babel (2.5.3)
  - Installing pbr (0.11.1)
  - Installing oslo.utils (1.4.0)

This is possible thanks to the efficient dependency resolver at the heart of Poetry.

Here is a breakdown of what exactly happens here:

oslo.utils (1.4.0) depends on:

  • pbr (>=0.6,!=0.7,<1.0)
  • Babel (>=1.3)
  • six (>=1.9.0)
  • iso8601 (>=0.1.9)
  • oslo.i18n (>=1.3.0)
  • netaddr (>=0.7.12)
  • netifaces (>=0.10.4)

What interests us is pbr (>=0.6,!=0.7,<1.0).

At this point, poetry will choose pbr==0.11.1 which is the latest version that matches the constraint.

Next it will try to select oslo.i18n==3.20.0 which is the latest version that matches oslo.i18n (>=1.3.0).

However this version requires pbr (!=2.1.0,>=2.0.0) which is incompatible with pbr==0.11.1, so poetry will try to find a version of oslo.i18n that satisfies pbr (>=0.6,!=0.7,<1.0).

By analyzing the releases of oslo.i18n, it will find oslo.i18n==2.1.0 which requires pbr (>=0.11,<2.0). At this point the rest of the resolution is straightforward since there is no more conflict.

Resources

Comments
  • Poetry is extremely slow when resolving the dependencies

    Poetry is extremely slow when resolving the dependencies

    • [x] I am on the latest Poetry version.
    • [x] I have searched the issues of this repo and believe that this is not a duplicate.
    • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
    • OS version and name: Centos 7
    • Poetry version: 1.0.0
    • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/qiuwei/a0c7eee89e5e8d75edb477858213c30b

    Issue

    I created an empty project and run poetry add allennlp. It takes ages to resolve the dependencies.

    kind/bug area/solver 
    opened by qiuwei 271
  • Poetry refuses to install package with correct hash

    Poetry refuses to install package with correct hash

    • [x] I am on the latest Poetry version.

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.

    • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

    • OS version and name: Debian Buster

    • Poetry version: 1.1.9

    • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/MartinWallgren/65ffceae6b597698602afdcdae927d7f

    Issue

    Poetry refuses to install a package even though the checksum is correct. Looking at the output it seems as if the cheksum stored in the lock file is md5 and the checksum used during installation is sha256.

    Both sha256:3ae5020d5eddabcb57db9211e3f1a46ebafa28cb31cdeb4a497189041757bb7b and md5:75dbe554e7838a35e3a5836887cf9efc are valid checksums for this package according to our index (artifactory).

    ❯ poetry install
    Installing dependencies from lock file
    
    Package operations: 1 install, 0 updates, 0 removals
    
      • Installing axis-json-log-formatter (0.1.0): Failed
    
      RuntimeError
    
      Retrieved digest for link axis_json_log_formatter-0.1.0.tar.gz(sha256:3ae5020d5eddabcb57db9211e3f1a46ebafa28cb31cdeb4a497189041757bb7b) not in poetry.lock metadata ['md5:75dbe554e7838a35e3a5836887cf9efc']
    
      at ~/.poetry/lib/poetry/installation/chooser.py:115 in _get_links
          111│
          112│         if links and not selected_links:
          113│             raise RuntimeError(
          114│                 "Retrieved digest for link {}({}) not in poetry.lock metadata {}".format(
        → 115│                     link.filename, h, hashes
          116│                 )
          117│             )
          118│
          119│         return selected_links
    
    kind/bug 
    opened by MartinWallgren 92
  • Ability to override/ignore sub-dependencies

    Ability to override/ignore sub-dependencies

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.

    (However, it is related to https://github.com/sdispater/poetry/issues/436).

    Issue

    In the dark, old world of Python packaging, sub-dependencies are handled very poorly. If I recall correctly, pip will happily install a sub-dependency despite conflicting versions being specified by two direct dependencies... in fact I think which version it ends up installing depends on the order in requirements.txt. Yuck! Only very recently has it even started issuing a warning for cases like this.

    In contrast, poetry does this right. It computes the entire dependency tree and will complain if there are conflicts anywhere in the tree.

    But... many packages out there are not specifying their dependencies properly. Even if they are, there's always the possibility that their specified dependencies are a tighter range than they strictly need to be.

    Is there a way to tell Poetry to force a specific version (or version) range of a dependency in cases like this — or in other words, to ignore a dependency specification of another dependency somewhere in the tree? If not, should there be?

    area/solver kind/feature status/wontfix 
    opened by zehauser 83
  • peotry version doesn't bump the value in __version__

    peotry version doesn't bump the value in __version__

    $ poetry version 0.1.1
    Bumping version from 0.1.0 to 0.1.1
    $ grep version pyproject.toml 
    version = "0.1.1"
    $ grep version */__init__.py
    src/__init__.py:__version__ = '0.1.0'
    $ poetry --version
    Poetry 0.9.0
    

    I don't know if it's intended or not. A way to do that safely is to parse the root __init__.py, detect __version__, back it up, extract the ast, bump the version string and replace it, then extract the new ast and compare the result. If both ast are the same, except for the version, the file semantics have been preserved. Otherwise, rollback the change and display an error message stating we can't bump the version safely.

    area/cli kind/feature 
    opened by ksamuel 72
  • Support for .env files

    Support for .env files

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.

    Issue

    First off I really like poetry- I'd actually only recently migrated over to pipenv but I already see the advantages of poetry and would ideally like to use it full time.

    I primarily work with Django and other web frameworks that can require a large amount of configuration which- when following 12 factor app practices- involves lots of environment variables that necessitates the use of a .env file.

    Is there a possibility of adding in .env file support, specifically for poetry's run command so that the resulting command runs both in the virtualenv and with the environment as configured in the .env file?

    opened by ptink 71
  • Add support for `scripts`

    Add support for `scripts`

    It would be nice if poetry supported the scripts feature of setuptools (note: this is not the same as entry points).

    I tried using a custom build script but it seems to be ignored by poetry when building wheels.

    kind/feature 
    opened by ojii 67
  • TooManyRedirects when trying to add aioauth2

    TooManyRedirects when trying to add aioauth2

    • [x] I am on the latest Poetry version.
    • [x] I have searched the issues of this repo and believe that this is not a duplicate.
    • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
    • OS version and name: GNU/Linux 4.18.7-1-default, openSUSE Tumbleweed
    • Poetry version: 0.12.10
    • Link of a Gist with the contents of your pyproject.toml file: Irrelevant

    Issue

    I run poetry add and get this:

    $ poetry -vvv add aioauth2
                                       
    [TooManyRedirects]  
    Exceeded 30 redirects.           
                                       
    Exception trace:
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cleo/application.py in run() at line 94
       status_code = self.do_run(input_, output_)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/console/application.py in do_run() at line 88
       return super(Application, self).do_run(i, o)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cleo/application.py in do_run() at line 197
       status_code = command.run(input_, output_)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/console/commands/command.py in run() at line 77
       return super(BaseCommand, self).run(i, o)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cleo/commands/base_command.py in run() at line 146
       status_code = self.execute(input_, output_)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cleo/commands/command.py in execute() at line 107
       return self.handle()
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/console/commands/add.py in handle() at line 69
       packages, allow_prereleases=self.option("allow-prereleases")
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/console/commands/init.py in _determine_requirements() at line 230
       requirement["name"], allow_prereleases=allow_prereleases
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/console/commands/init.py in _find_best_version_for_package() at line 260
       name, required_version, allow_prereleases=allow_prereleases
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/version/version_selector.py in find_best_candidate() at line 29
       package_name, constraint, allow_prereleases=allow_prereleases
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pool.py in find_packages() at line 65
       name, constraint, extras=extras, allow_prereleases=allow_prereleases
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pypi_repository.py in find_packages() at line 104
       info = self.get_package_info(name)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pypi_repository.py in get_package_info() at line 228
       name, lambda: self._get_package_info(name)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cachy/repository.py in remember_forever() at line 174
       val = value(callback)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/cachy/helpers.py in value() at line 6
       return val()
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pypi_repository.py in <lambda>() at line 228
       name, lambda: self._get_package_info(name)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pypi_repository.py in _get_package_info() at line 232
       data = self._get("pypi/{}/json".format(name))
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/poetry/repositories/pypi_repository.py in _get() at line 381
       json_response = self._session.get(self._url + endpoint)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/requests/sessions.py in get() at line 546
       return self.request('GET', url, **kwargs)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/requests/sessions.py in request() at line 533
       resp = self.send(prep, **send_kwargs)
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/requests/sessions.py in send() at line 668
       history = [resp for resp in gen] if allow_redirects else []
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/requests/sessions.py in <listcomp>() at line 668
       history = [resp for resp in gen] if allow_redirects else []
     /home/rominf/.pyenv/versions/3.6.7/envs/jira-oauth/lib/python3.6/site-packages/requests/sessions.py in resolve_redirects() at line 165
       raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
    
    add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...
    
    kind/bug 
    opened by rominf 62
  • "expected string or bytes-like object" on poetry install

    • [X] I am on the latest Poetry version.
    • [X] I have searched the issues of this repo and believe that this is not a duplicate.
    • [X] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
    • OS version and name: based on official docker image python:3.8-slim-buster (see below for Dockerfile)
    • Poetry version: 1.1.4
    • virtualenv version: 20.4.2
    • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/wichert/ba05b0505c24ee7c71c5d7deb2ac2cfe

    Issue

    When I run poetry install in a private GitHub runner on an GHES installation I started getting an error (see further below for full output):

      TypeError
    
      expected string or bytes-like object
    
      at /usr/local/lib/python3.8/site-packages/poetry/core/utils/helpers.py:24 in canonicalize_name
    

    Debug output

    Creating virtualenv amp-portal in /__w/backend/backend/amp-portal/.venv
    Using virtualenv: /__w/backend/backend/amp-portal/.venv
    
      Stack trace:
    
      11  /usr/local/lib/python3.8/site-packages/clikit/console_application.py:131 in run
           129│             parsed_args = resolved_command.args
           130│ 
         → 131│             status_code = command.handle(parsed_args, io)
           132│         except KeyboardInterrupt:
           133│             status_code = 1
    
      10  /usr/local/lib/python3.8/site-packages/clikit/api/command/command.py:120 in handle
           118│     def handle(self, args, io):  # type: (Args, IO) -> int
           119│         try:
         → 120│             status_code = self._do_handle(args, io)
           121│         except KeyboardInterrupt:
           122│             if io.is_debug():
    
       9  /usr/local/lib/python3.8/site-packages/clikit/api/command/command.py:163 in _do_handle
           161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
           162│             event = PreHandleEvent(args, io, self)
         → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
           164│ 
           165│             if event.is_handled():
    
       8  /usr/local/lib/python3.8/site-packages/clikit/api/event/event_dispatcher.py:22 in dispatch
            20│ 
            21│         if listeners:
         →  22│             self._do_dispatch(listeners, event_name, event)
            23│ 
            24│         return event
    
       7  /usr/local/lib/python3.8/site-packages/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
            87│                 break
            88│ 
         →  89│             listener(event, event_name, self)
            90│ 
            91│     def _sort_listeners(self, event_name):  # type: (str) -> None
    
       6  /usr/local/lib/python3.8/site-packages/poetry/console/config/application_config.py:141 in set_installer
           139│ 
           140│         poetry = command.poetry
         → 141│         installer = Installer(
           142│             event.io,
           143│             command.env,
    
       5  /usr/local/lib/python3.8/site-packages/poetry/installation/installer.py:65 in __init__
            63│         self._installer = self._get_installer()
            64│         if installed is None:
         →  65│             installed = self._get_installed()
            66│ 
            67│         self._installed_repository = installed
    
       4  /usr/local/lib/python3.8/site-packages/poetry/installation/installer.py:561 in _get_installed
           559│ 
           560│     def _get_installed(self):  # type: () -> InstalledRepository
         → 561│         return InstalledRepository.load(self._env)
           562│ 
    
       3  /usr/local/lib/python3.8/site-packages/poetry/repositories/installed_repository.py:118 in load
           116│                 path = Path(str(distribution._path))
           117│                 version = distribution.metadata["version"]
         → 118│                 package = Package(name, version, version)
           119│                 package.description = distribution.metadata.get("summary", "")
           120│ 
    
       2  /usr/local/lib/python3.8/site-packages/poetry/core/packages/package.py:51 in __init__
            49│         Creates a new in memory package.
            50│         """
         →  51│         super(Package, self).__init__(
            52│             name,
            53│             source_type=source_type,
    
       1  /usr/local/lib/python3.8/site-packages/poetry/core/packages/specification.py:19 in __init__
            17│     ):  # type: (str, Optional[str], Optional[str], Optional[str], Optional[str], Optional[List[str]]) -> None
            18│         self._pretty_name = name
         →  19│         self._name = canonicalize_name(name)
            20│         self._source_type = source_type
            21│         self._source_url = source_url
    
      TypeError
    
      expected string or bytes-like object
    
      at /usr/local/lib/python3.8/site-packages/poetry/core/utils/helpers.py:24 in canonicalize_name
           20│ _canonicalize_regex = re.compile("[-_]+")
           21│ 
           22│ 
           23│ def canonicalize_name(name):  # type: (str) -> str
        →  24│     return _canonicalize_regex.sub("-", name).lower()
           25│ 
           26│ 
           27│ def module_name(name):  # type: (str) -> str
           28│     return canonicalize_name(name).replace(".", "_").replace("-", "_")
    

    Dockerfile for base docker image

    ARG DEBIAN_VERSION=buster
    ARG PYTHON_VERSION=3.8
    FROM python:${PYTHON_VERSION}-slim-${DEBIAN_VERSION}
    
    ENV \
        DEBIAN_FRONTEND=noninteractive \
        PYTHONUNBUFFERED=1 \
        PYTHONDONTWRITEBYTECODE=1 \
        POETRY_VIRTUALENVS_IN_PROJECT=true \
        POETRY_NO_INTERACTION=1
    
    RUN set -x \
        && apt-get update \
        && apt-get install -yq --no-install-recommends libpq-dev build-essential sudo \
        && rm -rf /var/lib/apt/lists/*
    
    RUN pip install poetry==1.1.4
    
    kind/bug 
    opened by wichert 61
  • Manually specifying the venv path

    Manually specifying the venv path

    Is it possible to manually (via some config) specify which venv poetry is going to use?

    Due to some requirements, I would like to have two projects sharing the same virtual environment.

    Best case scenario would be setting the path via a config or environment variable

    kind/feature 
    opened by viniciusd 58
  • Monorepo / Monobuild support?

    Monorepo / Monobuild support?

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.
    • [x] I have searched the documentation and believe that my question is not covered.

    Feature Request

    The goal is to allow a developer to make changes to multiple python packages in their repo without having to submit and update lock files along the way.

    Cargo, which poetry seems to be modeled after, supports this with two features

    • Path dependencies. You can specify where to find a dependency on disk for local development while still supporting version constraints for public consumption
    • Workspaces let you define a group of packages you can perform operations on, like cargo test --all will run tests on all packages in a workspace.

    It looks like some monobuild tools exist for python (buck, pants, bazel) but

    • Some don't support all major platforms
    • They assume you are not using pypi and do not publish to pypi and expect all dependencies to be submitted to SCM.
    status/duplicate 
    opened by epage 55
  • Poetry does not use active pyenv when creating virtual environment

    Poetry does not use active pyenv when creating virtual environment

    • [x] I am on the latest Poetry version.

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.

    • OS version and name: MacOS 10.14 Mojave

    • Poetry version: 0.12.8

    Issue

    I have a project directory with a .python-version file like this:

    3.7.1
    

    Poetry has been installed into Python 3.6.5. According to recent comments, poetry is supposed to detect the active Python version when creating a new virtual environment, but it seems to stick with 3.6.5 all the time. To illustrate:

    $ python --version
    Python 3.7.1
    $ poetry run python --version
    Python 3.6.5
    

    When I specify python = "^3.7" in `pyproject.toml I get an error:

    $ poetry shell
    
    [RuntimeError]
    The current Python version (3.6.5) is not supported by the project (^3.7)
    Please activate a compatible Python version.
    
    shell
    
    opened by bjoernpollex 53
  • `poetry add` doesn't work with `git+file:///` URLs (error: `Could not parse version constraint: ...`)

    `poetry add` doesn't work with `git+file:///` URLs (error: `Could not parse version constraint: ...`)

    • Poetry version: 1.3.1
    • Python version: 3.11.1
    • OS version and name: Debian bookworm (12)
    • pyproject.toml: NA
    • [x] I am on the latest stable Poetry version, installed using a recommended method (pipx).
    • [x] I have searched the issues of this repo and believe that this is not a duplicate.
    • [x] I have consulted the FAQ and blog for any relevant entries or release notes.
    • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

    Issue

    poetry add with git+file:/// URL of local git repository results in error: Could not parse version constraint: ///tmp/tmp.AcoK44cpew/[email protected].

    Reproduce with:

    _tmp="$(mktemp -d)"
    pushd "${_tmp}"
    poetry new prj1
    poetry new prj2
    _branch='main'
    git -C prj1 init --initial-branch "${_branch}"
    git -C prj1 add --all
    git -C prj1 commit -m 'initial commit'
    cd prj2
    
    # poetry fails to add the project from file:/// URL
    poetry add "git+file://${_tmp}/prj1@${_branch}"
    # => error: Could not parse version constraint: ///tmp/tmp.AcoK44cpew/[email protected]
    
    # pip install works just fine
    poetry shell
    _branch='main'
    pip install "git+file://${_tmp}/prj1@${_branch}"
    # => ...
    # => Successfully installed prj1-0.1.0
    

    The documentation doesn't claim that git+file:/// URLs are supported. So maybe this is a feature request. But since pip/setuptools has no issue with it, poetry should probably support it, too.

    Output of poetry -vvv add "git+file:///tmp/tmp.AcoK44cpew/[email protected]" ```log Loading configuration file /home/kai/.config/pypoetry/config.toml Trying to detect current active python executable as specified in the config. Found: /home/kai/.pyenv/versions/3.11.1/bin/python Using virtualenv: /home/kai/.cache/pypoetry/virtualenvs/prj2-Dc-OYFc9-py3.11

    Stack trace:

    15 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:327 in run 325│ 326│ try: → 327│ exit_code = self._run(io) 328│ except BrokenPipeError: 329│ # If we are piped to another process, it may close early and send a

    14 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/application.py:190 in _run 188│ self._load_plugins(io) 189│ → 190│ exit_code: int = super()._run(io) 191│ return exit_code 192│

    13 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:431 in _run 429│ io.input.interactive(interactive) 430│ → 431│ exit_code = self._run_command(command, io) 432│ self._running_command = None 433│

    12 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:473 in _run_command 471│ 472│ if error is not None: → 473│ raise error 474│ 475│ return terminate_event.exit_code

    11 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:457 in _run_command 455│ 456│ if command_event.command_should_run(): → 457│ exit_code = command.run(io) 458│ else: 459│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

    10 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/base_command.py:119 in run 117│ io.input.validate() 118│ → 119│ status_code = self.execute(io) 120│ 121│ if status_code is None:

    9 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.py:62 in execute 60│ 61│ try: → 62│ return self.handle() 63│ except KeyboardInterrupt: 64│ return 1

    8 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/add.py:158 in handle 156│ return 0 157│ → 158│ requirements = self._determine_requirements( 159│ packages, 160│ allow_prereleases=self.option("allow-prereleases"),

    7 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/init.py:385 in _determine_requirements 383│ # check that the specified version/constraint exists 384│ # before we proceed → 385│ name, _ = self._find_best_version_for_package( 386│ requirement["name"], 387│ requirement["version"],

    6 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/init.py:408 in _find_best_version_for_package 406│ 407│ selector = VersionSelector(self._get_pool()) → 408│ package = selector.find_best_candidate( 409│ name, required_version, allow_prereleases=allow_prereleases, source=source 410│ )

    5 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/version/version_selector.py:31 in find_best_candidate 29│ from poetry.factory import Factory 30│ → 31│ dependency = Factory.create_dependency( 32│ package_name, 33│ {

    4 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/factory.py:338 in create_dependency 336│ version = constraint["version"] 337│ → 338│ dependency = Dependency( 339│ name, 340│ version,

    3 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/packages/dependency.py:66 in init 64│ self._constraint: VersionConstraint 65│ self._pretty_constraint: str → 66│ self.constraint = constraint # type: ignore[assignment] 67│ 68│ self._optional = optional

    2 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/packages/dependency.py:110 in constraint 108│ def constraint(self, constraint: str | VersionConstraint) -> None: 109│ if isinstance(constraint, str): → 110│ self._constraint = parse_constraint(constraint) 111│ else: 112│ self._constraint = constraint

    1 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/constraints/version/parser.py:36 in parse_constraint 34│ constraint_objects.append(parse_single_constraint(constraint)) 35│ else: → 36│ constraint_objects.append(parse_single_constraint(and_constraints[0])) 37│ 38│ if len(constraint_objects) == 1:

    ParseConstraintError

    Could not parse version constraint: ///tmp/tmp.AcoK44cpew/[email protected]

    at ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/constraints/version/parser.py:167 in parse_single_constraint 163│ if op == "!=": 164│ return VersionUnion(VersionRange(max=version), VersionRange(min=version)) 165│ return version 166│ → 167│ raise ParseConstraintError(f"Could not parse version constraint: {constraint}") 168│

    </details>
    kind/feature status/triage 
    opened by ktetzlaff 2
  • Create an official Poetry badge

    Create an official Poetry badge

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.

    Issue

    Projects such as black and isort have official badges that they provide to users to allow them to promote their projects to great affect.

    Code style: black Imports: isort

    Poetry could create a badge for the project to help users of Poetry promote the tool in a similar way.

    An example could look like:

    Packaged with Poetry

    [![Packaged with Poetry][poetry-badge]](https://python-poetry.org/)
    
    [poetry-badge]: https://img.shields.io/badge/packaging-poetry-cyan.svg
    

    The colors could optionally be tweaked using the official logo colors:

    image

    The badge could be hosted on https://python-poetry.org/ to allow easy referencing from projects and a snippet of how to add the badge could be added to the docs.

    area/docs status/triage 
    opened by johnthagen 0
  • In-place upgrading of Python versions for virtualenvs

    In-place upgrading of Python versions for virtualenvs

    • [x] I have searched the issues of this repo and believe that this is not a duplicate.
    • [x] I have searched the FAQ and general documentation and believe that my question is not already covered.

    Feature Request

    Having worked with Poetry for a year now, I appreciate the capabilities and ease of Python dev it introduced to my workflow!

    Only one other thing I'd love to see from Poetry is the ability to upgrade virtualenvs in-place with a newer Python version installed with pyenv. Having to re-create the virtualenvs and reinstall all the dependencies feels too much, at least for minor releases (e.g 3.10.x)!

    This feature alongside #461 baked in Poetry would be awesome!

    kind/feature status/triage 
    opened by 0xLem0nade 0
  • full support for duplicate depenencies with overlapping markers

    full support for duplicate depenencies with overlapping markers

    Resolves: #5066

    Requires: python-poetry/poetry-core#530, python-poetry/poetry-core#546, python-poetry/poetry-core#547

    • replace _merge_dependencies_by_marker and _handle_any_marker_dependencies by the more general _resolve_overlapping_markers
    • raise IncompatibleConstraintsError if there are conflicts (due to incompatible version constraints or source types) in the constraints of a package

    Tested with opencv, which has the most duplicate dependencies with overlapping markers I know about:

    numpy (>=1.13.3) ; python_version < "3.7"
    numpy (>=1.21.2) ; python_version >= "3.10"
    numpy (>=1.21.2) ; python_version >= "3.6" and platform_system == "Darwin" and platform_machine == "arm64"
    numpy (>=1.19.3) ; python_version >= "3.6" and platform_system == "Linux" and platform_machine == "aarch64"
    numpy (>=1.14.5) ; python_version >= "3.7"
    numpy (>=1.17.3) ; python_version >= "3.8"
    numpy (>=1.19.3) ; python_version >= "3.9"
    

    Especially the markers with platform_system and platform_machine, which overlap with most other markers make this example quite complex.

    TODO: Investigation of the influence on the performance for (more) real-world examples

    • [x] Added tests for changed code.
    • [ ] Updated documentation for changed code.
    opened by radoering 0
  • Arbitrary Equality Requirements

    Arbitrary Equality Requirements

    • [X] I have searched the issues of this repo and believe that this is not a duplicate.
    • [X] I have searched the FAQ and general documentation and believe that my question is not already covered.

    Feature Request

    Hi, I think poetry should support arbitrary equality requirements as described in PEP 440. Current behavior is problematic in case of the following usage:

    [tool.poetry.dependencies]
    xgboost= [
        {version = "0.81+upstream", markers = "sys_platform == 'linux'", source="***"},
        {version = "0.81", markers = "sys_platform != 'linux'", source="***"},
    ]
    

    Results in only the 0.81+upstream version ever being installed (as though installed with pip install xgboost==0.81, which too installs 0.81+upstream if available)

    I propose to make the following requirement legal

    [tool.poetry.dependencies]
    xgboost= [
        {version = "0.81+upstream", markers = "sys_platform == 'linux'", source="***"},
        {version = "===0.81", markers = "sys_platform != 'linux'", source="***"},
    ]
    

    Which will install 0.81+upstream on linux systems and 0.81 on non-linux systems (install as though with pip install xgboost===0.81)

    kind/feature status/triage 
    opened by bentheiii 2
Releases(1.3.1)
Owner
Poetry
Python packaging and dependency management made easy
Poetry
Library Management System

Library Management Library Management System How to Use run main.py python file. python3 main.py Links Download Source Code: Click Here My Github Aco

Mohammad Dori 3 Jul 15, 2022
Python Environment & Package Manager

Python Environment Manager A Visual Studio Code extension that provides the ability to via and manage all of your Python environments & packages from

Don Jayamanne 72 Dec 29, 2022
[DEPRECATED] YUM package manager

⛔ This project is deprecated. Please use DNF, the successor of YUM. YUM Yum is an automatic updater and installer for rpm-based systems. Included prog

111 Dec 20, 2022
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/

This is a PyPI mirror client according to PEP 381 + PEP 503 http://www.python.org/dev/peps/pep-0381/. bandersnatch =4.0 supports Linux, MacOSX + Wind

Python Packaging Authority 345 Dec 28, 2022
Dotpkg - Package manager for your dotfiles

Dotpkg A package manager for your dotfiles. Usage First make sure to have Python

FW 4 Mar 18, 2022
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/

This is a PyPI mirror client according to PEP 381 + PEP 503 http://www.python.org/dev/peps/pep-0381/. bandersnatch =4.0 supports Linux, MacOSX + Wind

Python Packaging Authority 345 Dec 28, 2022
Example for how to package a Python library based on Cython.

Cython sample module This project is an example of a module that can be built using Cython. It is an upgrade from a similar model developed by Arin Kh

Juan José García Ripoll 4 Aug 28, 2022
Package manager based on libdnf and libsolv. Replaces YUM.

Dandified YUM Dandified YUM (DNF) is the next upcoming major version of YUM. It does package management using RPM, libsolv and hawkey libraries. For m

1.1k Dec 26, 2022
The Fast Cross-Platform Package Manager

The Fast Cross-Platform Package Manager part of mamba-org Package Manager mamba Package Server quetz Package Builder boa mamba Mamba is a reimplementa

Mamba 4k Dec 30, 2022
pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.

pipreqs - Generate requirements.txt file for any project based on imports Installation pip install pipreqs Usage Usage: pipreqs [options] path

Vadim Kravcenko 4.8k Dec 31, 2022
Easy to use, fast, git sourced based, C/C++ package manager.

Yet Another C/C++ Package Manager Easy to use, fast, git sourced based, C/C++ package manager. Features No need to install a program, just include the

31 Dec 21, 2022
A PDM plugin that packs your packages into a zipapp

pdm-packer A PDM plugin that packs your packages into a zipapp Requirements pdm-packer requires Python =3.7 Installation If you have installed PDM wi

Frost Ming 23 Dec 29, 2022
A set of tools to keep your pinned Python dependencies fresh.

pip-tools = pip-compile + pip-sync A set of command line tools to help you keep your pip-based packages fresh, even when you've pinned them. You do pi

Jazzband 6.5k Dec 29, 2022
Simple Library Management made with Python

Installation pip install mysql-connector-python NOTE: You must make a database (library) & and table (books, student) to hold all data. Languange and

SonLyte 10 Oct 21, 2021
pip-run - dynamic dependency loader for Python

pip-run provides on-demand temporary package installation for a single interpreter run. It replaces this series of commands (or their Windows equivale

Jason R. Coombs 79 Dec 14, 2022
The delightful package manager for AppImages

⚡️ Zap The delightful package manager for AppImages Report bug · Request feature Looking for the older Zap v1 (Python) implementation? Head over to v1

Srevin Saju 368 Jan 04, 2023
Solaris IPS: Image Packaging System

Solaris Image Packaging System Introduction The image packaging system (IPS) is a software delivery system with interaction with a network repository

Oracle 57 Dec 30, 2022
Python dependency management and packaging made easy.

Poetry: Dependency Management for Python Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right sta

Poetry 23.2k Jan 05, 2023
Cilantropy: a Python Package Manager interface created to provide an "easy-to-use" visual and also a command-line interface for Pythonistas.

Cilantropy Cilantropy is a Python Package Manager interface created to provide an "easy-to-use" visual and also a command-line interface for Pythonist

48 Dec 16, 2022
A flexible package manager that supports multiple versions, configurations, platforms, and compilers.

Spack Spack is a multi-platform package manager that builds and installs multiple versions and configurations of software. It works on Linux, macOS, a

Spack 3.1k Jan 09, 2023