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 fails to find Git on Windows 10

    Poetry fails to find Git on Windows 10

    • Poetry version: 1.31
    • Python version: 3.10.4
    • OS version and name: Windows 10
    • pyproject.toml: n/a
    • [x] I am on the latest stable Poetry version, installed using a recommended method.
    • [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.
    powershell> poetry new pygame-test -vvv
    
      Stack trace:
    
      9  AppData\Roaming\pypoetry\venv\lib\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
    
      8  AppData\Roaming\pypoetry\venv\lib\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│
    
      7  AppData\Roaming\pypoetry\venv\lib\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│
    
      6  AppData\Roaming\pypoetry\venv\lib\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
    
      5  AppData\Roaming\pypoetry\venv\lib\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
    
      4  AppData\Roaming\pypoetry\venv\lib\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:
    
      3  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py:62 in execute
           60│
           61│         try:
        →  62│             return self.handle()
           63│         except KeyboardInterrupt:
           64│             return 1
    
      2  AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\new.py:66 in handle
           64│         readme_format = self.option("readme") or "md"
           65│
        →  66│         config = GitConfig()
           67│         author = None
           68│         if config.get("user.name"):
    
      1  AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:199 in __init__
          197│         try:
          198│             config_list = subprocess.check_output(
        → 199│                 [executable(), "config", "-l"], stderr=subprocess.STDOUT
          200│             ).decode()
          201│
    
      RuntimeError
    
      Unable to find a valid git executable
    
      at AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:182 in executable
          178│     else:
          179│         _executable = "git"
          180│
          181│     if _executable is None:
        → 182│         raise RuntimeError("Unable to find a valid git executable")
          183│
          184│     return _executable
          185│
          186│
    powershell> git --version
    git version 2.34.1.windows.1
    

    Issue

    Trying to create a new poetry project on windows 10 fails saying it hasn't found git. I recently updated poetry from 1.1.13 to 1.3.1 by running poetry self update and copying ~\AppData\Roaming\pypoetry\venv\Scripts\poetry.exe to ~\AppData\Roaming\Python\Scripts\poetry.exe as suggested in #5377. That worked. Then trying to create a new project via poetry new, poetry complains that it hasn't found a valid git executable, when git is in PATH, looking at the source code it trys to run %WINDIR%\\System32\\where.exe git, running this command in cmd finds git successfully. Maybe poetry requires a newer version of git than 2.34 which I have, seeing that the latest is 2.39?

    kind/bug status/triage 
    opened by mrlegohead0x45 3
  • release: bump version to 1.3.2

    release: bump version to 1.3.2

    Fixed

    • Fix a performance regression when locking dependencies from PyPI (#7232).
    • Fix an issue where passing a relative path via -C, --directory fails (#7266).

    Docs

    • Update docs to reflect the removal of the deprecated get-poetry.py installer from the repository (#7288).
    • Add clarifications for virtualenvs.path settings (#7286).
    opened by radoering 0
  • Add configuration option to use a global packages repository on the system, and symlink them to the local venv

    Add configuration option to use a global packages repository on the system, and symlink them to the local venv

    • [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

    The idea is pretty simple : as is evident with the nodejs ecosystem, local package installations can take quite a lot of disk space, especially as the number of projects grows. It's pretty common, after all to regularly delete all of your node_modules from your projects directories.

    In order to alleviate that, it would be a good idea to instead centralize the packages in the home directory like in ~/.poetry/site-packages/ or ~/AppData/Local/poetry/site-packages/ on windows systems.

    The directory architecture could be something like

    poetry/
    ├─ site-packages/
    │  ├─ package1/
    │  │  ├─ 1.0.0/
    │  │  │  ├─ __init__.py
    │  │  ├─ 1.1.0/
    │  │  │  ├─ __init__.py
    │  ├─ package2/
    │  │  ├─ 3.1.2/
    │  │  │  ├─ __init__.py
    │  ├─ dependency_graph.json
    

    Each package would be versionned, and the installation would be global to the user directory. When creating a virtualenv with poetry, it would then symlink to the actual files in the home directory.

    Furthermore, as you can see, there would be a dependency_graph.json file (file name or format could change depending on needs, maybe having an sqlite db instead would be more efficient). It would be used to speed up the dependency resolution. When querying an existing module, the dependency graph would be stored in that file, to be retrieved next time if the queried module is the same. Its structure could be something like

    {
      "module:version": [
        {
          "dependencies": [
            "module2:version",
            "module3:version"
          ]
        }
      ],
      "module2:version": [
        {
          "dependencies": [
          ]
        }
      ],
      "module3:version": [
        {
          "dependencies": [
          ]
        }
      ]
    }
    

    Any ideas or feedbacks to improve on this feature request would be greatly appreciated

    kind/feature status/triage 
    opened by Dogeek 0
  • poetry build for source naming convention changed between version 1.2.0 and 1.2.1

    poetry build for source naming convention changed between version 1.2.0 and 1.2.1

    • Poetry version: 1.2.0 behavior as compare to 1.2.1 and up
    • Python version: 3.9.13
    • OS version and name: Windows 10
    • pyproject.toml: https://github.com/pandas-dev/pandas-stubs/blob/main/pyproject.toml
    • [x] I am on the latest stable Poetry version, installed using a recommended method.
    • [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.
    • [N/A ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

    Issue

    We use poetry to build pandas-stubs.

    With poetry version 1.2.0, when we do poetry build, we would get the following files:

    Building pandas-stubs (1.5.2.230105)
      - Building sdist
      - Built pandas-stubs-1.5.2.230105.tar.gz
      - Building wheel
      - Built pandas_stubs-1.5.2.230105-py3-none-any.whl
    

    With poetry version 1.2.1 and above, when we do poetry build, we get the following files:

    Building pandas-stubs (1.5.2.230105)
      - Building sdist
      - Built pandas_stubs-1.5.2.230105.tar.gz
      - Building wheel
      - Built pandas_stubs-1.5.2.230105-py3-none-any.whl
    

    Note the change in the sdist of the source, where it used to be pandas-stubs, and now it is pandas_stubs. In other words, it used to include a hyphen, and now it is an underscore.

    Is this a documented and intentional change? For stubs packages, it isn't a great thing!

    kind/bug status/triage 
    opened by Dr-Irv 3
  • utils.env._full_python_path output encoding on Windows

    utils.env._full_python_path output encoding on Windows

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

    Issue

    I want to use poetry along with pyenv-win. When I set prefer-active-python = true and call poetry install I get "Command cannot be found" error:

    PS F:\python\projects\tutorial-hypermodern-python-winand> poetry install
    El sistema no puede encontrar la ruta especificada.
    
    Command 'C:\Users\Àíäðåé\.pyenv\pyenv-win\versions\3.8.10\python.exe -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))"' returned non-zero exit status 1.
    

    Username in the output has broken encoding (Àíäðåé instead of Андрей). I've found out that poetry tries to get current interpreter using utils.env._full_python_path function which returns broken path in my case.

    I've found two possible solutions:

    • Add universal_newlines=True / text=True to subprocess.check_output call. That fixes only paths which can be encoded with local encoding - cp1251.
    • Encode output to UTF-8 in child process:
    subprocess.check_output(
        list_to_shell_command(
            # [python, "-c", '"import sys; print(sys.executable)"']
            [python, "-c", '"import sys; sys.stdout.buffer.write(sys.executable.encode())"']
        ),
        shell=True,
    ).strip()
    
    kind/bug status/triage 
    opened by Winand 1
Releases(1.3.1)
Owner
Poetry
Python packaging and dependency management made easy
Poetry
A Poetry plugin for dynamically extracting the package version.

Poetry Version Plugin A Poetry plugin for dynamically extracting the package version. It can read the version from a file __init__.py with: # __init__

Sebastián Ramírez 264 Dec 22, 2022
PokerFace is a Python package for various poker tools.

PokerFace is a Python package for various poker tools. The following features are present in PokerFace... Types for cards and their componen

Juho Kim 21 Dec 29, 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
Install and Run Python Applications in Isolated Environments

pipx — Install and Run Python Applications in Isolated Environments Documentation: https://pipxproject.github.io/pipx/ Source Code: https://github.com

5.8k Dec 31, 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
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
Workon - A simple project manager for conda, windows 10 and vscode

WORK ON A simple project manager for conda, windows 10 and vscode Installation p

Jesus Alan Hernandez Galvan 1 Jan 16, 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
local pypi server (custom packages and auto-mirroring of pypi)

localshop A PyPI server which automatically proxies and mirrors PyPI packages based upon packages requested. It has support for multiple indexes and t

Michael van Tellingen 383 Sep 23, 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
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
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
For when Poetry just doesn't work.

Ballad For when Poetry just doesn't work. Have you tried setting up Poetry, but something doesn't work? Maybe you're... Trying to implement Github Act

BD103 4 Dec 06, 2021
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.1k Jan 01, 2023
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
A tool that updates all your project's Python dependency files through Pull Requests on GitHub/GitLab.

A tool that updates all your project's Python dependency files through Pull Requests on GitHub/GitLab. About This repo contains the bot that is runnin

pyup.io 413 Dec 29, 2022
Install All Basic Termux Packages To Your Phone

~All-Packages~ The Easiest Way To Install All Termux Packages 🤗 Tool By ⒹⓈ᭄ʜʏᴅʀᴀ✘๛ˢᴸ 👇 Contact Me On 👇 AVAILABLE ON : Termux TESTED ON : Term

ⒹⓈ ʜʏͥᴅᷧʀᷟᴀ✘๛ˢᴸ 7 Nov 12, 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
A tool to upgrade dependencies to the latest versions

pip-check-updates A tool to upgrade dependencies to the latest versions, inspired by npm-check-updates Install From PyPi pip install pip-check-updates

Zeheng Li 12 Jan 06, 2023
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