-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.py
executable file
·88 lines (79 loc) · 3.46 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
"""
Setup script for the surface-dynamics package.
This script defines the compilation of the .pyx files into extension modules
which cannot be configured in pyproject.toml yet.
"""
# ****************************************************************************
# Copyright (C) 2024 Julian Rüth
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
import numpy
from Cython.Build import cythonize
from setuptools import setup, Extension
# 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
# NOTE: When adding files here, make sure to duplicate the list in the inputs
# of the build task in pyproject.toml.
extensions = [
Extension(
"surface_dynamics.flat_surfaces.origamis.origami_dense",
sources=[
"surface_dynamics/flat_surfaces/origamis/origami_dense.pyx",
"surface_dynamics/flat_surfaces/origamis/normal_form.c",
"surface_dynamics/flat_surfaces/origamis/lyapunov_exponents.c",
],
include_dirs=[numpy.get_include(), "surface_dynamics/flat_surfaces/origamis"],
),
Extension(
"surface_dynamics.interval_exchanges.lyapunov_exponents",
sources=[
"surface_dynamics/interval_exchanges/lyapunov_exponents.pyx",
"surface_dynamics/interval_exchanges/generalized_permutation.c",
"surface_dynamics/interval_exchanges/lin_alg.c",
"surface_dynamics/interval_exchanges/quad_cover.c",
"surface_dynamics/interval_exchanges/random.c",
"surface_dynamics/interval_exchanges/permutation.c",
],
include_dirs=[numpy.get_include()],
),
Extension(
"surface_dynamics.interval_exchanges.integer_iet",
sources=[
"surface_dynamics/interval_exchanges/integer_iet.pyx",
"surface_dynamics/interval_exchanges/int_iet.c",
"surface_dynamics/interval_exchanges/int_vector.c",
],
include_dirs=[numpy.get_include()],
)
]
try:
import ppl as _
except ImportError:
import sys
print('Warning: pplpy not installed. Will not compile iet_family.', file=sys.stderr)
else:
extensions.append(Extension(
"surface_dynamics.interval_exchanges.iet_family",
sources=[
"surface_dynamics/interval_exchanges/iet_family.pyx",
],
include_dirs=[numpy.get_include()],
))
# Work around changes in SageMath 9.7, see
# https://trac.sagemath.org/wiki/ReleaseTours/sage-9.7#Packagessagesage.rings...arenownamespaces,
# i.e., work around import errors with Cython <3. This is also the reason we
# cannot currently build with meson.
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():
# We force cythonization since Cython caching does not catch when we switch between different versions of SageMath otherwise.
extensions = cythonize(extensions, force=True, compiler_directives={"language_level": "3"})
setup(ext_modules=extensions)