-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·105 lines (100 loc) · 3.71 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
from setuptools import setup, find_packages, Extension
import os
import sys
try:
from Cython.Build import cythonize
cython_available = True
except ImportError:
cython_available = False
def get_version():
"""
Gets the version number. Pulls it from the source files rather than
duplicating it.
"""
# we read the file instead of importing it as root sometimes does not
# have the cwd as part of the PYTHONPATH
fn = os.path.join(os.path.dirname(__file__), 'src', 'geompreds', '__init__.py')
try:
lines = open(fn, 'r').readlines()
except IOError:
raise RuntimeError("Could not determine version number"
"(%s not there)" % (fn))
version = None
for l in lines:
# include the ' =' as __version__ might be a part of __all__
if l.startswith('__version__ =', ):
version = eval(l[13:])
break
if version is None:
raise RuntimeError("Could not determine version number: "
"'__version__ =' string not found")
return version
# Platform specifics
# ==================
# Linux (2.x and 3.x) 'linux2'
# Windows 'win32'
# Windows/Cygwin 'cygwin'
# Mac OS X 'darwin'
# OS/2 'os2'
# OS/2 EMX 'os2emx'
# RiscOS 'riscos'
# AtheOS 'atheos'
macros = []
args = []
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
macros = [("CPU86", 1)]
elif sys.platform.startswith('linux'):
macros = [('LINUX',1), ]
# for GCC: full ieee754 compliance
# see: https://gcc.gnu.org/wiki/FloatingPointMath
args = ["-frounding-math","-fsignaling-nans", "-O0"]
if cython_available:
# cythonize the source
ext_modules = cythonize([Extension("geompreds._geompreds",
define_macros = macros,
sources = ["src/geompreds/_geompreds.pyx",
"src/geompreds/pred.c"],
extra_compile_args=args,
extra_link_args=args,
include_dirs=['src/geompreds'])])
else:
# use provided c file
ext_modules = [Extension("geompreds._geompreds",
define_macros = macros,
sources = ["src/geompreds/_geompreds.c",
"src/geompreds/pred.c"],
extra_compile_args=args,
extra_link_args=args,
include_dirs=['src/geompreds'])]
if __name__ == "__main__":
setup(
name = "geompreds",
version = get_version(),
author = "Martijn Meijers",
author_email = "b.m.meijers@tudelft.nl",
description = ("Adaptive Precision Floating-Point Arithmetic and "
"Fast Robust Predicates for Computational Geometry "
"for Python"),
license = "MIT license",
url = "https://bitbucket.org/bmmeijers/predicates/",
package_dir = {'':'src'},
packages = ['geompreds',],
ext_modules = ext_modules,
test_suite="geompreds.tests",
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Cython",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: GIS",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
],
)