setuptools: [BUG] 61.0.0 breaks "setup.py install" by missing dependencies in install_requires
setuptools version
61.0.0
Python version
3.10
OS
ubuntu-latest in GitHub Actions
Additional environment information
No response
Description
In our pywbem package, we test the different documented methods to install the package. One of them is still “setup.py install”. I do understand that it is deprecated since setuptools v58.3.0, but that still means it should be expected to work.
The issue is that the “setup.py install” command successfully installs the pywbem package, but upon import it turns out that dependent packages were not installed, e.g. “six”.
The GitHub Actions test run showing that is: https://github.com/pywbem/pywbem/runs/5687824533?check_suite_focus=true
“pip install” on the package works with setuptools 61.0.0 and does install the dependent packages.
The requirements.txt file of the pywbem project does specify the dependent packages and the setup.py script loads the dependencies from requirements.txt and specifies them in the “install_requires” parameter of setup().
The “setup.py install” approach worked before setuptools 61.0.0, e.g. with 60.10.0, see this test run.
Expected behavior
61.0.0 should still support “setup.py install” as before.
How to Reproduce
- Create a new virtual env on Python 3.10
pip install setuptools==61.0.0; pip uninstall six
git clone https://github.com/pywbem/pywbem.git; cd pywbem
./setup.py install
# should succeedpip list
# should display:
and the issue is that the dependent packages are not installed.Package Version ---------- ---------- pip 22.0.4 pywbem 1.5.0.dev1 setuptools 61.0.0 wheel 0.37.1
pip install .
# should succeedpip list
# should display the correctly installed dependencies:Package Version ------------------ ---------- certifi 2021.10.8 charset-normalizer 2.0.12 idna 3.3 nocasedict 1.0.2 nocaselist 1.0.4 pip 22.0.4 ply 3.11 pywbem 1.5.0.dev1 PyYAML 6.0 requests 2.27.1 setuptools 61.0.0 six 1.16.0 urllib3 1.26.9 wheel 0.37.1 yamlloader 1.1.0
Output
See above
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 31 (28 by maintainers)
Commits related to this issue
- 61.0.0 setuptools does not install the dependencies - So we stay at 60.10.0 - See https://github.com/pypa/setuptools/issues/3198 — committed to populse/populse_mia by servoz 2 years ago
- 61.0.0 setuptools does not install the dependencies - So we stay at 60.10.0 - See https://github.com/pypa/setuptools/issues/3198 — committed to populse/populse_mia by servoz 2 years ago
Hi @AndydeCleyre, I noticed that the fixtures seem to be creating distributions with no python modules.
When I compare
METADATA_TEST_CASES
forsetup.cfg
andsetup.py
I can see thatsetup.cfg
haspackages = find:
, butsetup.py
lacks the equivalentpackages=find_packages()
. Is that on purpose?Note that, prior to setuptools v61, these different configurations are not equivalent:
a) The example with
setup.cfg
would includesample_lib/__init__.py
in the distribution b) The example withsetup.py
would be empty.For the majority of use cases, the situation in
(b)
is accidental and unintended (maybe the same accident happened in your test case?).With the improvements in v61, setuptools will try to auto-detect which files to include, but it will fail if the root directory has a confusing/equivocal layout.
The example generated by the fixtures seems to have extra folders
dists
andpackages
.setuptools>=61
does not know exactly how to deal with these folders and therefore, halts the build process asking for the user to improve the configuration or use asrc-layout
.This is the breaking change motivating the major bump from v60 to v61 and is described in the CHANGELOG.
The layouts recognized by setuptools for auto-discovery are described in https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#automatic-discovery.
Layouts that differ from the ones documented are asked to explicitly list
packages
and/orpy_modules
in their configuration.These include “intentionally empty” packages and “meta-packages”[^1]. For those scenarios the users are asked to set
packages=[]
.[^1]: That only exists to specify dependencies.
Uummm… It is a possibility but I don’t think setuptools is that smart 😅
These are all different ways of “building” the package and how the metadata looks like:
It seems that
Requires-Dist
in the metadata always contain the directory.@abravalheri I have narrowed my test example down to a single factor, In
requirementslib/models/setup_info.py
if I modify the methodbuild_pep517
to do this extra hack at the beginning (the hack has knowledge of the package sub-directories`:When I have that extra logic disabled, and some extra print statements, I can see that this gets built:
parent_folder.sibling_package.src.sibling_package-0.0.0-py3-none-any.whl
However, with my hack logic in place, the output instead is:
pep508_package-1.0.0-py3-none-any.whl
This makes all the difference in the world to get the expected result of:
However, I am still head scratching about what could have changed to cause it to no longer automatically get the subdirectory on the path in this step, or why it would have changed behaviors ~4 days ago.
This is comment intrigued me a little, because it might be related to another change in v61.*.
If you are trying to install
parent-folder
as if it was a package (note thatparent-folder
does not containsetup.py
orpyproject.toml
), previously setuptools would generate aUNKNOWN
package, but now with the new name discovery it will indeed createparent-folder.sibling-package.src.sibling-package
(the details of this mechanic were first proposed in https://github.com/pypa/setuptools/issues/2887#issuecomment-970708430)This happens because
parent_folder/sibling_package/src/sibling_package
is accidentally a valid namespaced package under the eyes of PEP 420. For example, if you are inside thetest-project
, you can fire up the REPL and successfully run:I have the impression that the name
parent-folder.sibling-package.src.sibling-package
is a valid under PEP 508.I will just add some notes here so when you have the time you can have a look.
That is completely possible. It might very well be that v61.0.0…v61.1.1 introduced something that is causing the problem. However this seems to be a second issue, and not the one originally reported here.
I don’t understand what you mean here. The test I did in my machine does not use
pip
at all. The original problem mentioned in this issue is related to invokingpython setup.py install
, so I tried to replicate it locally with the repository you linked.python setup.py install
does not usepip
(it useseasy_install
internally).If I instead run:
Then both packages seem to install fine.
If instead I run (replacing
install
withdevelop
:Then I see the same problem with v60.10.0
If you manage to find a minimal reproducer along the lines of the examples before that works for
setuptools==60.10.0
but does not work forsetuptools==61.1.1
that would help a lot to understand this problem.BTW, I am testing on:
Hi @matteius please do enjoy your leisure time, we can have a look at this later 😃