From 2a31c31a3bd60e899d903a7f63a4d49c21ecb8cc Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 26 Oct 2016 14:59:55 -0700 Subject: [PATCH 1/9] Make typing and typed-ast external dependencies. This will automatically install the typing and typed-ast packages when appropriate. The setup.py file now depends on setuptools. We should build wheels so that users installing from PyPI won't need setuptools. In order to build wheels the distribution builder/uploader needs to install the wheel package. To manage those dependencies, I've added build-requirements.txt. In summary: - python3 -m pip install -r build-requirements.txt - python3 setup.py bdist_wheel - upload the .whl file that appears in the dist/ subdirectory to PyPI --- MANIFEST.in | 1 - build-requirements.txt | 2 ++ setup.py | 16 +++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 build-requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index 8e6b6386b61f..e8e949f97f26 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,2 @@ -recursive-include lib-typing *.py recursive-include scripts * recursive-exclude scripts myunit diff --git a/build-requirements.txt b/build-requirements.txt new file mode 100644 index 000000000000..0a8547bcc8ef --- /dev/null +++ b/build-requirements.txt @@ -0,0 +1,2 @@ +setuptools +wheel diff --git a/setup.py b/setup.py index 374f76b627ed..4dd96c03bcba 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,8 @@ sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n") exit(1) -from distutils.core import setup -from distutils.command.build_py import build_py +from setuptools import setup +from setuptools.command.build_py import build_py from mypy.version import base_version from mypy import git @@ -81,18 +81,23 @@ def run(self): 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Software Development', ] package_dir = {'mypy': 'mypy'} -if sys.version_info < (3, 5, 0): - package_dir[''] = 'lib-typing/3.2' scripts = ['scripts/mypy', 'scripts/stubgen'] if os.name == 'nt': scripts.append('scripts/mypy.bat') +install_requires = [] +if sys.platform != 'win32': + install_requires.append('typed-ast >= 0.6.1') +if sys.version_info < (3, 5): + install_requires.append('typing >= 3.5.2') + setup(name='mypy-lang', version=version, description=description, @@ -103,10 +108,11 @@ def run(self): license='MIT License', platforms=['POSIX'], package_dir=package_dir, - py_modules=['typing'] if sys.version_info < (3, 5, 0) else [], + py_modules=[], packages=['mypy'], scripts=scripts, data_files=data_files, classifiers=classifiers, cmdclass={'build_py': CustomPythonBuild}, + install_requires=install_requires, ) From c2199616cb612fbfd42a5b866e01ce1f867d4ccf Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 26 Oct 2016 15:25:09 -0700 Subject: [PATCH 2/9] Make Python 3.3/3.4 tests pass, by skipping a test depending on a specific typing package --- test-data/unit/pythoneval.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index 1887177d3320..7945fe552114 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -11,7 +11,8 @@ print('hello, world') [out] hello, world -[case testAbstractBaseClasses] +-- Skipped because different typing package versions have different repr()s. +[case testAbstractBaseClasses-skip] import re from typing import Sized, Sequence, Iterator, Iterable, Mapping, AbstractSet From 263f00589039af4225ccdce090b15241f3f27c45 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 14 Nov 2016 13:35:07 -0800 Subject: [PATCH 3/9] Update setup.cfg with cargo-culted stuff --- setup.cfg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup.cfg b/setup.cfg index dd46edd3aeff..0877334f564b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,3 +20,14 @@ parallel = true [coverage:report] show_missing = true + +[wheel] +universal = true + +[bdist_wheel] +universal = true + +[metadata] +requires-dist = + typed-ast >= 0.6.1; sys_platform != 'win32' + typing >= 3.5.2; python_version < "3.5" From 7d91652d7d52f0237335348326cd1269650fa588 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 15 Nov 2016 08:32:36 -0800 Subject: [PATCH 4/9] Our wheels are not universal --- setup.cfg | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 0877334f564b..8599bea0eba7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,12 +21,6 @@ parallel = true [coverage:report] show_missing = true -[wheel] -universal = true - -[bdist_wheel] -universal = true - [metadata] requires-dist = typed-ast >= 0.6.1; sys_platform != 'win32' From 08c86df09c406cdc96fd67c7687ad5ba67ffa389 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 9 Dec 2016 12:13:02 -0800 Subject: [PATCH 5/9] Add comments clarifying some things added here --- setup.cfg | 4 ++++ setup.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/setup.cfg b/setup.cfg index 8599bea0eba7..d8033fb0b1e4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,10 @@ parallel = true show_missing = true [metadata] +# This seems to be used only by bdist_wheel. +# You need "pip3 install wheel". +# Then run "python3 setup.py bdist_wheel" to build a wheel file +# (and then upload that to PyPI). requires-dist = typed-ast >= 0.6.1; sys_platform != 'win32' typing >= 3.5.2; python_version < "3.5" diff --git a/setup.py b/setup.py index 4dd96c03bcba..92d35a3a1f89 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,9 @@ sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n") exit(1) +# This requires setuptools when building; setuptools is not needed +# when installing from a wheel file (though it is still neeeded for +# alternative forms of installing, as suggested by README.md). from setuptools import setup from setuptools.command.build_py import build_py from mypy.version import base_version @@ -92,6 +95,10 @@ def run(self): if os.name == 'nt': scripts.append('scripts/mypy.bat') +# These requirements are used when installing by other means than bdist_wheel. +# E.g. "pip3 install ." or +# "pip3 install git+git://github.com/python/mypy.git" +# (as suggested by README.md). install_requires = [] if sys.platform != 'win32': install_requires.append('typed-ast >= 0.6.1') From 8e8298db4e939f45100720018a3d7c379e8b060e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 12 Dec 2016 15:15:09 -0800 Subject: [PATCH 6/9] Attempt to fix test failure by also replacing base_version with $VERSION --- mypy/test/testcmdline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/test/testcmdline.py b/mypy/test/testcmdline.py index a5a888711840..f2ddc9bd429b 100644 --- a/mypy/test/testcmdline.py +++ b/mypy/test/testcmdline.py @@ -15,7 +15,7 @@ from mypy.test.config import test_data_prefix, test_temp_dir from mypy.test.data import parse_test_cases, DataDrivenTestCase from mypy.test.helpers import assert_string_arrays_equal -from mypy.version import __version__ +from mypy.version import __version__, base_version # Path to Python 3 interpreter python3_path = sys.executable @@ -99,5 +99,6 @@ def normalize_file_output(content: List[str], current_abs_path: str) -> List[str timestamp_regex = re.compile('\d{10}') result = [x.replace(current_abs_path, '$PWD') for x in content] result = [x.replace(__version__, '$VERSION') for x in result] + result = [x.replace(base_version, '$VERSION') for x in result] result = [timestamp_regex.sub('$TIMESTAMP', x) for x in result] return result From 2ab1e6edcd1da34ae00d4d03627fda78f038184a Mon Sep 17 00:00:00 2001 From: David Fisher Date: Fri, 6 Jan 2017 12:12:05 -0800 Subject: [PATCH 7/9] Update setup.cfg --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index d8033fb0b1e4..4cf58ca65daf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,5 +27,5 @@ show_missing = true # Then run "python3 setup.py bdist_wheel" to build a wheel file # (and then upload that to PyPI). requires-dist = - typed-ast >= 0.6.1; sys_platform != 'win32' - typing >= 3.5.2; python_version < "3.5" + typed-ast >= 0.6.2 + typing >= 3.5.3; python_version < "3.5" From b8468e751c81c95dbc0263a3fef7504df6b02412 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 6 Jan 2017 12:18:18 -0800 Subject: [PATCH 8/9] Update setup.py to match setup.cfg --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 92d35a3a1f89..0278a59ed697 100644 --- a/setup.py +++ b/setup.py @@ -100,10 +100,9 @@ def run(self): # "pip3 install git+git://github.com/python/mypy.git" # (as suggested by README.md). install_requires = [] -if sys.platform != 'win32': - install_requires.append('typed-ast >= 0.6.1') +install_requires.append('typed-ast >= 0.6.2') if sys.version_info < (3, 5): - install_requires.append('typing >= 3.5.2') + install_requires.append('typing >= 3.5.3') setup(name='mypy-lang', version=version, From 09d39c7885f6056321ee1797c2291cb220e939ff Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 6 Jan 2017 12:50:18 -0800 Subject: [PATCH 9/9] We need typed_ast 0.6.3 --- setup.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 4cf58ca65daf..084dab95b5e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,5 +27,5 @@ show_missing = true # Then run "python3 setup.py bdist_wheel" to build a wheel file # (and then upload that to PyPI). requires-dist = - typed-ast >= 0.6.2 + typed-ast >= 0.6.3 typing >= 3.5.3; python_version < "3.5" diff --git a/setup.py b/setup.py index 0278a59ed697..722fab858c0c 100644 --- a/setup.py +++ b/setup.py @@ -100,7 +100,7 @@ def run(self): # "pip3 install git+git://github.com/python/mypy.git" # (as suggested by README.md). install_requires = [] -install_requires.append('typed-ast >= 0.6.2') +install_requires.append('typed-ast >= 0.6.3') if sys.version_info < (3, 5): install_requires.append('typing >= 3.5.3')