forked from john-science/mazelib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
99 lines (80 loc) · 3.42 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
''' How to Install
The easiest solution it so install via PyPI:
pip install mazelib
But you can build mazelib locally using this file.
First things first:
pip install -r requirements.txt
To build mazelib and install the package on your computer:
python setup.py install
To build/install locally, not system-wide:
python setup.py install --inplace
To force all Cython code to rebuild/reinstall locally:
python setup.py install --inplace -f
To run the test suit:
python setup.py test
Though I could not reproduce this, one user reported having to set an environment variable to install:
export CFLAGS="-I /usr/local/lib/python3.6/site-packages/numpy/core/include"
'''
# non-controversial imports
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:
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:
print('WARNING: You do not have NumPy installed. Installation preceeding without Cython.')
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 = []
# 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/theJollySin/mazelib',
author='John Stilley',
classifiers=['Development Status :: 3 - Alpha',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Natural Language :: English'],
license='GPLv3',
long_description='A Python library for creating and solving mazes.',
packages=find_packages(),
ext_modules=ext_modules_list,
platforms='any',
test_suite="test",
setup_requires=["numpy>=1.13.1,<=1.16.4"],
install_requires=["cython>=0.27.0,<=0.28.0",
"numpy>=1.13.1,<=1.16.4"],
zip_safe=False)