poetry 1.1.0+ does not correctly detect python version in an activated virtualenv created via `python3 -m venv`

Created on 12 Nov 2020  Â·  4Comments  Â·  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).

  • OS version and name: Ubuntu 18.04

  • Poetry version: v1.1.4 (replicated on 1.1.0, 1.1.0b3, 1.1.0rc1)
  • Link of a Gist with the contents of your pyproject.toml file: Sadly can't share, includes info about a non-public project

Issue

We use poetry as part of our deployment process and have been really happy with it. So first: thanks for the great tool!

One of our systems had the following deployment steps:

python3 -m venv app-venv
source app-venv/bin/activate
poetry install --no-dev

and we were surprised to see it started to fail when we upgraded our poetry version.

The error looks like so:

$ poetry install --no-dev
Installing dependencies from lock file

Package operations: 28 installs, 2 updates, 0 removals

  • Updating certifi (2020.6.20 -> 2020.11.8)
  • Installing cryptography (3.2.1): Failed

  EnvCommandError

  Command ['/home/sirosen/test-env/bin/pip', 'install', '--no-deps', 'file:///home/sirosen/.cache/pypoetry/artifacts/46/98/d5/45908b6a9cc86c20356836d469529346913be679b28b77e1f811b092ce/cryptography-3.2.1-cp35-abi3-manylinux2010_x86_64.whl'] errored with the following return code 1, and output:
  cryptography-3.2.1-cp35-abi3-manylinux2010_x86_64.whl is not a supported wheel on this platform.


  at /opt/poetry/lib/python3.6/site-packages/poetry/utils/env.py:1074 in _run
      1070│                 output = subprocess.check_output(
      1071│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1072│                 )
      1073│         except CalledProcessError as e:
    → 1074│             raise EnvCommandError(e, input=input_)
      1075│
      1076│         return decode(output)
      1077│
      1078│     def execute(self, bin, *args, **kwargs):

It seems that somehow poetry's ability to detect which python version is in use in a virtualenv now hinges on the virtualenv having been created with virtualenv and not the venv module.
This is fine, but I think poetry should detect and hard abort if it's run on something made with venv, if this is going to be the behavior.

Bug Triage

All 4 comments

I feel like a similar error has already been filed. Also there is definitely something going on with cryptography.

Maybe related:

I wasn't able to find another report of this, but definitely please close as a dup if I missed it! That comment on #3160 about cryptography appears to be the same issue.

It could be cryptography, but it's also possible that that's just one of the only widely used packages which doesn't use a universal wheel. Unlike many of the reports of "flaky" failures, I find that this was very consistent.

I was able to reproduce the whole thing in a temp dir with the following script:

echo '
[tool.poetry]
name = "tmp"
version = "0.1.0"
description = ""
authors = ["Stephen Rosen <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.6"
cryptography = "^3.2.1"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
' > pyproject.toml
poetry lock
python3 -m venv test-env
. test-env/bin/activate
poetry install

Not sure if it's a duplicate ticket or not. For now, I am just trying to connect tickets together, so that maintainers have an easier job later on. Thanks for trying to make a minimal reproducible example.

Hello @sirosen,

I was able to reproduce it with your example. And I was able to solve it by make sure you have the latest pip version installed in your venv, like @sinoroc mentioned here.

fin swimmer

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeremy886 picture jeremy886  Â·  3Comments

ulope picture ulope  Â·  3Comments

thejohnfreeman picture thejohnfreeman  Â·  3Comments

mozartilize picture mozartilize  Â·  3Comments

probablykasper picture probablykasper  Â·  3Comments