11#!/usr/bin/env python3
22
3- import sys
43import os
5-
6- from setuptools import setup
7-
8- from subprocess import check_output
94import platform
5+ import sys
106import warnings
7+ from subprocess import CalledProcessError , check_output
8+ from typing import List
9+
10+ from setuptools import setup
1111
1212SDL_VERSION_NEEDED = (2 , 0 , 5 )
1313
1414
15- def get_version ():
15+ def get_version () -> str :
1616 """Get the current version from a git tag, or by reading tcod/version.py"""
1717 try :
1818 tag = check_output (
@@ -31,27 +31,28 @@ def get_version():
3131 version += ".dev%i" % commits_since_tag
3232
3333 # update tcod/version.py
34- with open ("tcod/version.py" , "w" ) as f :
35- f .write ('__version__ = "%s"\n ' % version )
34+ with open ("tcod/version.py" , "w" ) as version_file :
35+ version_file .write ('__version__ = "%s"\n ' % version )
3636 return version
37- except :
37+ except CalledProcessError :
3838 try :
39- exec (open ("tcod/version.py" ).read (), globals ())
40- return __version__
39+ __version__ = "0.0.0"
40+ with open ("tcod/version.py" ) as version_file :
41+ exec (version_file .read (), globals ()) # Update __version__
4142 except FileNotFoundError :
4243 warnings .warn (
4344 "Unknown version: "
4445 "Not in a Git repository and not from a sdist bundle or wheel."
4546 )
46- return "0.0.0"
47+ return __version__
4748
4849
4950is_pypy = platform .python_implementation () == "PyPy"
5051
5152
52- def get_package_data ():
53+ def get_package_data () -> List [ str ] :
5354 """get data files which will be included in the main tcod/ directory"""
54- BITSIZE , LINKAGE = platform .architecture ()
55+ BITSIZE , _ = platform .architecture ()
5556 files = [
5657 "py.typed" ,
5758 "lib/LIBTCOD-CREDITS.txt" ,
@@ -68,13 +69,13 @@ def get_package_data():
6869 return files
6970
7071
71- def get_long_description ():
72+ def get_long_description () -> str :
7273 """Return this projects description."""
73- with open ("README.rst" , "r" ) as f :
74- return f .read ()
74+ with open ("README.rst" , "r" ) as readme_file :
75+ return readme_file .read ()
7576
7677
77- def check_sdl_version ():
78+ def check_sdl_version () -> None :
7879 """Check the local SDL version on Linux distributions."""
7980 if not sys .platform .startswith ("linux" ):
8081 return
@@ -127,13 +128,17 @@ def check_sdl_version():
127128 packages = ["tcod" , "tcod.__pyinstaller" ],
128129 package_data = {"tcod" : get_package_data ()},
129130 python_requires = ">=3.6" ,
131+ setup_requires = [
132+ * pytest_runner ,
133+ "cffi~=1.13" ,
134+ "pycparser>=2.14" ,
135+ ],
130136 install_requires = [
131137 "cffi~=1.13" , # Also required by pyproject.toml.
132138 "numpy~=1.10" if not is_pypy else "" ,
133139 "typing_extensions" ,
134140 ],
135141 cffi_modules = ["build_libtcod.py:ffi" ],
136- setup_requires = pytest_runner ,
137142 tests_require = ["pytest" , "pytest-cov" , "pytest-benchmark" ],
138143 classifiers = [
139144 "Development Status :: 5 - Production/Stable" ,
0 commit comments