Skip to content

Improve logic for detecting msys2-based Python (works for 3.11 and 3.…#6

Merged
frostming merged 3 commits intopdm-project:mainfrom
cr1901:msys-fix
Mar 10, 2025
Merged

Improve logic for detecting msys2-based Python (works for 3.11 and 3.…#6
frostming merged 3 commits intopdm-project:mainfrom
cr1901:msys-fix

Conversation

@cr1901
Copy link
Contributor

@cr1901 cr1901 commented Nov 10, 2024

…12).

The MSYS2 project standardized sysconfig names for 3.12, resulting in errors such as the following after an upgrade:

$ pdm run -v test.py pipx
INFO: Reusing existing script environment: C:/Users/William/AppData/Local/pdm/pdm/venvs/2fa106ce3fc8b29bf047ce91804516ef
Traceback (most recent call last):
  File "C:/msys64/home/William/Projects/python/pdm/src/pdm/models/in_process/env_spec.py", line 25, in <module>
    print(json.dumps(get_current_env_spec(), indent=2))
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/home/William/Projects/python/pdm/src/pdm/models/in_process/env_spec.py", line 16, in get_current_env_spec
    "platform": str(Platform.current()),
                    ^^^^^^^^^^^^^^^^^^
  File "C:/msys64/home/William/Projects/python/dep-logic/src/dep_logic/tags/platform.py", line 164, in current
    return cls(os_, Arch.parse(architecture))
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/home/William/Projects/python/dep-logic/src/dep_logic/tags/platform.py", line 390, in parse
    return cls(arch)
           ^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'x86_64_msvcrt_gnu' is not a valid Arch

This PR slightly changes the logic introduced by pdm-project/pdm#3158 for detecting the arch in the MSYS2 case (works for 3.12 and while I don't have 3.11 to test right now, I checked that the mingw_x86_64 string also triggers my updated logic.

@cr1901
Copy link
Contributor Author

cr1901 commented Mar 4, 2025

I just ran into this issue again after upgrading pdm, and forgetting to inject my copy of dep-logic into the pipx environment. I totally forgot I made this PR. @frostming Are there any changes that you'd like me to make, or should I continue to wait patiently until you have some free time to look at this?

Copy link
Contributor

@frostming frostming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, I've missed it.

@cr1901
Copy link
Contributor Author

cr1901 commented Mar 9, 2025

Thank you for being patient. I have implemented the requested changes.

@frostming frostming merged commit 7007756 into pdm-project:main Mar 10, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants