From f30858a9b15b5871f7a0cd92305f01e05cff0edd Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Tue, 1 Feb 2022 10:34:26 -0500 Subject: [PATCH] MAINT: be more tolerant of setuptools>=60 NumPy may fail to build with the default vendored distutils in setuptools>=60. Rather than panic and die when new setuptools is found, let's check (or set, if possible) the SETUPTOOLS_USE_DISTUTILS environment variable that restores "proper" setuptools behavior. --- setup.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 06170df51ac4..0257fc5ba755 100755 --- a/setup.py +++ b/setup.py @@ -81,9 +81,16 @@ import numpy.distutils.command.sdist import setuptools if int(setuptools.__version__.split('.')[0]) >= 60: - raise RuntimeError( - "Setuptools version is '{}', version < '60.0.0' is required. " - "See pyproject.toml".format(setuptools.__version__)) + # setuptools >= 60 switches to vendored distutils by default; this + # may break the numpy build, so make sure the stdlib version is used + try: + setuptools_use_distutils = os.environ['SETUPTOOLS_USE_DISTUTILS'] + except KeyError: + os.environ['SETUPTOOLS_USE_DISTUTILS'] = "stdlib" + else: + if setuptools_use_distutils != "stdlib": + raise RuntimeError("setuptools versions >= '60.0.0' require " + "SETUPTOOLS_USE_DISTUTILS=stdlib in the environment") # Initialize cmdclass from versioneer from numpy.distutils.core import numpy_cmdclass