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

[BUG] name/version from pyproject.toml is not respected on macOS #3291

Closed
slonopotamus opened this issue Apr 27, 2022 · 15 comments
Closed

[BUG] name/version from pyproject.toml is not respected on macOS #3291

slonopotamus opened this issue Apr 27, 2022 · 15 comments
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@slonopotamus
Copy link

slonopotamus commented Apr 27, 2022

setuptools version

60.10.0

Python version

3.9.12

OS

macOS 12.3.1 (Monterey)

Additional environment information

For your convenience, here's a test project that reproduces described behavior on GitHub Actions. You can see problematic build output here.

Note that exactly the same steps are done on Windows and Ubuntu and bug doesn't occur there.

For comparison, here's the list of package versions on different OSes:

macOS (broken):

Python 3.9.12

pip        22.0.4
setuptools 60.10.0
wheel      0.37.1

Windows (works):

Python 3.9.12

argcomplete 2.0.0
click       8.1.2
colorama    0.4.4
dummy       0.0.1
packaging   21.3
pip         22.0.4
pipx        1.0.0
pyparsing   3.0.8
setuptools  58.1.0
userpath    1.8.0

Ubuntu (works):

Python 3.8.10

argcomplete            2.0.0               
attrs                  19.3.0              
Automat                0.8.0               
blinker                1.4                 
certifi                2019.11.28          
chardet                3.0.4               
Click                  7.0                 
cloud-init             22.1                
colorama               0.4.3               
command-not-found      0.3                 
configobj              5.0.6               
constantly             15.1.0              
crcmod                 1.7                 
crit                   0.0.1               
cryptography           2.8                 
dbus-python            1.2.16              
distro                 1.4.0               
distro-info            0.23ubuntu1         
dummy                  0.0.1               
entrypoints            0.3                 
httplib2               0.14.0              
hyperlink              19.0.0              
idna                   2.8                 
importlib-metadata     1.5.0               
incremental            16.10.1             
Jinja2                 2.10.1              
jsonpatch              1.22                
jsonpointer            2.0                 
jsonschema             3.2.0               
keyring                18.0.1              
language-selector      0.1                 
launchpadlib           1.10.13             
lazr.restfulclient     0.14.2              
lazr.uri               1.0.3               
MarkupSafe             1.1.0               
more-itertools         4.2.0               
netifaces              0.10.4              
oauthlib               3.1.0               
packaging              21.3                
pexpect                4.6.0               
pip                    20.0.2              
pipx                   1.0.0               
protobuf               3.6.1               
pyasn1                 0.4.2               
pyasn1-modules         0.2.1               
Pygments               2.3.1               
PyGObject              3.36.0              
PyHamcrest             1.9.0               
PyJWT                  1.7.1               
pymacaroons            0.13.0              
PyNaCl                 1.3.0               
pyOpenSSL              19.0.0              
pyparsing              3.0.8               
pyparted               3.11.2              
pyrsistent             0.15.5              
pyserial               3.4                 
python-apt             2.0.0+ubuntu0.20.4.7
python-debian          0.1.36ubuntu1       
PyYAML                 5.3.1               
requests               2.22.0              
requests-unixsocket    0.2.0               
SecretStorage          2.3.1               
service-identity       18.1.0              
setuptools             45.2.0              
simplejson             3.16.0              
six                    1.14.0              
sos                    4.3                 
ssh-import-id          5.10                
systemd-python         234                 
Twisted                18.9.0              
ubuntu-advantage-tools 27.7                
ufw                    0.36                
urllib3                1.25.8              
userpath               1.8.0               
wadllib                1.3.3               
WALinuxAgent           2.2.46              
wheel                  0.34.2              
zipp                   1.0.0               
zope.interface         4.7.1    

Description

setuptools installs packages as UNKNOWN even though they have name/version specified in pypackage.toml

Expected behavior

name/version from pyproject.toml is respected

How to Reproduce

Create a directory with a trivial pyproject.toml:

[project]
name = "dummy"
version = "0.0.1"

And then install it with pip3 install --user .

Output

pyproject.toml:

[project]
name = "dummy"
version = "0.0.1"

pip3 output:

Processing /Users/runner/work/setuptools-vs-pyproject.toml/setuptools-vs-pyproject.toml
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml): started
  Building wheel for UNKNOWN (pyproject.toml): finished with status 'done'
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=955 sha256=a7b6a1a2dbdb6b58ac9dba154d08243bfa69d3f9531da4f25091503bd5fce88e
  Stored in directory: /Users/runner/Library/Caches/pip/wheels/0c/20/8e/7124b70b3908c7615c98401dce5a60eabf88726b43c04fe667
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Successfully installed UNKNOWN-0.0.0
@slonopotamus slonopotamus added bug Needs Triage Issues that need to be evaluated for severity and status. labels Apr 27, 2022
@abravalheri
Copy link
Contributor

Hi @slonopotamus , the support for the [project] table was added in version 61.

@slonopotamus
Copy link
Author

slonopotamus commented Apr 27, 2022

  1. How does it work on Linux/Windows then?

The configuration is missing [build-system] and at the same time it does not have a setup.py... In theory in this situation there is nothing telling pip what is the right thing to do, so that might be generating the confusion.

@abravalheri
Copy link
Contributor

Please could you repeat the experiment adding a [build-system] table specifing the latest version of setuptools? I suspect that will fix all the problems you might be facing.

@slonopotamus
Copy link
Author

slonopotamus commented Apr 27, 2022

I've forced setuptools-62.1 and explicitly specified build-backend: slonopotamus/setuptools-vs-pyproject.toml@9474f22

See updated run. Behavior is still the same (Windows/Linux works, macOS doesn't).

I also added --verbose so we can clearly see that pip uses updated setuptools:

Run pip3 install --user --verbose .
Using pip 22.0.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Processing /Users/runner/work/setuptools-vs-pyproject.toml/setuptools-vs-pyproject.toml
  Installing build dependencies: started
  Running command pip subprocess to install build dependencies
  Collecting setuptools>=62.1
    Using cached setuptools-62.1.0-py3-none-any.whl (1.1 MB) <-----------------------------------------------------------------------
  Collecting wheel
    Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
  Installing collected packages: wheel, setuptools
  Successfully installed setuptools-62.1.0 wheel-0.37.1
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Running command Getting requirements to build wheel
  running egg_info
  creating UNKNOWN.egg-info
  writing UNKNOWN.egg-info/PKG-INFO
  writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
  writing top-level names to UNKNOWN.egg-info/top_level.txt
  writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
  reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
  writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  creating /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info
  writing /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/PKG-INFO
  writing dependency_links to /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/dependency_links.txt
  writing top-level names to /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/top_level.txt
  writing manifest file '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/SOURCES.txt'
  reading manifest file '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/SOURCES.txt'
  writing manifest file '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.egg-info/SOURCES.txt'
  creating '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-modern-metadata-u02iamyb/UNKNOWN.dist-info'
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml): started
  Running command Building wheel for UNKNOWN (pyproject.toml)
  running bdist_wheel
  running build
  installing to build/bdist.macosx-11-x86_64/wheel
  running install
  running install_egg_info
  running egg_info
  writing UNKNOWN.egg-info/PKG-INFO
  writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
  writing top-level names to UNKNOWN.egg-info/top_level.txt
  reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
  writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
  Copying UNKNOWN.egg-info to build/bdist.macosx-11-x86_64/wheel/UNKNOWN-0.0.0-py3.9.egg-info
  running install_scripts
  creating build/bdist.macosx-11-x86_64/wheel/UNKNOWN-0.0.0.dist-info/WHEEL
  creating '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-wheel-b5qfl1g7/tmpkny_4ctf/UNKNOWN-0.0.0-py3-none-any.whl' and adding 'build/bdist.macosx-11-x86_64/wheel' to it
  adding 'UNKNOWN-0.0.0.dist-info/METADATA'
  adding 'UNKNOWN-0.0.0.dist-info/WHEEL'
  adding 'UNKNOWN-0.0.0.dist-info/top_level.txt'
  adding 'UNKNOWN-0.0.0.dist-info/RECORD'
  removing build/bdist.macosx-11-x86_64/wheel
  Building wheel for UNKNOWN (pyproject.toml): finished with status 'done'
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=955 sha256=d7dd4d77f2e85d16eb5542012749730f0f2cb0d5a3335a6aa1aecb6c6a059d23
  Stored in directory: /Users/runner/Library/Caches/pip/wheels/0c/20/8e/7124b70b3908c7615c98401dce5a60eabf88726b43c04fe667
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Successfully installed UNKNOWN-0.0.0

@abravalheri
Copy link
Contributor

Sorry @slonopotamus , I was trying to reply using the phone app and I ended up for some reason editing your comment instead of posting a new one...

@abravalheri
Copy link
Contributor

Can you do other 2 experiments please? (unfortunately I don't have access to a macOS machine to test it myself)

Can you update any/all global installation of setuptools also before installing the package?

Can you also try using python -m build and then install the resulting wheel with pip install dist/*.whl?

These experiments will serve to rule out the possibility the environment pip is using for the build is leaking...

@slonopotamus
Copy link
Author

slonopotamus commented Apr 27, 2022

Can you update any/all global installation of setuptools also before installing the package?

Everything started to work properly if I do pip3 install setuptools>=62" before installing my gem.
Diff: slonopotamus/setuptools-vs-pyproject.toml@e2a79c8
Build run: https://github.com/slonopotamus/setuptools-vs-pyproject.toml/runs/6195651518?check_suite_focus=true#step:4:53

@abravalheri
Copy link
Contributor

Ummm... it would seem that there is a leak on the environment pip is using for the build.

Any chance this is related to pypa/pip#11053 (comment)?

@slonopotamus
Copy link
Author

slonopotamus commented Apr 27, 2022

Could be... But.

The thing is that I observe the same behavior even without any Homebrew, but with vanilla Python 3.8.9 that comes bundled with macOS 12.3.1. Note that I cannot easily upgrade system setuptools, and actually would like to avoid doing that. I can pip3 install --user setuptools>62 instead, but that doesn't fix the issue.

image

(Sorry for this being a screenshot instead of text)

@slonopotamus
Copy link
Author

slonopotamus commented Apr 27, 2022

Workaround: sudo pip3 install "setuptools>=62" or (possibly better) sudo pip3 uninstall setuptools.

@abravalheri
Copy link
Contributor

If the workaround is indeed sudo pip3 uninstall setuptools, I think it is safe to assume that somehow the build environment is leaking...

If that is the case, there is not much setuptools can do here, as it assumes the correct version is ensured by the build frontend.

@slonopotamus
Copy link
Author

So, should I instead report this to pip?

@slonopotamus
Copy link
Author

And yes, sudo pip3 uninstall setuptools IS a workaround.

@slonopotamus
Copy link
Author

Very similar issue on Ubuntu 22.04: #3269

And they agreed it should be fixed on pip side: pypa/pip#6264

@slonopotamus
Copy link
Author

So, I think this can be closed, because the root of the issue is not in setuptools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

No branches or pull requests

2 participants