-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
setup.py
139 lines (109 loc) · 3.78 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python Setuptools for Mathics core
For the easiest installation:
pip install -e .
For full installation:
pip install -e .[full]
This will install the library in the default location. For instructions on
how to customize the install procedure read the output of:
python setup.py --help install
In addition, there are some other commands:
python setup.py clean -> will clean all trash (*.pyc and stuff)
To get a full list of available commands, read the output of:
python setup.py --help-commands
"""
import logging
import os
import os.path as osp
import platform
import sys
from typing import List
from setuptools import Extension, setup
from setuptools.command.build_py import build_py as setuptools_build_py
log = logging.getLogger(__name__)
is_PyPy = platform.python_implementation() == "PyPy" or hasattr(
sys, "pypy_version_info"
)
def get_srcdir():
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
return osp.realpath(filename)
DEPENDENCY_LINKS: List[str] = []
# "http://github.com/Mathics3/mathics-scanner/tarball/master#egg=Mathics_Scanner-1.0.0.dev"
# ]
# What should be run through Cython?
EXTENSIONS = []
CMDCLASS = {}
try:
if is_PyPy:
raise ImportError
from Cython.Distutils import build_ext # type: ignore[import-not-found]
except ImportError:
pass
else:
if os.environ.get("USE_CYTHON", False):
log.info("Running Cython over code base")
EXTENSIONS_DICT = {
"core": (
"expression",
"symbols",
"number",
"rules",
"pattern",
),
"builtin": [
"arithmetic",
"patterns/basic",
"patterns/composite",
"patterns/defaults",
"patterns/restrictions",
"patterns/rules",
"graphics",
],
"eval": ("nevaluator", "makeboxes", "test"),
}
EXTENSIONS = [
Extension(
f"mathics.{parent}.{module}".replace("/", "."),
["mathics/%s/%s.py" % (parent, module)],
)
for parent, modules in EXTENSIONS_DICT.items()
for module in modules
]
# EXTENSIONS_SUBDIR_DICT = {
# "builtin": [("numbers", "arithmetic"), ("numbers", "numeric"), ("drawing", "graphics")],
# }
# EXTENSIONS.append(
# Extension(
# "mathics.%s.%s.%s" % (parent, module[0], module[1]), ["mathics/%s/%s/%s.py" % (parent, module[0], module[1])]
# )
# for parent, modules in EXTENSIONS_SUBDIR_DICT.items()
# for module in modules
# )
CMDCLASS = {"build_ext": build_ext}
class build_py(setuptools_build_py):
def run(self):
if not os.path.exists("mathics/data/op-tables.json"):
os.system(
"mathics3-generate-json-table"
" --field=ascii-operator-to-symbol"
" --field=ascii-operator-to-unicode"
" --field=ascii-operator-to-wl-unicode"
" --field=operator-to-ascii"
" --field=operator-to-unicode"
" -o mathics/data/op-tables.json"
)
if not os.path.exists("mathics/data/operator-tables.json"):
os.system(
"mathics3-generate-operator-json-table" " -o operator-tables.json"
)
self.distribution.package_data["mathics"].append("data/op-tables.json")
setuptools_build_py.run(self)
CMDCLASS["build_py"] = build_py
setup(
cmdclass=CMDCLASS,
ext_modules=EXTENSIONS,
dependency_links=DEPENDENCY_LINKS,
# don't pack Mathics in egg because of media files, etc.
zip_safe=False,
)