From 8e459eab40ac0fae9740e985ee4aeb348cde28c5 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 26 Feb 2023 15:27:20 +0000 Subject: [PATCH 1/4] Fix mypyc build errors on `master` The latest release of `types-setuptools` is causing type-check errors (and, therefore, build errors) on the `master` branch: see, e.g. https://github.com/python/mypy/actions/runs/4275505309/jobs/7442902732. #14781 addressed some of the new errors, but didn't quite fix the build. --- mypyc/build.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mypyc/build.py b/mypyc/build.py index f90e82abc7fc..fca2cae754be 100644 --- a/mypyc/build.py +++ b/mypyc/build.py @@ -63,13 +63,14 @@ 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 + from distutils.core import Extension as extension_class else: - from setuptools import Extension + from setuptools import Extension as extension_class - return Extension + return extension_class def setup_mypycify_vars() -> None: From 58273fb068f4c83539fca4d8e06f1986e1e9983a Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 26 Feb 2023 17:51:13 +0000 Subject: [PATCH 2/4] Revert "Pin `types-setuptools` to <67.4.0.2 (#14788)" This reverts commit 800e8ffdf17de9fc641fefff46389a940f147eef. --- build-requirements.txt | 3 +-- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) 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/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" From 1a595bd66ac9d363ee37bd020ef2764a06a2ef00 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 26 Feb 2023 17:52:34 +0000 Subject: [PATCH 3/4] Try Jelle's suggestion --- mypyc/build.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mypyc/build.py b/mypyc/build.py index fca2cae754be..d62d106eb50e 100644 --- a/mypyc/build.py +++ b/mypyc/build.py @@ -66,9 +66,11 @@ def get_extension() -> type[Extension]: extension_class: type[Extension] if not use_setuptools: - from distutils.core import Extension as extension_class + import distutils.core + extension_class = distutils.core.Extension else: - from setuptools import Extension as extension_class + import setuptools + extension_class = setuptools.Extension return extension_class From 633bc309da30a6b2b09bad9b4f572c5a303ef287 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sun, 26 Feb 2023 17:58:35 +0000 Subject: [PATCH 4/4] Fix lints --- mypyc/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypyc/build.py b/mypyc/build.py index d62d106eb50e..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 @@ -67,9 +67,9 @@ def get_extension() -> type[Extension]: if not use_setuptools: import distutils.core + extension_class = distutils.core.Extension else: - import setuptools extension_class = setuptools.Extension return extension_class