diff --git a/build-requirements.txt b/build-requirements.txt index ea8de9d1ce02..52c518d53bc2 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1,6 +1,5 @@ # NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml -r mypy-requirements.txt types-psutil -# TODO: fix build when using the latest version of types-setuptools -types-setuptools<67.4.0.2 +types-setuptools types-typed-ast>=1.5.8,<1.6.0 diff --git a/mypyc/build.py b/mypyc/build.py index f90e82abc7fc..8e1ee8078c11 100644 --- a/mypyc/build.py +++ b/mypyc/build.py @@ -51,7 +51,7 @@ try: # Import setuptools so that it monkey-patch overrides distutils - import setuptools # noqa: F401 + import setuptools except ImportError: if sys.version_info >= (3, 12): # Raise on Python 3.12, since distutils will go away forever @@ -63,13 +63,16 @@ def get_extension() -> type[Extension]: # We can work with either setuptools or distutils, and pick setuptools # if it has been imported. use_setuptools = "setuptools" in sys.modules + extension_class: type[Extension] if not use_setuptools: - from distutils.core import Extension + import distutils.core + + extension_class = distutils.core.Extension else: - from setuptools import Extension + extension_class = setuptools.Extension - return Extension + return extension_class def setup_mypycify_vars() -> None: diff --git a/pyproject.toml b/pyproject.toml index 0869bba3bada..328b9bf159a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ requires = [ "tomli>=1.1.0; python_version<'3.11'", # the following is from build-requirements.txt "types-psutil", - "types-setuptools<67.4.0.2", # TODO: fix build when using the latest version of types-setuptools + "types-setuptools", "types-typed-ast>=1.5.8,<1.6.0", ] build-backend = "setuptools.build_meta"