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] An empty directory with an empty pyproject.toml file is a valid setuptools project #3765

Closed
pradyunsg opened this issue Jan 11, 2023 · 5 comments
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@pradyunsg
Copy link
Member

pradyunsg commented Jan 11, 2023

setuptools version

setuptools==65.7.0

Python version

N/A

OS

N/A

Additional environment information

No response

Description

Setuptools does not refuse to build a project if it is missing a name or a version.

Expected behavior

Setuptools should fail because this project did not declare a name and a version for this package.

How to Reproduce

❯ mkdir /tmp/foo
❯ touch /tmp/foo.pyproject.toml
❯ pip wheel -vv /tmp/foo
Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-ephem-wheel-cache-sig2t8yx
Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe
Initialized build tracking at /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe
Created build tracker: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe
Entered build tracker: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe
Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-wheel-zisoqdm8
Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-ephem-wheel-cache-zo6vfgeo
Processing /private/tmp/foo
  Added file:///private/tmp/foo to build tracker '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe'
  Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-env-zynnm9x1
  Running command pip subprocess to install build dependencies
  Using pip 23.0.dev0 from /Users/pradyunsg/Developer/github/pip/src/pip (python 3.10)
  Collecting setuptools>=40.8.0
    Using cached setuptools-65.7.0-py3-none-any.whl (1.2 MB)
  Collecting wheel
    Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
  Installing collected packages: wheel, setuptools
    Creating /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-env-zynnm9x1/overlay/bin
    changing mode of /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-env-zynnm9x1/overlay/bin/wheel to 755
  Successfully installed setuptools-65.7.0 wheel-0.38.4
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  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'
  Getting requirements to build wheel ... done
  Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  creating /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info
  writing /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/PKG-INFO
  writing dependency_links to /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/dependency_links.txt
  writing top-level names to /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/top_level.txt
  writing manifest file '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/SOURCES.txt'
  reading manifest file '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/SOURCES.txt'
  writing manifest file '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN.egg-info/SOURCES.txt'
  creating '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-modern-metadata-eok1kcfe/UNKNOWN-0.0.0.dist-info'
  Preparing metadata (pyproject.toml) ... done
  Source in /private/tmp/foo has version 0.0.0, which satisfies requirement UNKNOWN==0.0.0 from file:///private/tmp/foo
  Removed UNKNOWN==0.0.0 from file:///private/tmp/foo from build tracker '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe'
Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-unpack-9usa7vao
Building wheels for collected packages: UNKNOWN
  Created temporary directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-wheel-nwaq45u8
  Destination directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-wheel-nwaq45u8
  Running command Building wheel for UNKNOWN (pyproject.toml)
  running bdist_wheel
  running build
  installing to build/bdist.macosx-11.6-arm64/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.6-arm64/wheel/UNKNOWN-0.0.0-py3.10.egg-info
  running install_scripts
  creating build/bdist.macosx-11.6-arm64/wheel/UNKNOWN-0.0.0.dist-info/WHEEL
  creating '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-wheel-nwaq45u8/.tmp-9pg6213d/UNKNOWN-0.0.0-py3-none-any.whl' and adding 'build/bdist.macosx-11.6-arm64/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.6-arm64/wheel
  Building wheel for UNKNOWN (pyproject.toml) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=922 sha256=99881449cf5f483d5c9bce481b854d4546b01c43c42176a8faf2138d5ce79434
  Stored in directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-ephem-wheel-cache-zo6vfgeo/wheels/54/10/69/9afa0ccc2ebddbac532467b09e8cbf723c5a663ffda67f9d55
Successfully built UNKNOWN
Remote version of pip: 22.3.1
Local version of pip:  23.0.dev0
Was pip installed by pip? True
Removed build tracker: '/private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-build-tracker-lfadyaxe'
❯ ls /tmp/foo
UNKNOWN-0.0.0-py3-none-any.whl UNKNOWN.egg-info               build                          pyproject.toml

Output

See above.

@pradyunsg pradyunsg added bug Needs Triage Issues that need to be evaluated for severity and status. labels Jan 11, 2023
@pradyunsg
Copy link
Member Author

x-ref #2329

That was closed with the rationale that (a) this is useful for testing and (b) that higher level tools protect against this.

I really don't think (a) is a strong argument -- getting a clear error message and manually adding 1 line is much better than having users be confused because a build proceeded despite not having any metadata. Notably, this prevents using pyproject.toml as a marker file for a Python project that isn't supposed to be packaged; since pip install . will work on it.

And, as demonstrated (b) is not true.

@pradyunsg
Copy link
Member Author

pradyunsg commented Jan 11, 2023

This behaviour has been a consistent source of user-confusion. In ~60 seconds and a couple of searches, I can find:

Please reconsider this behaviour of setuptools and fail explicitly when given "degenerate" build configuration instead of proceeding to do a degenerate build.

@abravalheri
Copy link
Contributor

abravalheri commented Jan 12, 2023

This behaviour has been a consistent source of user-confusion. In ~60 seconds and a couple of searches, I can find:

Hi @pradyunsg, I would like to clarify that in the listed issues the source of user-confusion is not related to the behaviour being discussed here.

There might be other issues in that the assumption is correct, but specifically in the links listed above the packages are indeed providing enough metadata for the build.

The origin of the problems is different: either there was no version of setuptools available at that point in time capable of parsing pyproject.toml/setup.cfg or somehow a wrong old version of setuptools got used.

Implementing the changes proposed would not change the user-confusion if an older version of setuptools gets accidentally used during the build. There would still be a UNKNOWN-0.0.0-py3-none-any.whl being generated.

If we do a mental exercise for the given examples and imagine a scenario where setuptools had failed explicitly instead of proceeding with a degenerate build, users would still be confused, because they were indeed declaring user and version so the explicit exception would make no sense...

Of course, there might be other (better) examples. We just have to be careful to not accidentally step into a XY-problem-style reasoning to justify the need for change in the setuptools behaviour.

@abravalheri
Copy link
Contributor

abravalheri commented Jan 12, 2023

@pradyunsg, would you like to keep this issue to centralise the discussion or #3511?

@pradyunsg
Copy link
Member Author

Bah, #3511 is good enough. Sorry for the duplicate!

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