forked from john-science/mazelib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
125 lines (112 loc) · 3.86 KB
/
setup.py
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
""" How to Install
The easiest solution it so install via PyPI:
pip install mazelib
But if you know setuputils/distutils, you can build locally:
pip install -r requirements.txt
pip install .
To run the test suite any of the following will work:
nosetests test/
pytest test/
make test
"""
# non-controversial imports
import os
from setuptools import setup, find_packages
from setuptools.command.install import install
from glob import glob
from os import name as os_name
from sys import argv, platform
from mazelib import __version__
# Ideally, you install Cython *before* you install mazelib, so you can compile it.
try:
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
cmdclass = {"install": install, "build_ext": build_ext}
has_cython = True
except (ModuleNotFoundError, ImportError):
print(
"WARNING: You do not have Cython installed. Installation preceeding without Cython."
)
cmdclass = {"install": install}
has_cython = False
# You will also need NumPy to compile this Cython
try:
import numpy as np
except (ModuleNotFoundError, ImportError):
print(
"WARNING: You do not have NumPy installed. Installation preceeding without NumPy."
)
has_cython = False
# find all the extension modules in the project, for a Cython build
if has_cython:
FORCE_FLAGS = ["-f", "--f", "--force"]
FORCE_REBUILD = True if any([f in argv for f in FORCE_FLAGS]) else False
IS_WINDOWS = (
True if (os_name.lower() == "nt" or "win" in platform.lower()) else False
)
COMP_DIRS = {
"language_level": 3,
"boundscheck": False,
"initializedcheck": False,
"cdivision": True,
}
sep = "\\" if IS_WINDOWS else "/"
ext_modules = [
Extension(
p[:-4].replace(sep, "."),
[p, p[:-2] + "y"],
include_dirs=[np.get_include(), "."],
)
for p in glob(sep.join(["mazelib", "*", "*.pxd"]))
]
ext_modules_list = cythonize(
ext_modules, annotate=False, force=FORCE_REBUILD, compiler_directives=COMP_DIRS
)
else:
ext_modules_list = []
# grab the README.md text
this_dir = os.path.abspath(os.path.dirname(__file__))
try:
with open(os.path.join(this_dir, "README.md")) as f:
readme = f.read()
except IOError:
readme = ""
# perform the actual build/install
setup(
cmdclass=cmdclass,
name="mazelib",
version=__version__,
description="A Python API for creating and solving mazes.",
url="https://github.com/john-science/mazelib",
keywords="game mathematics algorithms maze mazes math games algorithm",
author="John Stilley",
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Games/Entertainment :: Puzzle Games",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Natural Language :: English",
],
python_requires=">=3.4, <3.12",
license="MIT",
long_description=readme,
long_description_content_type="text/markdown",
packages=find_packages(),
package_data={"mazelib": ["generate/*.pxd", "solve/*.pxd", "transmute/*.pxd"]},
ext_modules=ext_modules_list,
platforms="any",
test_suite="test",
setup_requires=["numpy>=1.13.1,<=1.23.4"],
install_requires=["cython>=0.27.0,<=0.29.32", "numpy>=1.13.1,<=1.23.4"],
zip_safe=False,
)