Repository navigation
Closed
Description
Describe the issue:
The latest release of setuptools breaks builds using numpy.distutils
Reproduce the code example:
https://github.com/lsst/sphgeom/
python -m buildError message:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 404, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in run_setup
exec(code, locals())
File "<string>", line 29, in <module>
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
self.run_command(cmd_name)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/pybind11/setup_helpers.py", line 288, in build_extensions
ext.cxx_std = auto_cpp_level(self.compiler)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/pybind11/setup_helpers.py", line 267, in auto_cpp_level
if has_flag(compiler, STD_TMPL.format(level)):
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/pybind11/setup_helpers.py", line 245, in has_flag
compiler.compile([str(fname)], extra_postargs=[flag])
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/ccompiler.py", line 89, in <lambda>
m = lambda self, *args, **kw: func(self, *args, **kw)
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/ccompiler.py", line 272, in CCompiler_compile
jobs = get_num_build_jobs()
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 91, in get_num_build_jobs
from numpy.distutils.core import get_distribution
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/core.py", line 24, in <module>
from numpy.distutils.command import config, config_compiler, \
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/command/config.py", line 19, in <module>
from numpy.distutils.mingw32ccompiler import generate_manifest
File "/tmp/pip-build-env-niwad26p/overlay/lib/python3.10/site-packages/numpy/distutils/mingw32ccompiler.py", line 28, in <module>
from distutils.msvccompiler import get_build_version as get_build_msvc_version
ModuleNotFoundError: No module named 'distutils.msvccompiler'NumPy/Python version information:
numpy 1.23.0 3.10.5
setuptools 65.0.0
Context for the issue:
Related to
pypa/setuptools#3505
Reacted by Saransh Chopra, Augustin FL and Edvin Močibob
Activity
charris commentedon Aug 15, 2022
Yes. Don't do that :) There is a reason setuptools is pinned to 59.2.0 in
environment.yml,pyproject.toml, andtest_requirements.txt. We will stop using setup in the future.mwittgen commentedon Aug 15, 2022
So the recommended workaround for now is to pin setuptools when using numpy.distutils?
charris commentedon Aug 15, 2022
Yes. There were supposedly some back compatibility fixes in newer setuptools, but it is a moving target and cannot be relied on.
Saransh-cpp commentedon Aug 16, 2022
Upper-capping
setuptools<=64.0.0works too!Saransh-cpp commentedon Aug 17, 2022
FYI: This has been fixed in the new
setuptoolsrelease - pypa/setuptools@v65.0.1...main (reverts back the breaking change).charris commentedon Aug 17, 2022
IIRC, Python 3.12 will drop distutils. NumPy is looking to move to meson to solve that problem. Downstream projects are also advised to also look into alternative build systems if they currently need NumPy distutils. Things are going to be messy for a while.
rgommers commentedon Aug 19, 2022
Either way, our recommendation is to pin
setuptoolsto the last version that worked for you (59.xfor numpy itself, maybe64.0for others). This is always a good idea to do in your releases. You don't want to find out that things work at release time, and then break afterwards becausesetuptoolsor another build-time dependency did a major release.We already documented this at https://numpy.org/devdocs/user/depending_on_numpy.html#build-time-dependency, although we perhaps should make that a more prominent warning box. The relevant text there is: "For your other build dependencies you can probably be looser, however it’s still important to set lower and upper bounds for each dependency. It’s fine to specify either a range or a specific version for a dependency like
wheelorsetuptools. It’s recommended to set the upper bound of the range to the latest already released version ofwheelandsetuptools- this prevents future releases from breaking your packages on PyPI."I will open a PR to make the warning more prominent, and will advertise the recommendation here again on the mailing list.
EDIT: note that there's a second place we recommend this, in the deprecation warning for
numpy.distutils:numpy/numpy/distutils/__init__.py
Lines 31 to 39 in 831c04a
Temporarily Pin setuptools<=60.0 in Wheel Build
Temporarily Pin setuptools<=60.0 in Wheel Build (#173)
mattip commentedon Aug 21, 2022
The PR was merged. Was the recommendation advertised on the mailing list?
rgommers commentedon Aug 21, 2022
Just done: https://mail.python.org/archives/list/[email protected]/thread/CTOEM2J6UCJGZATZB5Z2RZUOD3RASEQS/
Use build-isolation to build wxPython