Skip to content

Commit a207754

Browse files
gvanrossumddfisher
authored andcommitted
Make typing and typed-ast external dependencies (#2452)
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
1 parent 996e3e8 commit a207754

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
recursive-include lib-typing *.py
21
recursive-include scripts *
32
recursive-exclude scripts myunit

build-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
setuptools
2+
wheel

mypy/test/testcmdline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from mypy.test.config import test_data_prefix, test_temp_dir
1616
from mypy.test.data import parse_test_cases, DataDrivenTestCase
1717
from mypy.test.helpers import assert_string_arrays_equal
18-
from mypy.version import __version__
18+
from mypy.version import __version__, base_version
1919

2020
# Path to Python 3 interpreter
2121
python3_path = sys.executable
@@ -99,5 +99,6 @@ def normalize_file_output(content: List[str], current_abs_path: str) -> List[str
9999
timestamp_regex = re.compile('\d{10}')
100100
result = [x.replace(current_abs_path, '$PWD') for x in content]
101101
result = [x.replace(__version__, '$VERSION') for x in result]
102+
result = [x.replace(base_version, '$VERSION') for x in result]
102103
result = [timestamp_regex.sub('$TIMESTAMP', x) for x in result]
103104
return result

setup.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ parallel = true
2020

2121
[coverage:report]
2222
show_missing = true
23+
24+
[metadata]
25+
# This seems to be used only by bdist_wheel.
26+
# You need "pip3 install wheel".
27+
# Then run "python3 setup.py bdist_wheel" to build a wheel file
28+
# (and then upload that to PyPI).
29+
requires-dist =
30+
typed-ast >= 0.6.3
31+
typing >= 3.5.3; python_version < "3.5"

setup.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n")
1010
exit(1)
1111

12-
from distutils.core import setup
13-
from distutils.command.build_py import build_py
12+
# This requires setuptools when building; setuptools is not needed
13+
# when installing from a wheel file (though it is still neeeded for
14+
# alternative forms of installing, as suggested by README.md).
15+
from setuptools import setup
16+
from setuptools.command.build_py import build_py
1417
from mypy.version import base_version
1518
from mypy import git
1619

@@ -81,18 +84,26 @@ def run(self):
8184
'Programming Language :: Python :: 3.3',
8285
'Programming Language :: Python :: 3.4',
8386
'Programming Language :: Python :: 3.5',
87+
'Programming Language :: Python :: 3.6',
8488
'Topic :: Software Development',
8589
]
8690

8791

8892
package_dir = {'mypy': 'mypy'}
89-
if sys.version_info < (3, 5, 0):
90-
package_dir[''] = 'lib-typing/3.2'
9193

9294
scripts = ['scripts/mypy', 'scripts/stubgen']
9395
if os.name == 'nt':
9496
scripts.append('scripts/mypy.bat')
9597

98+
# These requirements are used when installing by other means than bdist_wheel.
99+
# E.g. "pip3 install ." or
100+
# "pip3 install git+git://github.com/python/mypy.git"
101+
# (as suggested by README.md).
102+
install_requires = []
103+
install_requires.append('typed-ast >= 0.6.3')
104+
if sys.version_info < (3, 5):
105+
install_requires.append('typing >= 3.5.3')
106+
96107
setup(name='mypy-lang',
97108
version=version,
98109
description=description,
@@ -103,10 +114,11 @@ def run(self):
103114
license='MIT License',
104115
platforms=['POSIX'],
105116
package_dir=package_dir,
106-
py_modules=['typing'] if sys.version_info < (3, 5, 0) else [],
117+
py_modules=[],
107118
packages=['mypy'],
108119
scripts=scripts,
109120
data_files=data_files,
110121
classifiers=classifiers,
111122
cmdclass={'build_py': CustomPythonBuild},
123+
install_requires=install_requires,
112124
)

test-data/unit/pythoneval.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ print('hello, world')
1111
[out]
1212
hello, world
1313

14-
[case testAbstractBaseClasses]
14+
-- Skipped because different typing package versions have different repr()s.
15+
[case testAbstractBaseClasses-skip]
1516
import re
1617
from typing import Sized, Sequence, Iterator, Iterable, Mapping, AbstractSet
1718

0 commit comments

Comments
 (0)