forked from libtcod/python-tcod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·158 lines (131 loc) · 4.88 KB
/
setup.py
File metadata and controls
executable file
·158 lines (131 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env python3
import sys
from setuptools import setup
from subprocess import check_output
import platform
import warnings
from distutils.unixccompiler import UnixCCompiler
C_STANDARD = "-std=c99"
CPP_STANDARD = "-std=c++14"
old_compile = UnixCCompiler._compile
def new_compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
cc_args = list(cc_args)
if UnixCCompiler.language_map[ext] == "c":
cc_args.append(C_STANDARD)
elif UnixCCompiler.language_map[ext] == "c++":
cc_args.append(CPP_STANDARD)
return old_compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
UnixCCompiler._compile = new_compile
def get_version():
"""Get the current version from a git tag, or by reading tcod/version.py"""
try:
tag = check_output(
["git", "describe", "--abbrev=0"], universal_newlines=True
).strip()
assert not tag.startswith("v")
version = tag
# add .devNN if needed
log = check_output(
["git", "log", "%s..HEAD" % tag, "--oneline"],
universal_newlines=True,
)
commits_since_tag = log.count("\n")
if commits_since_tag:
version += ".dev%i" % commits_since_tag
# update tcod/version.py
open("tcod/version.py", "w").write('__version__ = "%s"\n' % version)
return version
except:
try:
exec(open("tcod/version.py").read(), globals())
return __version__
except FileNotFoundError:
warnings.warn(
"Unknown version: "
"Not in a Git repository and not from a sdist bundle or wheel."
)
return "0.0.0"
is_pypy = platform.python_implementation() == "PyPy"
def get_package_data():
"""get data files which will be included in the main tcod/ directory"""
BITSIZE, LINKAGE = platform.architecture()
files = [
"py.typed",
"lib/LIBTCOD-CREDITS.txt",
"lib/LIBTCOD-LICENSE.txt",
"lib/README-SDL.txt",
]
if "win32" in sys.platform:
if BITSIZE == "32bit":
files += ["x86/SDL2.dll"]
else:
files += ["x64/SDL2.dll"]
if sys.platform == "darwin":
files += ["SDL2.framework/Versions/A/SDL2"]
return files
def get_long_description():
"""Return this projects description."""
with open("README.rst", "r") as f:
readme = f.read()
with open("CHANGELOG.rst", "r") as f:
changelog = f.read()
changelog = changelog.replace("\nUnreleased\n------------------", "")
return "\n".join([readme, changelog])
if sys.version_info < (3, 5):
error = """
This version of python-tcod only supports Python 3.5 and above.
The last version supporting Python 2.7/3.4 was 'tcod==6.0.7'.
The end-of-life for Python 2 is the year 2020.
https://pythonclock.org/
Python {py} detected.
""".format(
py=".".join([str(v) for v in sys.version_info[:3]])
)
print(error)
sys.exit(1)
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
pytest_runner = ["pytest-runner"] if needs_pytest else []
setup(
name="tcod",
version=get_version(),
author="Kyle Stewart",
author_email="4B796C65+tdl@gmail.com",
description="Pythonic cffi port of libtcod.",
long_description=get_long_description(),
url="https://github.com/libtcod/python-tcod",
py_modules=["libtcodpy"],
packages=["tdl", "tcod"],
package_data={"tdl": ["*.png"], "tcod": get_package_data()},
python_requires=">=3.5",
install_requires=[
"cffi>=1.12.0,<2",
"numpy>=1.10,<2" if not is_pypy else "",
],
cffi_modules=["build_libtcod.py:ffi"],
setup_requires=["cffi>=1.8.1,<2", "pycparser>=2.14,<3"] + pytest_runner,
tests_require=["pytest", "pytest-cov", "pytest-benchmark"],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Win32 (MS Windows)",
"Environment :: MacOS X",
"Environment :: X11 Applications",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Games/Entertainment",
"Topic :: Multimedia :: Graphics",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords="roguelike cffi Unicode libtcod fov heightmap namegen",
platforms=["Windows", "MacOS", "Linux"],
license="Simplified BSD License",
)