Skip to content

Commit

Permalink
Make typing and typed-ast external dependencies (python#2452)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gvanrossum authored and ddfisher committed Jan 6, 2017
1 parent 996e3e8 commit a207754
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
recursive-include lib-typing *.py
recursive-include scripts *
recursive-exclude scripts myunit
2 changes: 2 additions & 0 deletions build-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setuptools
wheel
3 changes: 2 additions & 1 deletion mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ parallel = true

[coverage:report]
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.3
typing >= 3.5.3; python_version < "3.5"
22 changes: 17 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
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
# 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
from mypy import git

Expand Down Expand Up @@ -81,18 +84,26 @@ 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')

# 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 = []
install_requires.append('typed-ast >= 0.6.3')
if sys.version_info < (3, 5):
install_requires.append('typing >= 3.5.3')

setup(name='mypy-lang',
version=version,
description=description,
Expand All @@ -103,10 +114,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,
)
3 changes: 2 additions & 1 deletion test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a207754

Please sign in to comment.