[BUG] Calling pip install .
to build/install setuptools multiple times in a row results in unwanted build/lib/...
files
#4394
Labels
setuptools version
70
Python version
3.12
OS
Tested on
python:3.12-bookworm
linux containerAdditional environment information
No response
Description
Running
pip install .
multiple times to install thesetuptools
project itself results in installingunwanted
build/lib/...
files intosite-packages
.Running
pip wheel .
multiple times (or after runningpip install .
) results in unwantedbuild/lib/...
files in the created wheel.I suspect that the root cause of this problem is that setuptools is configured to find packages using an
exclude
rule, but this exclude rule does not exclude thebuild
directory. It is also considered to find namespace packages.In the regular finder implementation there is no special provision to ignore those files (and to honest, my opinion is that there should not be one because packages can choose the name
build
..., beforebuild
migrated toflit
that was exactly the case).For the default, automatic discovery there is a provision in place to avoid that directory.
I expect this problem to be the same before v70 (I haven't tested though).
Expected behavior
When building/insalling the
setuptools
repository there should be notbuild/lib/...
in the site-packages directory or in the wheel. This should be "idempotent" (it does not matter how many times you build/install).How to Reproduce
Now if we use
pip wheel .
we can see that all these spurious directories are included in the wheel:Full output
This does not happen with
python -m build
, but I guessbuild
copies the directory to a temporary directory before running? (and that prevents thebuild
directory from being created in the CWD?)Other than
pip install .
orpip wheel .
, running the test suite withtox
itself also produces thebuild
directory, so if anyone tries to runtox
beforepip install .
, they also end-up with spurious files.Another related thought:
In the time that setuptools/distutils was created this was not a concern, because namespace packages were not a thing. So setuptools/distutils could use a
build
ordist
directories without a problem for build artifacts without having any concern for those to be accidentally counted as Python packages during the build. But since PEP 440 was introduced, that no longer holds.The text was updated successfully, but these errors were encountered: