From fbc32c7d184d3df4240b05c0e7a050280acf3a2e Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Fri, 16 Sep 2022 23:37:08 -0700 Subject: [PATCH 1/3] Support building mypycified mypy with PEP517 interface (#13445) --- .github/workflows/test.yml | 2 +- build-requirements.txt | 1 + mypy-requirements.txt | 1 + pyproject.toml | 12 ++++++++++++ setup.py | 4 ++-- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8f8a2a05e2b..c06bb0692f57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,7 @@ jobs: if: ${{ matrix.test_mypyc }} run: | pip install -r test-requirements.txt - CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace + CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e . - name: Setup tox environment run: tox -e ${{ matrix.toxenv }} --notest - name: Test diff --git a/build-requirements.txt b/build-requirements.txt index dabc9b14c493..85666bccda25 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1,3 +1,4 @@ +# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml -r mypy-requirements.txt types-setuptools types-typed-ast>=1.5.0,<1.6.0 diff --git a/mypy-requirements.txt b/mypy-requirements.txt index 1c372294383d..ee5fe5d295b8 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -1,3 +1,4 @@ +# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml typing_extensions>=3.10 mypy_extensions>=0.4.3 typed_ast>=1.4.0,<2; python_version<'3.8' diff --git a/pyproject.toml b/pyproject.toml index 95f65599a130..a792eb43882c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,19 @@ [build-system] requires = [ + # NOTE: this needs to be kept in sync with mypy-requirements.txt + # and build-requirements.txt, because those are both needed for + # self-typechecking :/ "setuptools >= 40.6.2", "wheel >= 0.30.0", + # the following is from mypy-requirements.txt + "typing_extensions>=3.10", + "mypy_extensions>=0.4.3", + "typed_ast>=1.4.0,<2; python_version<'3.8'", + "tomli>=1.1.0; python_version<'3.11'", + # the following is from build-requirements.txt + "types-psutil", + "types-setuptools", + "types-typed-ast>=1.5.8,<1.6.0", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index a8c86ff663a3..5390d09d92b4 100644 --- a/setup.py +++ b/setup.py @@ -79,8 +79,8 @@ def run(self): USE_MYPYC = False # To compile with mypyc, a mypyc checkout must be present on the PYTHONPATH -if len(sys.argv) > 1 and sys.argv[1] == "--use-mypyc": - sys.argv.pop(1) +if len(sys.argv) > 1 and "--use-mypyc" in sys.argv: + sys.argv.remove("--use-mypyc") USE_MYPYC = True if os.getenv("MYPY_USE_MYPYC", None) == "1": USE_MYPYC = True From 98a1920c30d95d1befc7e332a4f321bef4a1e9ae Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 19 Sep 2022 10:29:15 -0700 Subject: [PATCH 2/3] Update build-requirements.txt --- build-requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-requirements.txt b/build-requirements.txt index 85666bccda25..52c518d53bc2 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1,4 +1,5 @@ # NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml -r mypy-requirements.txt +types-psutil types-setuptools -types-typed-ast>=1.5.0,<1.6.0 +types-typed-ast>=1.5.8,<1.6.0 From e41aff0242330fdbb6007032e5903a3dcc066223 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 19 Sep 2022 11:06:13 -0700 Subject: [PATCH 3/3] backport less --- build-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/build-requirements.txt b/build-requirements.txt index 52c518d53bc2..4b5f57c28ab9 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1,5 +1,4 @@ # NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml -r mypy-requirements.txt -types-psutil types-setuptools types-typed-ast>=1.5.8,<1.6.0