forked from flatsurf/surface-dynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·141 lines (121 loc) · 5.29 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# encoding=utf-8
r"""
Installation script for the flatsurf module
It depends on distutils
"""
import sys
import os
import numpy as np
import cypari2
from distutils.core import setup
from distutils.extension import Extension
from distutils.version import LooseVersion
from distutils.command.build_py import build_py as _build_py
from Cython.Build import cythonize
# NOTE: without this option, tab-completion and documentation are mostly broken within sage
# See https://trac.sagemath.org/ticket/31632
import Cython.Compiler.Options
Cython.Compiler.Options.embed_pos_in_docstring = True
with open("surface_dynamics/version.py") as f:
version = f.read().strip()
prefix = "version='"
suffix = "'"
assert version.startswith(prefix) and version.endswith(suffix)
version = version[len(prefix):len(version)-len(suffix)]
with open("README.md") as f:
long_description = f.read()
try:
import ppl
except ImportError:
sys.stderr.write('Warning: pplpy not installed. Will not compile iet_family\n')
WITH_PPL = False
else:
WITH_PPL = True
extensions_data = {
'origamis': {
'name': 'surface_dynamics.flat_surfaces.origamis.origami_dense',
'dir': os.path.join('flat_surfaces', 'origamis'),
'sources': ['origami_dense.pyx', 'normal_form.c', 'lyapunov_exponents.c'],
'headers': ['origami_dense.pxd', 'lyapunov_exponents.h', 'normal_form.h']
},
'lyapunov_exponents': {
'name': 'surface_dynamics.interval_exchanges.lyapunov_exponents',
'dir': 'interval_exchanges',
'sources': ['lyapunov_exponents.pyx', 'generalized_permutation.c' , 'lin_alg.c', 'quad_cover.c', 'random.c', 'permutation.c'],
'headers': ['lyapunov_exponents.h']
},
# this will not compile on sage < 8.0 (troubles with cysignals)
'integer_iet': {
'name': 'surface_dynamics.interval_exchanges.integer_iet',
'dir': 'interval_exchanges',
'sources': ['integer_iet.pyx', 'int_iet.c', 'int_vector.c'],
'headers': ['integer_iet.pxd', 'int_iet.h'],
},
# build iet_family only if pplpy is available
'iet_family': {
'name': 'surface_dynamics.interval_exchanges.iet_family',
'dir': 'interval_exchanges',
'sources': ['iet_family.pyx'],
'headers': [],
'condition': WITH_PPL
}
}
extensions = []
source_files = []
for name, data in extensions_data.items():
if data.get('condition', True):
print('Adding extension {}:\n sources = {}\n headers = {}'.format(data['name'], data['sources'], data['headers']))
full_dir = os.path.join('surface_dynamics', data['dir'])
sources = [os.path.join(full_dir, src) for src in data['sources']]
headers = [os.path.join(full_dir, data['dir'], head) for head in data['headers']]
extensions.append(Extension(data['name'], sources=sources, include_dirs=[full_dir, np.get_include()]))
sources = [os.path.join(data['dir'], src) for src in data['sources']]
headers = [os.path.join(data['dir'], head) for head in data['headers']]
source_files.extend(sources)
source_files.extend(headers)
# Work around changes in SageMath 9.7, see https://trac.sagemath.org/wiki/ReleaseTours/sage-9.7#Packagessagesage.rings...arenownamespaces
try:
from sage.misc.package_dir import cython_namespace_package_support
except (ImportError, ModuleNotFoundError):
from contextlib import nullcontext as cython_namespace_package_support
with cython_namespace_package_support():
extensions = cythonize(extensions)
setup(name='surface-dynamics',
version=version,
description="Dynamics on surfaces",
long_description=long_description,
long_description_content_type="text/markdown",
author='Vincent Delecroix',
author_email='[email protected]',
project_urls={
"Bug Tracker": "https://github.com/flatsurf/surface-dynamics/issues",
"Documentation": "https://flatsurf.github.io/surface-dynamics/",
"Source Code": "https://github.com/flatsurf/surface-dynamics",
},
license="GPL v2",
packages=['surface_dynamics',
'surface_dynamics/misc',
'surface_dynamics/topology',
'surface_dynamics/topological_recursion',
'surface_dynamics/flat_surfaces',
'surface_dynamics/databases',
'surface_dynamics/flat_surfaces/origamis',
'surface_dynamics/interval_exchanges'],
package_data={
'surface_dynamics': source_files,
'surface_dynamics/databases': ['cylinder_diagrams/cyl_diags*', 'generalized_permutation_twins/twins*'],
'surface_dynamics/flat_surfaces/origamis': ['origamis.db'],
},
ext_modules=extensions,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
'Operating System :: OS Independent',
'Programming Language :: C',
'Programming Language :: C++',
'Programming Language :: Python',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering :: Mathematics',
],
keywords='surfaces, dynamics, geometry, flat surfaces, Abelian differentials, quadratic differentials, Riemann surfaces')