Skip to content

Commit b45c990

Browse files
committed
Merge branch 'merge-mypyc' (python#7378)
The general approach here is that mypyc becomes a top-level package and mypyc-specific files are sunk down into its subdirectories. This includes README, test-data, docs, and our vendored copy of googletest. The existing CI test builds all now run the mypyc tests as well. New builds are added to run mypyc run tests on OS X, linux with a debug build of python, and 32-bit windows. A side effect of this is that we now test a fully bootstrapped mypyc, which is pretty cool. There will probably need to be some follow-up work to improve docs, test experience, etc, but I think we are ready to pull the trigger on this. The mypyc history was rewritten before this merge to fix up PR and issue references to be cross-repo references to the old mypyc repo. Closes python#7308.
2 parents 67688df + 034e437 commit b45c990

File tree

143 files changed

+70821
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+70821
-41
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,12 @@ include/
4343

4444
.tox
4545
pip-wheel-metadata
46+
47+
48+
test_capi
49+
*.o
50+
*.a
51+
test_capi
52+
/.mypyc-flake8-cache.json
53+
/mypyc/lib-rt/build/
54+
/mypyc/lib-rt/*.so

.travis.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ if: tag IS present OR type = pull_request OR ((branch = master OR branch =~ rele
44
language: python
55
# cache package wheels (1 cache per python version)
66
cache: pip
7+
# also cache the directories where we set up our custom pythons in some builds
8+
cache:
9+
directories:
10+
- $HOME/python-debug
11+
# I ran into some issues with this but will investigate again later.
12+
# - $HOME/.pyenv/versions
13+
- $HOME/Library/Caches/pip
14+
715
# newer python versions are available only on xenial (while some older only on trusty) Ubuntu distribution
816
dist: xenial
917

1018
env:
1119
TOXENV=py
1220
EXTRA_ARGS="-n 12"
1321
TEST_MYPYC=0
22+
PYTHON_DEBUG_BUILD=0
1423

1524
jobs:
1625
include:
@@ -22,6 +31,20 @@ jobs:
2231
python: 3.6 # 3.6.3 pip 9.0.1
2332
- name: "run test suite with python 3.7"
2433
python: 3.7 # 3.7.0 pip 10.0.1
34+
- name: "run mypyc runtime tests with python 3.6 debug build"
35+
language: generic
36+
env:
37+
- TOXENV=py36
38+
- PYTHONVERSION=3.6.8
39+
- PYTHON_DEBUG_BUILD=1
40+
- EXTRA_ARGS="-n 12 mypyc/test/test_run.py mypyc/test/test_external.py"
41+
- name: "run mypyc runtime tests with python 3.6 on OS X"
42+
os: osx
43+
osx_image: xcode8.3
44+
language: generic
45+
env:
46+
- PYTHONVERSION=3.6.3
47+
- EXTRA_ARGS="-n 12 mypyc/test/test_run.py mypyc/test/test_external.py"
2548
- name: "run test suite with python 3.7 (compiled with mypyc)"
2649
python: 3.7
2750
env:
@@ -58,11 +81,33 @@ install:
5881
- pip install -U pip setuptools
5982
- pip install -U tox==3.9.0
6083
- tox --notest
84+
6185
# This is a big hack and only works because the layout of our directories
6286
# means that tox picks up the mypy from the source directories instead of
6387
# the version it installed into a venv. This is also *why* we need to do this,
6488
# since if we arranged for tox to build with mypyc, pytest wouldn't use it.
65-
- 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
89+
- if [[ $TEST_MYPYC == 1 ]]; then pip install -r test-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi
6690

6791
script:
6892
- tox -- $EXTRA_ARGS
93+
94+
# Getting our hands on a debug build or the right OS X build is
95+
# annoying, unfortunately.
96+
before_install: |
97+
set -e
98+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
99+
if [[ $PYTHON_DEBUG_BUILD == 1 ]]; then
100+
PYTHONDIR=~/python-debug/python-$PYTHONVERSION
101+
VENV=$PYTHONDIR/env
102+
misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV
103+
source $VENV/bin/activate
104+
fi
105+
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
106+
# Attempt to install, skipping if version already exists.
107+
pyenv install $PYTHONVERSION -s
108+
# Regenerate shims
109+
pyenv rehash
110+
# Manually set pyenv variables per https://pythonhosted.org/CodeChat/.travis.yml.html
111+
export PYENV_VERSION=$PYTHONVERSION
112+
export PATH="/Users/travis/.pyenv/shims:${PATH}"
113+
fi

LICENSE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Mypy is licensed under the terms of the MIT license, reproduced below.
1+
Mypy (and mypyc) are licensed under the terms of the MIT license, reproduced below.
22

33
= = = = =
44

55
The MIT License
66

7-
Copyright (c) 2015-2016 Jukka Lehtosalo and contributors
7+
Copyright (c) 2015-2019 Jukka Lehtosalo and contributors
88

99
Permission is hereby granted, free of charge, to any person obtaining a
1010
copy of this software and associated documentation files (the "Software"),
@@ -26,8 +26,10 @@ DEALINGS IN THE SOFTWARE.
2626

2727
= = = = =
2828

29-
Portions of mypy are licensed under different licenses. The files
30-
under stdlib-samples are licensed under the PSF 2 License, reproduced below.
29+
Portions of mypy and mypyc are licensed under different licenses. The
30+
files under stdlib-samples as well as the files
31+
mypyc/lib-rt/pythonsupport.h and mypyc/lib-rt/getargs.c are licensed
32+
under the PSF 2 License, reproduced below.
3133

3234
= = = = =
3335

@@ -223,5 +225,3 @@ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
223225
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
224226
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
225227
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
226-
227-
= = = = =

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ Compiled version of mypy
265265
------------------------
266266

267267
We have built an compiled version of mypy using the [mypyc
268-
compiler](https://github.com/mypyc/mypyc) for mypy-annotated Python
269-
code. It is approximately 4 times faster than interpreted mypy and is
270-
available (and the default) for 64-bit Windows, macOS, and Linux.
268+
compiler](https://github.com/python/mypy/files/mypyc) for
269+
mypy-annotated Python code. It is approximately 4 times faster than
270+
interpreted mypy and is available (and the default) for 64-bit
271+
Windows, macOS, and Linux.
271272

272273
To install an interpreted mypy instead, use:
273274

appveyor.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ cache:
33

44
environment:
55
matrix:
6-
76
- PYTHON: "C:\\Python37-x64"
87
PYTHON_VERSION: "3.7.x"
98
PYTHON_ARCH: "64"
9+
EXTRA_ARGS:
10+
- PYTHON: "C:\\Python37"
11+
PYTHON_VERSION: "3.7.x"
12+
PYTHON_ARCH: "32"
13+
EXTRA_ARGS: "mypyc/test/test_run.py mypyc/test/test_external.py"
1014

1115
install:
1216
- "git submodule update --init mypy/typeshed"
@@ -16,7 +20,7 @@ install:
1620
build: off
1721

1822
test_script:
19-
- "%PYTHON%\\python.exe -m tox -e py37"
23+
- "%PYTHON%\\python.exe -m tox -e py37 %EXTRA_ARGS%"
2024

2125
skip_commits:
2226
files:

conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ def pytest_configure(config):
99
mypy_source_root = os.path.dirname(os.path.abspath(__file__))
1010
if os.getcwd() != mypy_source_root:
1111
os.chdir(mypy_source_root)
12+
13+
14+
# This function name is special to pytest. See
15+
# http://doc.pytest.org/en/latest/writing_plugins.html#initialization-command-line-and-configuration-hooks
16+
def pytest_addoption(parser) -> None:
17+
parser.addoption('--bench', action='store_true', default=False,
18+
help='Enable the benchmark test runs')

misc/build-debug-python.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash -eux
2+
3+
# Build a debug build of python, install it, and create a venv for it
4+
# This is mainly intended for use in our travis builds but it can work
5+
# locally. (Though it unfortunately uses brew on OS X to deal with openssl
6+
# nonsense.)
7+
# Usage: build-debug-python.sh <version> <install prefix> <venv location>
8+
#
9+
# Running it locally might look something like: mkdir -p ~/tmp/cpython-debug && cd ~/tmp/cpython-debug && ~/src/mypy/misc/build-debug-python.sh 3.6.6 ~/tmp/cpython-debug ~/src/mypy/env-debug
10+
11+
VERSION=$1
12+
PREFIX=$2
13+
VENV=$3
14+
if [[ -f $PREFIX/bin/python3 ]]; then
15+
exit
16+
fi
17+
18+
CPPFLAGS=""
19+
LDFLAGS=""
20+
if [[ $(uname) == Darwin ]]; then
21+
brew install openssl xz
22+
CPPFLAGS="-I$(brew --prefix openssl)/include"
23+
LDFLAGS="-L$(brew --prefix openssl)/lib"
24+
fi
25+
26+
curl -O https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz
27+
tar zxf Python-$VERSION.tgz
28+
cd Python-$VERSION
29+
CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure CFLAGS="-DPy_DEBUG -DPy_TRACE_REFS -DPYMALLOC_DEBUG" --with-pydebug --prefix=$PREFIX
30+
make -j4
31+
make install
32+
$PREFIX/bin/python3 -m pip install virtualenv
33+
$PREFIX/bin/python3 -m virtualenv $VENV
34+
ln -s python3-config $PREFIX/bin/python-config

misc/clean-mypyc.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
echo "Cleaning C/C++ build artifacts..."
3+
(cd mypyc/lib-rt; make clean)
4+
(cd mypyc/external/googletest/make; make clean)

misc/update-mypyc-version.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

mypyc-requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy