Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDM will unconditionally install packages with MSYS2 Python rather than compile C/Rust extensions. #3158

Closed
1 task done
cr1901 opened this issue Sep 13, 2024 · 14 comments
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@cr1901
Copy link
Contributor

cr1901 commented Sep 13, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

If a Python package has non-Python code, generally with MSYS2 Python, the package must be compiled from source due to technically incompatible ABIs1. Since commit c190e14, pdm will install such packages immediately using a wheel for MSVC rather than compile the wheel from source.

c190e14 is 2000+ lines of changes; I imagine this particular behavior can be fixed in a few lines (I hope!). I would be happy to bisect further, but the feat/lock-targets branch in #2995 doesn't seem to exist anymore.

  1. The resulting installed package may or may not work. E.g. jupyter notebook fails to properly initialize due to a missing Cython-compiled zmq, ruff works fine.

Steps to reproduce

  1. Checkout a version of pdm after/during commit c190e14 and install it using a Python provided by the MSYS2 project:

    William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
    $ python
    Python 3.11.9 (main, Apr 12 2024, 09:55:31)  [GCC 13.2.0 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
    William@DESKTOP-3H1DSBV MINGW64 ~/Projects/python/pdm
    $ pip install -e .
    ...
    Successfully installed pdm-2.16.2.dev8+gc190e143
    
  2. Create a dummy pdm project:

    William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
    $ pdm init -v
    Creating a pyproject.toml for PDM...
    Please enter the Python interpreter to use
     0. cpython@3.11 (C:/msys64/mingw64/bin/python.EXE)
     1. cpython@3.12 (C:/msys64/usr/bin/python3.12.exe)
     2. cpython@3.12 (C:/msys64/usr/bin/python3.exe)
     4. cpython@3.12 (C:/msys64/usr/bin/python.exe)
     5. cpython@3.11 (C:/msys64/home/William/Projects/MCVE/pdm-install/.venv/bin/python.exe)
     6. cpython@3.11 (C:/msys64/mingw64/bin/python3.11.exe)
     7. cpython@3.11 (C:/msys64/mingw64/bin/python3.exe)
     8. cpython@3.11 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.11.8/python.exe)
     9. cpython@3.8 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.8.18/python.exe)
    Please select (0): 0
    INFO: Cleaning existing target directory C:/msys64/home/William/Projects/MCVE/pdm-install/.venv
    Run command: ['C:/msys64/mingw64/bin/python.exe', '-m', 'virtualenv', 'C:/msys64/home/William/Projects/MCVE/pdm-install/.venv', '-p',
    'C:/msys64/mingw64/bin/python.EXE', '--prompt=pdm-install-3.11', '--no-pip', '--no-setuptools', '--no-wheel']
    created virtual environment CPython3.11.9.final.0-64 in 193ms
      creator CPython3Windows(dest=C:/msys64/home/William/Projects/MCVE/pdm-install/.venv, clear=False, no_vcs_ignore=False, global=False)
      activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
    Virtualenv is created successfully at C:/msys64/home/William/Projects/MCVE/pdm-install/.venv
    Project name (pdm-install):
    Project version (0.1.0):
    Do you want to build this project for distribution(such as wheel)?
    If yes, it will be installed by default when running `pdm install`. [y/n] (n):
    License(SPDX name) (MIT):
    Author name (William D. Jones):
    Author email (thor0505@comcast.net):
    Python requires('*' to allow any) (==3.11.*):
    Project is initialized successfully
    INFO: PDM 2.16.2.dev8+gc190e143 is installed, while 2.18.2 is available.
    Please run `C:/msys64/mingw64/bin/python.exe -m pdm self update` to upgrade.
    Run `pdm config check_update false` to disable the check.
    
  3. Install any non-pure-Python package (i.e. requires C or Rust code). For this example, I chose ruff:

    William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
    $ pdm add -v ruff
    Adding packages to default dependencies: ruff
    STATUS: Resolving dependencies
    STATUS: Resolve for environment (==3.11.*)
    pdm.termui: ======== Start resolving requirements ========
    pdm.termui:   ruff
    pdm.termui:   Adding requirement ruff
    pdm.termui:   Adding requirement python==3.11.*
    pdm.termui: ======== Starting round 0 ========
    STATUS: Resolving: new pin python==3.11.*
    pdm.termui: Pinning: python None
    pdm.termui: ======== Ending round 0 ========
    pdm.termui: ======== Starting round 1 ========
    STATUS: Resolving: new pin ruff 0.6.4
    pdm.termui: Pinning: ruff 0.6.4
    pdm.termui: ======== Ending round 1 ========
    pdm.termui: ======== Starting round 2 ========
    pdm.termui: ======== Resolution Result ========
    pdm.termui: Stable pins:
    pdm.termui:   python None
    pdm.termui:     ruff 0.6.4
    pdm.termui: Fetching hashes for ruff@0.6.4
    � Lock successful.
    Changes are written to pyproject.toml.
    STATUS: Resolving packages from lockfile...
    Synchronizing working set with resolved packages: 1 to add, 0 to update, 0 to remove
    
    pdm.termui: Using cached response for https://files.pythonhosted.org/packages/6b/d2/2dee8c547bee3d4cfdd897f7b8e38510383acaff2c8130ea783
    
    b67631d72/ruff-0.6.4-py3-none-win_amd64.whl
    unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/6b/d2/2dee8c547bee3d4cfdd897f7b8e38510383acaff2c8130ea783b6
    
    7631d72/ruff-0.6.4-py3-none-win_amd64.whl (from https://pypi.org/simple/ruff/)> (8.8 MB)
    ✔ Install ruff 0.6.4 successful
    
    � All complete!
    INFO: PDM 2.16.2.dev8+gc190e143 is installed, while 2.18.2 is available.
    Please run `C:/msys64/mingw64/bin/python.exe -m pdm self update` to upgrade.
    Run `pdm config check_update false` to disable the check.
    

Actual behavior

ruff/your Python package of choice is immediately installed from an upstream wheel with an incompatible ABI.

Expected behavior

ruff/your Python package of choice should be compiled from source. This is what happens in 7d39569, the commit immediately preceding c190e14:

(cargo/rustc output has been stripped for brevity)

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm -V
PDM, version 2.16.2.dev7+g7d395693

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ export CARGO_PROFILE_RELEASE_LTO="false"

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm init -v
Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
 0. cpython@3.11 (C:/msys64/mingw64/bin/python.EXE)
 1. cpython@3.12 (C:/msys64/usr/bin/python3.12.exe)
 2. cpython@3.12 (C:/msys64/usr/bin/python3.exe)
 3. cpython@3.12 (C:/msys64/usr/bin/python.exe)
 4. cpython@3.11 (C:/msys64/home/William/Projects/MCVE/pdm-install/.venv/bin/python.exe)
 5. cpython@3.11 (C:/msys64/mingw64/bin/python3.11.exe)
 6. cpython@3.11 (C:/msys64/mingw64/bin/python3.exe)
 7. cpython@3.11 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.11.8/python.exe)
 8. cpython@3.8 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.8.18/python.exe)
Please select (0):
INFO: Cleaning existing target directory C:/msys64/home/William/Projects/MCVE/pdm-install/.venv
Run command: ['C:/msys64/mingw64/bin/python.exe', '-m', 'virtualenv', 'C:/msys64/home/William/Projects/MCVE/pdm-install/.venv', '-p',
'C:/msys64/mingw64/bin/python.EXE', '--prompt=pdm-install-3.11', '--no-pip', '--no-setuptools', '--no-wheel']
created virtual environment CPython3.11.9.final.0-64 in 194ms
  creator CPython3Windows(dest=C:/msys64/home/William/Projects/MCVE/pdm-install/.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at C:/msys64/home/William/Projects/MCVE/pdm-install/.venv
Project name (pdm-install):
Project version (0.1.0):
Do you want to build this project for distribution(such as wheel)?
If yes, it will be installed by default when running `pdm install`. [y/n] (n):
License(SPDX name) (MIT):
Author name (William D. Jones):
Author email (thor0505@comcast.net):
Python requires('*' to allow any) (==3.11.*):
Project is initialized successfully
INFO: PDM 2.16.2.dev7+g7d395693 is installed, while 2.18.2 is available.
Please run `C:/msys64/mingw64/bin/python.exe -m pdm self update` to upgrade.
Run `pdm config check_update false` to disable the check.

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm add -v ruff
Adding packages to default dependencies: ruff
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   ruff
pdm.termui:   python==3.11.*
pdm.termui:   Adding requirement ruff
pdm.termui:   Adding requirement python==3.11.*
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python==3.11.*
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
STATUS: Resolving: new pin ruff 0.6.4
pdm.termui: Pinning: ruff 0.6.4
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:   python None
pdm.termui:     ruff 0.6.4
STATUS: Fetching hashes for resolved packages...
pdm.termui: Fetching hashes for ruff@0.6.4
� Lock successful
Changes are written to pyproject.toml.
STATUS: Resolving packages from lockfile...
Synchronizing working set with resolved packages: 1 to add, 0 to update, 0 to remove

pdm.termui: Using cached response for https://files.pythonhosted.org/packages/a4/55/9f485266e6326cab707369601b13e3e72eb90ba3eee2d677954

9a00a0d58/ruff-0.6.4.tar.gz
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/a4/55/9f485266e6326cab707369601b13e3e72eb90ba3eee2d6779549a

00a0d58/ruff-0.6.4.tar.gz (from https://pypi.org/simple/ruff/)> (2.5 MB)
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
pdm.termui: Saving wheel to cache: <Link https://files.pythonhosted.org/packages/a4/55/9f485266e6326cab707369601b13e3e72eb90ba3eee2d677

9549a00a0d58/ruff-0.6.4.tar.gz (from https://pypi.org/simple/ruff/)>
pdm.termui: Running PEP 517 backend to build a wheel for <Link https://files.pythonhosted.org/packages/a4/55/9f485266e6326cab707369601b

13e3e72eb90ba3eee2d6779549a00a0d58/ruff-0.6.4.tar.gz (from https://pypi.org/simple/ruff/)>
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   maturin<2.0,>=1.0
pdm.termui:   python==3.11.9
pdm.termui:   Adding requirement maturin<2.0,>=1.0
pdm.termui:   Adding requirement python==3.11.9
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: Pinning: maturin 1.7.1
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:    python None
pdm.termui:   maturin 1.7.1
pdm.termui: Installing maturin@1.7.1...
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/1d/ec/1f688d6ad82a568fd7c239f1c7a130d3fc2634977df4ef662ee

0ac58a153/maturin-1.7.1.tar.gz
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/1d/ec/1f688d6ad82a568fd7c239f1c7a130d3fc2634977df4ef662ee0a

c58a153/maturin-1.7.1.tar.gz (from https://pypi.org/simple/maturin/)> (190 kB)
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
pdm.termui: Saving wheel to cache: <Link https://files.pythonhosted.org/packages/1d/ec/1f688d6ad82a568fd7c239f1c7a130d3fc2634977df4ef66

2ee0ac58a153/maturin-1.7.1.tar.gz (from https://pypi.org/simple/maturin/)>
pdm.termui: Running PEP 517 backend to build a wheel for <Link https://files.pythonhosted.org/packages/1d/ec/1f688d6ad82a568fd7c239f1c7

a130d3fc2634977df4ef662ee0ac58a153/maturin-1.7.1.tar.gz (from https://pypi.org/simple/maturin/)>
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   setuptools-rust>=1.4.0
pdm.termui:   wheel>=0.36.2
pdm.termui:   setuptools
pdm.termui:   python==3.11.9
pdm.termui:   Adding requirement setuptools-rust>=1.4.0
pdm.termui:   Adding requirement wheel>=0.36.2
pdm.termui:   Adding requirement setuptools
pdm.termui:   Adding requirement python==3.11.9
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui:   Adding requirement setuptools>=62.4(from setuptools-rust 1.10.1)
pdm.termui:   Adding requirement semantic-version<3,>=2.8.2(from setuptools-rust 1.10.1)
pdm.termui: Pinning: setuptools-rust 1.10.1
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: Pinning: setuptools 74.1.2
pdm.termui: ======== Ending round 2 ========
pdm.termui: ======== Starting round 3 ========
pdm.termui: Pinning: wheel 0.44.0
pdm.termui: ======== Ending round 3 ========
pdm.termui: ======== Starting round 4 ========
pdm.termui: Pinning: semantic-version 2.10.0
pdm.termui: ======== Ending round 4 ========
pdm.termui: ======== Starting round 5 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:             python None
pdm.termui:    setuptools-rust 1.10.1
pdm.termui:         setuptools 74.1.2
pdm.termui:              wheel 0.44.0
pdm.termui:   semantic-version 2.10.0
pdm.termui: Installing semantic-version@2.10.0...
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/6a/23/8146aad7d88f4fcb3a6218f41a60f6c2d4e3a72de72da1825dc

7c8f7877c/semantic_version-2.10.0-py2.py3-none-any.whl
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/6a/23/8146aad7d88f4fcb3a6218f41a60f6c2d4e3a72de72da1825dc7c

8f7877c/semantic_version-2.10.0-py2.py3-none-any.whl (from https://pypi.org/simple/semantic-version/)> (15 kB)
pdm.termui: Installing setuptools@74.1.2...
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/cb/9c/9ad11ac06b97e55ada655f8a6bea9d1d3f06e120b178cd578d8

0e558191d/setuptools-74.1.2-py3-none-any.whl
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/cb/9c/9ad11ac06b97e55ada655f8a6bea9d1d3f06e120b178cd578d80e

558191d/setuptools-74.1.2-py3-none-any.whl (from https://pypi.org/simple/setuptools/)> (1.3 MB)
pdm.termui: Installing setuptools-rust@1.10.1...
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/43/3c/434984fca14c73e16a763f59424f06051758a01bb4d19e3f647

0693790be/setuptools_rust-1.10.1-py3-none-any.whl
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/43/3c/434984fca14c73e16a763f59424f06051758a01bb4d19e3f64706

93790be/setuptools_rust-1.10.1-py3-none-any.whl (from https://pypi.org/simple/setuptools-rust/)> (26 kB)
pdm.termui: Installing wheel@0.44.0...
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/1b/d1/9babe2ccaecff775992753d8686970b1e2755d21c8a63be73ab

a7a4e7d77/wheel-0.44.0-py3-none-any.whl
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/1b/d1/9babe2ccaecff775992753d8686970b1e2755d21c8a63be73aba7

a4e7d77/wheel-0.44.0-py3-none-any.whl (from https://pypi.org/simple/wheel/)> (67 kB)
pdm.termui: Synchronization complete.
pdm.termui: running egg_info
pdm.termui: creating maturin.egg-info
pdm.termui: writing maturin.egg-info/PKG-INFO
pdm.termui: writing dependency_links to maturin.egg-info/dependency_links.txt
pdm.termui: writing requirements to maturin.egg-info/requires.txt
pdm.termui: writing top-level names to maturin.egg-info/top_level.txt
pdm.termui: writing manifest file 'maturin.egg-info/SOURCES.txt'
pdm.termui: reading manifest file 'maturin.egg-info/SOURCES.txt'
pdm.termui: reading manifest template 'MANIFEST.in'
pdm.termui: warning: no files found matching '*.json' under directory 'src/python_interpreter'
pdm.termui: adding license file 'license-apache'
pdm.termui: adding license file 'license-mit'
pdm.termui: writing manifest file 'maturin.egg-info/SOURCES.txt'
pdm.termui: running bdist_wheel
pdm.termui: running build
pdm.termui: running build_py
pdm.termui: creating build
pdm.termui: creating build/lib.mingw_x86_64-cpython-311
pdm.termui: creating build/lib.mingw_x86_64-cpython-311/maturin
pdm.termui: copying maturin/__init__.py -> build/lib.mingw_x86_64-cpython-311/maturin
pdm.termui: copying maturin/__main__.py -> build/lib.mingw_x86_64-cpython-311/maturin
pdm.termui: running egg_info
pdm.termui: writing maturin.egg-info/PKG-INFO
pdm.termui: writing dependency_links to maturin.egg-info/dependency_links.txt
pdm.termui: writing requirements to maturin.egg-info/requires.txt
pdm.termui: writing top-level names to maturin.egg-info/top_level.txt
pdm.termui: reading manifest file 'maturin.egg-info/SOURCES.txt'
pdm.termui: reading manifest template 'MANIFEST.in'
pdm.termui: warning: no files found matching '*.json' under directory 'src/python_interpreter'
pdm.termui: adding license file 'license-apache'
pdm.termui: adding license file 'license-mit'
pdm.termui: writing manifest file 'maturin.egg-info/SOURCES.txt'
pdm.termui: running build_ext
pdm.termui: running build_rust
pdm.termui: cargo build --manifest-path Cargo.toml --message-format=json-render-diagnostics --release -v --no-default-features --lockedpdm.termui:    Compiling proc-macro2 v1.0.85
pdm.termui:    Compiling unicode-ident v1.0.12
pdm.termui:    Compiling cfg-if v1.0.0
pdm.termui:    Compiling windows_x86_64_gnu v0.52.5
pdm.termui:    Compiling serde v1.0.204
pdm.termui:    Compiling version_check v0.9.4
pdm.termui:    Compiling once_cell v1.19.0
pdm.termui:    Compiling cc v1.1.6
...
pdm.termui:     Finished `release` profile [optimized] target(s) in 3m 05s
pdm.termui: Copying rust artifact from C:\msys64\tmp\pdm-build-fzhydql3\target\release\maturin.exe to build/scripts-3.11/maturin.exe
pdm.termui: installing to build/bdist.mingw_x86_64/wheel
pdm.termui: running install
pdm.termui: running install_lib
pdm.termui: copying maturin/__init__.py -> build/bdist.mingw_x86_64/wheel/./maturin
pdm.termui: copying maturin/__main__.py -> build/bdist.mingw_x86_64/wheel/./maturin
pdm.termui: running install_egg_info
pdm.termui: Copying maturin.egg-info to build/bdist.mingw_x86_64/wheel/./maturin-1.7.1-py3.11.egg-info
pdm.termui: running install_scripts
pdm.termui: Installing maturin.exe script to build/bdist.mingw_x86_64/wheel/maturin-1.7.1.data/scripts
pdm.termui: creating build/bdist.mingw_x86_64/wheel/maturin-1.7.1.dist-info/WHEEL
pdm.termui: creating 'C:/Users/William/AppData/Local/pdm/pdm/Cache/wheels/cb/b5/48/310d3830278cba5217f1c1be1beb39a6f8c74c00aa1341e45e/.

tmp-qx5sac7z/maturin-1.7.1-cp311-cp311-mingw_x86_64.whl' and adding 'build/bdist.mingw_x86_64/wheel' to it
pdm.termui: adding 'maturin/__init__.py'
pdm.termui: adding 'maturin/__main__.py'
pdm.termui: adding 'maturin-1.7.1.data/scripts/maturin.exe'
pdm.termui: adding 'maturin-1.7.1.dist-info/METADATA'
pdm.termui: adding 'maturin-1.7.1.dist-info/WHEEL'
pdm.termui: adding 'maturin-1.7.1.dist-info/license-apache'
pdm.termui: adding 'maturin-1.7.1.dist-info/license-mit'
pdm.termui: adding 'maturin-1.7.1.dist-info/top_level.txt'
pdm.termui: adding 'maturin-1.7.1.dist-info/RECORD'
pdm.termui: removing build/bdist.mingw_x86_64/wheel
pdm.termui: Synchronization complete.
pdm.termui: Running `maturin pep517 build-wheel -i C:/msys64/home/William/Projects/MCVE/pdm-install/.venv/bin/python.exe --compatibility off`
pdm.termui: � Building a mixed python/rust project
pdm.termui: � Found bin bindings
pdm.termui: � Using build options bindings from pyproject.toml
pdm.termui:    Compiling unicode-ident v1.0.12
pdm.termui:    Compiling proc-macro2 v1.0.86
pdm.termui:    Compiling windows_x86_64_gnu v0.52.6
pdm.termui:    Compiling serde v1.0.209
pdm.termui:    Compiling memchr v2.7.4
pdm.termui:    Compiling cfg-if v1.0.0
pdm.termui:    Compiling once_cell v1.19.0
pdm.termui:    Compiling log v0.4.22
...
pdm.termui:     Finished `release` profile [optimized] target(s) in 17m 05s
pdm.termui: � Including files matching "rust-toolchain.toml"
pdm.termui: � Built wheel to C:\msys64\tmp\pdm-build-ze6lf0l7\target\wheels\ruff-0.6.4-py3-none-win_amd64.whl
pdm.termui: C:\msys64\tmp\pdm-build-ze6lf0l7\target\wheels\ruff-0.6.4-py3-none-win_amd64.whl
  ✔ Install ruff 0.6.4 successful

� All complete!
INFO: PDM 2.16.2.dev7+g7d395693 is installed, while 2.18.2 is available.
Please run `C:/msys64/mingw64/bin/python.exe -m pdm self update` to upgrade.
Run `pdm config check_update false` to disable the check.

With a recent pip, compiling from source is also what happens:

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pip install ruff
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'
Collecting ruff
  Using cached ruff-0.6.4.tar.gz (2.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ruff
  Building wheel for ruff (pyproject.toml) ... done
  Created wheel for ruff: filename=ruff-0.6.4-py3-none-win_amd64.whl size=12536787 sha256=4996175a422bb8f67e93f6fe2b5ba8660f4935e0e685a

6115da7fd0d89faaf7e
  Stored in directory: c:/users/william/appdata/local/pip/cache/wheels/a5/eb/81/7245391b564f153f9e7f75c9a9cc09e5da7ae893004d762542
Successfully built ruff
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'
Installing collected packages: ruff
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'
Successfully installed ruff-0.6.4
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:/msys64/mingw64/lib/python3.11/site-packages/findpython-0.6.0.dist-info due to invalid metadata entry 'name'

Environment Information

I tested against c190e14, but can confirm that the issue still exists in the current HEAD.

# Paste the output of `pdm info && pdm info --env` below:

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm info && pdm info --env
PDM version:
  2.18.3.dev2+g0ed53b64
Python Interpreter:
  C:/msys64/home/William/Projects/MCVE/pdm-install/.venv/bin/python.exe (3.11)
Project Root:
  C:/msys64/home/William/Projects/MCVE/pdm-install
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.11.9",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.11.9",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@cr1901 cr1901 added the 🐛 bug Something isn't working label Sep 13, 2024
@frostming
Copy link
Collaborator

Created wheel for ruff: filename=ruff-0.6.4-py3-none-win_amd64.whl size=12536787

Interesting, the built wheel is also named ruff-0.6.4-py3-none-win_amd64.whl, so how can it tell it's not abi compatible from just looking at the wheel name?

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 13, 2024

I think the MSYS2 pip logic might be as simple as "if the name contains none-any, the package advertises itself as pure-Python; install from wheel. Otherwise, download and compile from source". But I didn't actually check pip's source code for certain yet; this is based on my own experience using it for several years.

@frostming
Copy link
Collaborator

That's tricky since I don't have a msys2 environment for testing, can you paste the output of python3 -m pip debug --verbose?

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 14, 2024

William@DESKTOP-3H1DSBV MINGW64 ~
$ python3 -m pip debug --verbose
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 24.1.2 from C:/msys64/mingw64/lib/python3.11/site-packages/pip (python 3.11)
sys.version: 3.11.9 (main, Apr 12 2024, 09:55:31)  [GCC 13.2.0 64 bit (AMD64)]
sys.executable: C:/msys64/mingw64/bin/python3.exe
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: cp1252
sys.platform: win32
sys.implementation:
  name: cpython
'cert' config value: Not specified
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): C:/msys64/mingw64/lib/python3.11/site-packages/pip/_vendor/certifi/cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
  CacheControl==0.14.0
  distlib==0.3.8
  distro==1.9.0
  msgpack==1.0.8
  packaging==24.1
  platformdirs==4.2.1
  pyproject-hooks==1.0.0
  requests==2.32.3
  certifi==2024.02.02
  idna==3.7
  urllib3==1.26.18
  rich==13.7.1 (Unable to locate actual module version, using vendor.txt specified version)
  pygments==2.17.2
  typing_extensions==4.11.0 (Unable to locate actual module version, using vendor.txt specified version)
  resolvelib==1.0.1
  setuptools==69.5.1 (Unable to locate actual module version, using vendor.txt specified version)
  tenacity==8.2.3 (Unable to locate actual module version, using vendor.txt specified version)
  tomli==2.0.1
  truststore==0.9.1
Compatible tags: 39
  cp311-cp311-mingw_x86_64
  cp311-abi3-mingw_x86_64
  cp311-none-mingw_x86_64
  cp310-abi3-mingw_x86_64
  cp39-abi3-mingw_x86_64
  cp38-abi3-mingw_x86_64
  cp37-abi3-mingw_x86_64
  cp36-abi3-mingw_x86_64
  cp35-abi3-mingw_x86_64
  cp34-abi3-mingw_x86_64
  cp33-abi3-mingw_x86_64
  cp32-abi3-mingw_x86_64
  py311-none-mingw_x86_64
  py3-none-mingw_x86_64
  py310-none-mingw_x86_64
  py39-none-mingw_x86_64
  py38-none-mingw_x86_64
  py37-none-mingw_x86_64
  py36-none-mingw_x86_64
  py35-none-mingw_x86_64
  py34-none-mingw_x86_64
  py33-none-mingw_x86_64
  py32-none-mingw_x86_64
  py31-none-mingw_x86_64
  py30-none-mingw_x86_64
  cp311-none-any
  py311-none-any
  py3-none-any
  py310-none-any
  py39-none-any
  py38-none-any
  py37-none-any
  py36-none-any
  py35-none-any
  py34-none-any
  py33-none-any
  py32-none-any
  py31-none-any
  py30-none-any

Do you still have the feat/lock-targets branch anywhere locally? I can further bisect with that if necessary.

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 14, 2024

Just to make things more interesting, maturin, a dep required by ruff, got the correct tag when I built both yesterday as part of opening this issue. But ruff does not:

William@DESKTOP-3H1DSBV MINGW64 ~
$ find /c/Users/William/AppData/Local/pip/cache/wheels/ -name *.whl -newermt 1d -type f
/c/Users/William/AppData/Local/pip/cache/wheels/47/51/71/7dd73f65f6c4a49297cc779fb153b89ca3a4f99c9afe3a8285/maturin-1.7.1-cp311-cp311-mingw_x86_64.whl
/c/Users/William/AppData/Local/pip/cache/wheels/a5/eb/81/7245391b564f153f9e7f75c9a9cc09e5da7ae893004d762542/ruff-0.6.4-py3-none-win_amd64.whl

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 23, 2024

I have installed pdm version 2.19.0, and am still experiencing the same problem- ruff and maturin are is installed immediately rather than compiling from source.

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ rm -rf *

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm init -v
Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
 0. cpython@3.11 (C:/msys64/mingw64/bin/python.EXE)
 1. cpython@3.12 (C:/msys64/usr/bin/python3.12.exe)
 2. cpython@3.12 (C:/msys64/usr/bin/python3.exe)
 3. cpython@3.12 (C:/msys64/usr/bin/python.exe)
 4. cpython@3.11 (C:/msys64/mingw64/bin/python3.11.exe)
 5. cpython@3.11 (C:/msys64/mingw64/bin/python3.exe)
 6. cpython@3.11 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.11.8/python.exe)
 7. pypy@3.10 (C:/Users/William/AppData/Local/pdm/pdm/python/pypy@3.10.14/python.exe)
 8. cpython@3.8 (C:/Users/William/AppData/Local/pdm/pdm/python/cpython@3.8.18/python.exe)
Please select (0):
Run command: ['C:/msys64/mingw64/bin/python.exe', '-m', 'virtualenv', 'C:/msys64/home/William/Projects/MCVE/pdm-install/.venv', '-p',
'C:/msys64/mingw64/bin/python.EXE', '--prompt=pdm-install-3.11', '--no-pip', '--no-setuptools', '--no-wheel']
created virtual environment CPython3.11.10.final.0-64 in 193ms
  creator CPython3Windows(dest=C:/msys64/home/William/Projects/MCVE/pdm-install/.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at C:/msys64/home/William/Projects/MCVE/pdm-install/.venv
Project name (pdm-install):
Project version (0.1.0):
Do you want to build this project for distribution(such as wheel)?
If yes, it will be installed by default when running `pdm install`. [y/n] (n):
License(SPDX name) (MIT):
Author name (William D. Jones):
Author email (thor0505@comcast.net):
Python requires('*' to allow any) (==3.11.*):
Project is initialized successfully

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm add -v ruff
Adding packages to default dependencies: ruff
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   ruff
pdm.termui:   Adding requirement python==3.11.*
pdm.termui:   Adding requirement ruff
pdm.termui: ======== Starting round 0 ========
pdm.termui: Adding new pin: python None
pdm.termui: ======== Starting round 1 ========
pdm.termui: Adding new pin: ruff 0.6.7
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui:   python None
pdm.termui:     ruff 0.6.7
pdm.termui: Fetching hashes for ruff@0.6.7
Changes are written to pyproject.toml.
STATUS: Resolving packages from lockfile...
Synchronizing working set with resolved packages: 1 to add, 0 to update, 0 to remove

pdm.termui: Using cached response for https://files.pythonhosted.org/packages/97/80/193d1604a3f7d75eb1b2a7ce6bf0fdbdbc136889a65caacea6f

fb29501b1/ruff-0.6.7-py3-none-win_amd64.whl
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/97/80/193d1604a3f7d75eb1b2a7ce6bf0fdbdbc136889a65caacea6ffb

29501b1/ruff-0.6.7-py3-none-win_amd64.whl (from https://pypi.org/simple/ruff/)> (9.3 MB)
  ✔ Install ruff 0.6.7 successful
  � All complete!

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$

EDIT: Ignore the maturin part.

@frostming
Copy link
Collaborator

Upgrade dep-logic to 0.4.8 to fix this

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 23, 2024

Assuming this is the intended behavior, fair enough :P. If not, I'll debug and open an issue when I get the chance.

I've run into a different behavior. So that's progress :D!

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ pdm add -v ruff
Adding packages to default dependencies: ruff
Traceback (most recent call last):
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/models/in_process/env_spec.py", line 24, in <module>
    print(json.dumps(get_current_env_spec(sys.argv[1]), indent=2))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/models/in_process/env_spec.py", line 17, in get_current_env_spec
    "platform": str(Platform.current()),
                    ^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/dep_logic/tags/platform.py", line 113, in current
    raise PlatformError(f"Unsupported platform {platform_}")
dep_logic.tags.platform.PlatformError: Unsupported platform mingw_x86_64
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:/msys64/mingw64/bin/pdm.exe/__main__.py", line 7, in <module>
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/core.py", line 378, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/core.py", line 267, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/core.py", line 262, in main
    self.handle(project, options)
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/core.py", line 194, in handle
    command.handle(project, options)
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/cli/commands/add.py", line 71, in handle
    self.do_add(
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/cli/commands/add.py", line 159, in do_add
    resolved = do_lock(
               ^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/cli/actions.py", line 64, in do_lock
    locked_repo = project.get_locked_repository()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/project/core.py", line 444, in get_locked_repository
    return LockedRepository(lockfile, self.sources, self.environment, env_spec=env_spec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/models/repositories/lock.py", line 40, in __init__
    super().__init__(sources, environment, env_spec=env_spec or environment.spec)
                                                                ^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/environments/base.py", line 186, in spec
    return get_env_spec(self.interpreter.executable.as_posix())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/site-packages/pdm/models/in_process/__init__.py", line 53, in get_env_spec
    return EnvSpec.from_spec(**json.loads(subprocess.check_output([executable, "-EsS", script, shared_lib])))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/mingw64/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:/msys64/home/William/Projects/MCVE/pdm-install/.venv/bin/python.exe', '-EsS', 'C:/msys64/mi

ngw64/lib/python3.11/site-packages/pdm/models/in_process/env_spec.py', 'C:/msys64/mingw64/lib/python3.11/site-packages']' returned non-

zero exit status 1.

@frostming
Copy link
Collaborator

Assuming this is the intended behavior

it's not, what is the output of sysconfig.get_platform() on msys2?

There are only two places that raise such error in dep-logic, but you didn't provide the full traceback, which is always a good habbit. I can't find why.

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 23, 2024

but you didn't provide the full traceback, which is always a good habbit.

Apologies, you are of course correct. I have updated the traceback.

what is the output of sysconfig.get_platform() on msys2?

William@DESKTOP-3H1DSBV MINGW64 ~/Projects/MCVE/pdm-install
$ python
Python 3.11.10 (main, Sep 10 2024, 13:02:13)  [GCC 14.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_platform()
'mingw_x86_64'
>>>

@frostming
Copy link
Collaborator

'mingw_x86_64'

That's somehome surprising, sorry I don't work on msys2 and didn't test the parser on this platfrom.

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 23, 2024

Starting from line 109 in dep-logic/tags/platform.py, I rewrote the code as the following:

        if len(platform_info) == 1:
            if platform_info[0] in "win32":
                return cls(os.Windows(), Arch.X86)
            elif platform_info[0] in "mingw_x86_64":
                return cls(os.Generic("mingw"), Arch.parse("x86_64"))
            else:
                raise PlatformError(f"Unsupported platform {platform_}")

This got the expected behavior of compiling from source :D. Feel free to steal/modify/ignore.

Why Not Just Use pdm python/pdm use?

I could, and that works for the Python app where I originally noticed the new behavior. But a lot of the software installed on my system is GNU ABI-based and I want to keep my options open :).

@frostming
Copy link
Collaborator

Upgrade dep-logic to 0.4.9 to fix this:

pdm-project/dep-logic@9ce357b

@cr1901
Copy link
Contributor Author

cr1901 commented Sep 23, 2024

Beautiful, this fixed everything! Thank you for the quick response and fix, sorry for not providing a traceback the first time :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants