Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.py: Build op-tables.json as part of "build_py" #1034

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 7 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[build-system]
requires = [
"setuptools>=61.2",
"cython>=0.15.1; implementation_name!='pypy'"
"cython>=0.15.1; implementation_name!='pypy'",
# For mathics-generate-json-table
"Mathics-Scanner >= 1.3.0",
]
build-backend = "setuptools.build_meta"

[project]
name = "Mathics3"
Expand Down Expand Up @@ -76,46 +79,9 @@ mathics = "mathics.main:main"

[tool.setuptools]
include-package-data = false
packages = [
"mathics",
"mathics.algorithm",
"mathics.compile",
"mathics.core",
"mathics.core.convert",
"mathics.core.parser",
"mathics.builtin",
"mathics.builtin.arithfns",
"mathics.builtin.assignments",
"mathics.builtin.atomic",
"mathics.builtin.binary",
"mathics.builtin.box",
"mathics.builtin.colors",
"mathics.builtin.distance",
"mathics.builtin.exp_structure",
"mathics.builtin.drawing",
"mathics.builtin.fileformats",
"mathics.builtin.files_io",
"mathics.builtin.forms",
"mathics.builtin.functional",
"mathics.builtin.image",
"mathics.builtin.intfns",
"mathics.builtin.list",
"mathics.builtin.matrices",
"mathics.builtin.numbers",
"mathics.builtin.numpy_utils",
"mathics.builtin.pymimesniffer",
"mathics.builtin.pympler",
"mathics.builtin.quantum_mechanics",
"mathics.builtin.scipy_utils",
"mathics.builtin.specialfns",
"mathics.builtin.statistics",
"mathics.builtin.string",
"mathics.builtin.testing_expressions",
"mathics.builtin.vectors",
"mathics.eval",
"mathics.doc",
"mathics.format",
]

[tool.setuptools.packages.find]
include = ["mathics*"]

[tool.setuptools.package-data]
"mathics" = [
Expand Down
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys

from setuptools import Extension, setup
from setuptools.command.build_py import build_py as setuptools_build_py

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -97,6 +98,25 @@ def get_srcdir():
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(
"mathics-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"
)
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,
Expand Down
Loading