From 80e2c5e851fd5361f2f7bfbf31fcc3ecebfd42d0 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Mon, 20 May 2019 13:45:35 -0700 Subject: [PATCH 1/4] Try testing when compiled with mypyc --- .travis.yml | 12 ++++++++++++ mypy/test/testmypyc.py | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 mypy/test/testmypyc.py diff --git a/.travis.yml b/.travis.yml index 882737fc7c53c..32a35205c63bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ dist: xenial env: TOXENV=py EXTRA_ARGS="-n 12" + TEST_MYPYC=0 jobs: include: @@ -34,6 +35,12 @@ jobs: - TOXENV=py - EXTRA_ARGS="-n 12" - NEWSEMANAL=1 + - name: "run test suite with python 3.7 (compiled with mypyc)" + python: 3.7 + env: + - TOXENV=py + - EXTRA_ARGS="-n 12" + - TEST_MYPYC=1 - name: "run test suite with python 3.8-dev" python: 3.8-dev - name: "type check our own code" @@ -64,6 +71,11 @@ install: - pip install -U pip setuptools - pip install -U tox==3.9.0 - tox --notest +# This is a big hack and only works because the layout of our directories +# means that tox picks up the mypy from the source directories instead of +# the version it installed into a venv. This is also *why* we need to do this, +# since if we arranged for tox to build with mypyc, pytest wouldn't use it. +- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi script: - tox -- $EXTRA_ARGS diff --git a/mypy/test/testmypyc.py b/mypy/test/testmypyc.py new file mode 100644 index 0000000000000..632e7855c5101 --- /dev/null +++ b/mypy/test/testmypyc.py @@ -0,0 +1,11 @@ +"""A basic check to make sure that we are using a mypyc-compiled version when expected.""" + +import mypy + +from unittest import TestCase +import os + +class MypycTest(TestCase): + def test_using_mypyc(self) -> None: + if os.getenv('TEST_MYPYC', None) == '1': + assert not mypy.__file__.endswith('.py'), "Expected to find a mypyc-compiled version" From 289a71f4033481e73647332111a405b5dcbeea75 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Mon, 20 May 2019 14:07:07 -0700 Subject: [PATCH 2/4] How about with -O3? Faster or slower?? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32a35205c63bb..2d768eed0a33e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ install: # means that tox picks up the mypy from the source directories instead of # the version it installed into a venv. This is also *why* we need to do this, # since if we arranged for tox to build with mypyc, pytest wouldn't use it. -- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi +- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=3 python3 setup.py --use-mypyc build_ext --inplace; fi script: - tox -- $EXTRA_ARGS From 4c336802635bed262497bbc42e0ee0b3f17c91da Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Mon, 20 May 2019 14:29:58 -0700 Subject: [PATCH 3/4] Revert "How about with -O3? Faster or slower??" This reverts commit 289a71f4033481e73647332111a405b5dcbeea75. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2d768eed0a33e..32a35205c63bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ install: # means that tox picks up the mypy from the source directories instead of # the version it installed into a venv. This is also *why* we need to do this, # since if we arranged for tox to build with mypyc, pytest wouldn't use it. -- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=3 python3 setup.py --use-mypyc build_ext --inplace; fi +- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypyc-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi script: - tox -- $EXTRA_ARGS From 96b9631418c9c6956e6a34f0c2beb49784a3f385 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Mon, 20 May 2019 14:39:06 -0700 Subject: [PATCH 4/4] fix lint --- mypy/test/testmypyc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/test/testmypyc.py b/mypy/test/testmypyc.py index 632e7855c5101..b66ec9e5ccf3f 100644 --- a/mypy/test/testmypyc.py +++ b/mypy/test/testmypyc.py @@ -5,6 +5,7 @@ from unittest import TestCase import os + class MypycTest(TestCase): def test_using_mypyc(self) -> None: if os.getenv('TEST_MYPYC', None) == '1':