Skip to content

Poetry always detects venvs created by mingw-w64-x86_64-python (MSYS2) as broken #2867

@daniel-a-melo

Description

@daniel-a-melo
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10
  • Poetry version: 1.0.10
  • Link of a Gist with the contents of your pyproject.toml file:
[tool.poetry]
name = "poetry-demo2"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
pendulum = "^2.1.2"

[tool.poetry.dev-dependencies]
pytest = "^5.2"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

When using MSYS2, package mingw-w64-x86_64-python (https://packages.msys2.org/package/mingw-w64-x86_64-python) venvs are created with POSIX-style layout :

 daniel@GALILEO ~/A/L/p/C/v/poetry-demo2-raCoCXDb-py3.8> pwd
/c/Users/Daniel/AppData/Local/pypoetry/Cache/virtualenvs/poetry-demo2-raCoCXDb-py3.8
daniel@GALILEO ~/A/L/p/C/v/poetry-demo2-raCoCXDb-py3.8> ls -al
total 5
drwxr-xr-x 1 daniel daniel   0 Aug 29 23:05 ./
drwxr-xr-x 1 daniel daniel   0 Aug 29 23:05 ../
drwxr-xr-x 1 daniel daniel   0 Aug 29 23:06 bin/
drwxr-xr-x 1 daniel daniel   0 Aug 29 23:05 include/
drwxr-xr-x 1 daniel daniel   0 Aug 29 23:05 lib/
-rw-r--r-- 1 daniel daniel 106 Aug 29 23:05 pyvenv.cfg

Every subsequent command will display the message "The virtual environment found in seems to be broken" and the venv will be recreated. I

Steps to reproduce

1 - Install MSYS2
2 - From MSYS shell, install python mingw64 build : pacman -S mingw-w64-x86_64-python
3 - Install poetry
4 - poetry new poetry-demo
5 - poetry install
6 - poetry show . The message will be displayed and venv will be recreated.

The cause seems to be in

bin_dir = "bin" if not self._is_windows else "Scripts"

As the system is detected to be Windows it expects the bin dir to be Scripts which is not the case for venvs created with this python distro.

I changed this line to be bin_dir = "bin" and it seems to work correctly.

it is possible to detect this python distro with sysconfig.get_platform() . It will return mingw . See https://stackoverflow.com/questions/35956180/how-to-determine-the-python-is-mingw-or-official-build

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions