diff --git a/pythran/config.py b/pythran/config.py index d119a68c94..3652e966b3 100644 --- a/pythran/config.py +++ b/pythran/config.py @@ -19,29 +19,6 @@ def get_include(): return (os.path.dirname(os.path.dirname(__file__)) or '.') + '/pythran' -class silent(object): - ''' - Silent sys.stderr at the system level - ''' - - def __enter__(self): - try: - self.prevfd = os.dup(sys.stderr.fileno()) - os.close(sys.stderr.fileno()) - except io.UnsupportedOperation: - self.prevfd = None - - self.prevstream = sys.stderr - sys.stderr = open(os.devnull, 'r') - - def __exit__(self, exc_type, exc_value, traceback): - sys.stderr.close() - sys.stderr = self.prevstream - if self.prevfd: - os.dup2(self.prevfd, sys.stderr.fileno()) - os.close(self.prevfd) - - def get_paths_cfg( sys_file='pythran.cfg', platform_file='pythran-{}.cfg'.format(sys.platform), @@ -246,26 +223,9 @@ def parse_define(define): extension['define_macros'].append('PYTHRAN_BLAS_NONE') if user_blas not in reserved_blas_entries: - if sys.version_info < (3, 12): - # `numpy.distutils` not present for Python >= 3.12 - try: - import numpy.distutils.system_info as numpy_sys - # Numpy can pollute stdout with checks - with silent(): - numpy_blas = numpy_sys.get_info(user_blas) - # required to cope with atlas missing extern "C" - extension['define_macros'].append('PYTHRAN_BLAS_{}' - .format(user_blas.upper())) - extension['libraries'].extend(numpy_blas.get('libraries', [])) - extension['library_dirs'].extend( - numpy_blas.get('library_dirs', [])) - extension['include_dirs'].extend( - numpy_blas.get('include_dirs', [])) - except Exception as exc: - raise RuntimeError( - "The likely cause of this failure is an incompatibility " - "between `setuptools` and `numpy.distutils. " - ) from exc + # required to cope with atlas missing extern "C" + extension['define_macros'].append('PYTHRAN_BLAS_{}' + .format(user_blas.upper())) # final macro normalization extension["define_macros"] = [ diff --git a/pythran/dist.py b/pythran/dist.py index 0a3abffee9..211f16f08b 100644 --- a/pythran/dist.py +++ b/pythran/dist.py @@ -14,13 +14,7 @@ import os from distutils.command.build_ext import build_ext as LegacyBuildExt - -try: - # `numpy.distutils` is deprecated, and won't be present on Python >=3.12 - # If it is installed, we need to use it though, so try-import it: - from numpy.distutils.extension import Extension -except ImportError: - from distutils.extension import Extension +from distutils.extension import Extension diff --git a/pythran/tests/test_distutils.py b/pythran/tests/test_distutils.py index 2e194e94d8..82e3ba6824 100644 --- a/pythran/tests/test_distutils.py +++ b/pythran/tests/test_distutils.py @@ -1,4 +1,5 @@ from subprocess import check_call +import glob import os import re import shutil @@ -126,9 +127,11 @@ def test_setup_build3(self): libdir = os.path.join(base, 'lib') if not os.path.isdir(libdir): libdir = os.path.join(base, 'lib64') + demo3_site = glob.glob( + os.path.join(libdir, python_version, 'site-packages', 'demo3*') + )[0] check_call([python, '-c', 'import a'], - cwd=os.path.join(libdir, python_version, 'site-packages', - 'demo3')) + cwd=demo3_site) check_call([python, 'setup.py', 'clean'], cwd=os.path.join(cwd, 'test_distutils_numpy')) shutil.rmtree(os.path.join(cwd, 'test_distutils_numpy', 'demo_install3')) diff --git a/pythran/tests/test_distutils_numpy/setup.py b/pythran/tests/test_distutils_numpy/setup.py index 962afe5010..247ab5be4e 100644 --- a/pythran/tests/test_distutils_numpy/setup.py +++ b/pythran/tests/test_distutils_numpy/setup.py @@ -1,5 +1,6 @@ -from numpy.distutils.core import setup -from numpy.distutils.command.build_ext import build_ext as npy_build_ext +from distutils.core import setup +from distutils.command.build_ext import build_ext as npy_build_ext + from pythran.dist import PythranExtension, PythranBuildExt module1 = PythranExtension('demo3.a', sources = ['demo3/a.py']) diff --git a/pythran/toolchain.py b/pythran/toolchain.py index d5e73d58ca..e22beabc0c 100644 --- a/pythran/toolchain.py +++ b/pythran/toolchain.py @@ -24,11 +24,7 @@ from distutils.errors import CompileError from distutils import sysconfig -try: - # `numpy.distutils is deprecated, may not be present, or broken - from numpy.distutils.core import setup -except Exception: - from distutils.core import setup +from distutils.core import setup from tempfile import mkdtemp, NamedTemporaryFile import gast as ast