Poetry: Poetry unable to add pex to Python3 project

Created on 2 Apr 2020  路  2Comments  路  Source: python-poetry/poetry

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

Issue

Trying to add pex as a dev (or regular) dependency fails with a SolverProblemError:
```lang=sh
poetry new --src poetry_bug
cd poetry_bug
poetry add --dev pex

```lang=sh
The currently activated Python version 2.7.17 is not supported by the project (^3.4).
Trying to find and use a compatible version. 
Trying python3
Using python3 (3.7.7)
Virtualenv poetry-bug-3oKZJDu--py3.7 already exists.
Using virtualenv: /home/----/.cache/pypoetry/virtualenvs/poetry-bug-3oKZJDu--py3.7
PyPI: 97 packages found for pex *
Using version ^2.1.8 for pex

Updating dependencies
Resolving dependencies...
   1: fact: poetry-bug is 0.1.0
   1: derived: poetry-bug
   1: fact: poetry-bug depends on pytest (^4.6)
   1: fact: poetry-bug depends on pex (^2.1.8)
   1: fact: poetry-bug depends on pytest (^4.6)
   1: fact: poetry-bug depends on pex (^2.1.8)
   1: selecting poetry-bug (0.1.0)
   1: derived: pex (^2.1.8)
   1: derived: pytest (^4.6)
PyPI: 1 packages found for pex >=2.1.8,<3.0.0
   1: fact: pex (2.1.8) requires Python >=2.7,<3.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
   1: derived: not pex (2.1.8)
   1: fact: no versions of pex match >2.1.8,<3.0.0
   1: conflict: no versions of pex match >2.1.8,<3.0.0
   1: ! pex (>2.1.8,<3.0.0) is partially satisfied by not pex (2.1.8)
   1: ! which is caused by "pex (2.1.8) requires Python >=2.7,<3.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*"
   1: ! thus: pex is forbidden
   1: ! pex (>=2.1.8,<3.0.0) is satisfied by pex (^2.1.8)
   1: ! which is caused by "poetry-bug depends on pex (^2.1.8)"
   1: ! thus: version solving failed
   1: Version solving took 0.015 seconds.
   1: Tried 1 solutions.

[SolverProblemError]
The current project's Python requirement (^3.4) is not compatible with some of the required packages Python requirement:
  - pex requires Python >=2.7,<3.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*

Because no versions of pex match >2.1.8,<3.0.0
 and pex (2.1.8) requires Python >=2.7,<3.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*, pex is forbidden.
So, because poetry-bug depends on pex (^2.1.8), version solving failed.

Traceback (most recent call last):
  File "/home/----/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/----/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/----/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/----/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/----/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
    status = installer.run()
  File "/home/----/.poetry/lib/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/home/----/.poetry/lib/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/home/----/.poetry/lib/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/home/----/.poetry/lib/poetry/puzzle/solver.py", line 190, in _solve
    raise SolverProblemError(e)

Seems to work correctly when using Python2. Activating the virtualenv and installing directly via pip also works just fine.

Also tested this on macOS.

Bug

Most helpful comment

Hello @taranjlu ,

poetry tries to find a major version of a package that is available for all python version that can be used within a project. In your pyproject.toml you have defined ^3.4 for python. This means all python versions >=3.4 but <4.

pex has defined that it is not compatible with python 3.4 and the version must be <3.9. So that's in conflict with your project requirements.

Solution: Set your python requirement to >3.4,<3.9

TL,DR: poetry is only satisfied if it can resolve dependencies for python version specified in the pyproject.toml and not only for the currently used one.

fin swimmer

All 2 comments

Hello @taranjlu ,

poetry tries to find a major version of a package that is available for all python version that can be used within a project. In your pyproject.toml you have defined ^3.4 for python. This means all python versions >=3.4 but <4.

pex has defined that it is not compatible with python 3.4 and the version must be <3.9. So that's in conflict with your project requirements.

Solution: Set your python requirement to >3.4,<3.9

TL,DR: poetry is only satisfied if it can resolve dependencies for python version specified in the pyproject.toml and not only for the currently used one.

fin swimmer

Ah, okay, I see. Thank you for clearing that up. I had assumed that it would look at the various dependencies and requirements to determine if any valid configuration exists and then use that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ambv picture ambv  路  3Comments

jbarlow83 picture jbarlow83  路  3Comments

etijskens picture etijskens  路  3Comments

AWegnerGitHub picture AWegnerGitHub  路  3Comments

mozartilize picture mozartilize  路  3Comments