Skip to content

Commit 6296cc6

Browse files
committed
Revise to use pyproject
1 parent 0eac512 commit 6296cc6

File tree

6 files changed

+104
-90
lines changed

6 files changed

+104
-90
lines changed

.github/workflows/consistency-checks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ['3.10']
14+
python-version: ['3.12']
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -27,6 +27,7 @@ jobs:
2727
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
2828
(cd src/mathics3 && bash ./admin-tools/make-JSON-tables.sh)
2929
# python -m pip install Mathics3[full]
30+
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
3031
- name: Install Pymathics.natlang
3132
run: |
3233
make develop

.github/workflows/osx.yml-needs-enchant-fixup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ master ]
66
pull_request:
7-
branches: '**'
7+
branches: [ master ]
88

99
jobs:
1010
build:

.github/workflows/ubuntu.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
# python-version: ['3.9', '3.10'] # Figure out what's wrong here.
15-
python-version: ['3.9', '3.10', '3.11']
14+
python-version: ['3.9', '3.10', '3.13']
1615
steps:
1716
- uses: actions/checkout@v4
1817
- name: Set up Python ${{ matrix.python-version }}
@@ -21,15 +20,15 @@ jobs:
2120
python-version: ${{ matrix.python-version }}
2221
- name: Install dependencies
2322
run: |
24-
# python -m pip install --upgrade pip
23+
python -m pip install --upgrade pip
2524
python -m pip install pytest
26-
# Can comment out when next Mathics3 core and Mathics-scanner are released
27-
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
28-
# python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
29-
# git clone https://github.com/Mathics3/mathics-core
30-
# (cd mathics-core && pip3 install -e .[full])
31-
# (cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
32-
python -m pip install Mathics3[full]
25+
# Go over and comment out stuff when next Mathics core and Mathics-scanner are released
26+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
27+
git clone https://github.com/Mathics3/mathics-core
28+
(cd mathics-core && pip3 install -e .[full])
29+
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
30+
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
31+
python -m pip install -e .
3332
- name: install pymathics natlang
3433
run: |
3534
make develop

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
/ChangeLog-spell-corrected
55
/ChangeLog.orig
66
/ChangeLog.rej
7+
/ChangeLog.spell-corrected
8+
/Mathics3_natlang.egg-info
79
/build
810
/dist
911
/pymathics_natlang.egg-info

pyproject.toml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=70.0.0", # CVE-2024-38335 recommends this
4+
"sympy>=1.11,<1.13",
5+
"PatternLite",
6+
"langid", # replace with a supported newer package, e.g. via spacy
7+
"matplotlib",
8+
"mpmath>=1.2.0",
9+
"numpy",
10+
"pycountry>=3.2.0",
11+
"pyenchant>=3.2.0",
12+
"scipy>=1.10.0",
13+
"spacy>=3.4",
14+
"wasabi<1.1.0,>=0.8.2",
15+
]
16+
build-backend = "setuptools.build_meta"
17+
18+
[project]
19+
name = "Mathics3-natlang"
20+
description = "Mathics3 Natural Language Toolkit module"
21+
dependencies = [
22+
"Mathics3>=8.0.1",
23+
"Mathics3-Module-Base",
24+
"click>=8.0",
25+
"joblib>=1.0.1",
26+
"langid", # replace with a supported newer package, e.g. via spacy
27+
"llvmlite>=0.36",
28+
"nltk>=3.8.0",
29+
"PatternLite",
30+
"pyenchant>=3.2.0",
31+
"pycountry>=3.2.0",
32+
"spacy>=3.4",
33+
"wasabi<1.1.0,>=0.8.2",
34+
]
35+
requires-python = ">=3.9"
36+
readme = "README.rst"
37+
license = {text = "GPL"}
38+
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
39+
maintainers = [
40+
{name = "Mathics Group", email = "mathics-devel@googlegroups.com"},
41+
]
42+
classifiers = [
43+
"Intended Audience :: Developers",
44+
"Intended Audience :: Science/Research",
45+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
46+
"Programming Language :: Python",
47+
"Programming Language :: Python :: 3.9",
48+
"Programming Language :: Python :: 3.10",
49+
"Programming Language :: Python :: 3.11",
50+
"Programming Language :: Python :: 3.12",
51+
"Programming Language :: Python :: 3.13",
52+
"Programming Language :: Python :: Implementation :: CPython",
53+
"Programming Language :: Python :: Implementation :: PyPy",
54+
"Topic :: Scientific/Engineering",
55+
"Topic :: Scientific/Engineering :: Mathematics",
56+
"Topic :: Software Development :: Interpreters",
57+
]
58+
dynamic = ["version"]
59+
60+
[project.urls]
61+
Homepage = "https://github.com/Mathics3/pymathics-natlang"
62+
Downloads = "https://github.com/Mathics3/pymathics-natlang/releases"
63+
64+
[project.optional-dependencies]
65+
dev = [
66+
"pytest",
67+
]
68+
69+
[tool.setuptools]
70+
packages = [
71+
"pymathics.natlang",
72+
]
73+
74+
[tool.setuptools.dynamic]
75+
version = {attr = "pymathics.natlang.__version__"}

setup.py

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,10 @@
1-
#!/usr/bin/env python
21
# -*- coding: utf-8 -*-
32

43
import os
5-
import os.path as osp
6-
import platform
74
import sys
85

9-
from setuptools import find_namespace_packages, setup
10-
11-
# Ensure user has the correct Python version
12-
if sys.version_info < (3, 8):
13-
print("Mathics support Python 3.8 and above; you have %d.%d" % sys.version_info[:2])
14-
sys.exit(-1)
15-
16-
17-
def get_srcdir():
18-
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
19-
return osp.realpath(filename)
20-
21-
22-
def read(*rnames):
23-
return open(osp.join(get_srcdir(), *rnames)).read()
24-
25-
26-
# Get/set VERSION and long_description from files
27-
long_description = read("README.rst") + "\n"
28-
29-
__version__ = "0.0.0" # overwritten by exec below
30-
31-
# stores __version__ in the current namespace
32-
exec(compile(open("pymathics/natlang/version.py").read(), "version.py", "exec"))
33-
34-
is_PyPy = platform.python_implementation() == "PyPy"
35-
36-
# Install a wordlist.
37-
# Environment variables "lang", "WORDLIST_SIZE", and "SPACY_DOWNLOAD" override defaults.
6+
from setuptools import setup
7+
from setuptools.command.egg_info import egg_info
388

399
# Full package name with two-letter language code, e.g. fr, zh
4010
lang = os.environ.get("lang", "en_core_web_md")
@@ -43,56 +13,23 @@ def read(*rnames):
4313
# sm=small, lg=large, md=medium.
4414
WORDLIST_SIZE = os.environ.get("WORDLIST_SIZE", "md")
4515

46-
SPACY_DOWNLOAD = os.environ.get("SPACY_DOWNLOAD", "%s" % (lang,))
16+
SPACY_DOWNLOAD = os.environ.get("SPACY_DOWNLOAD", lang)
17+
18+
19+
class CustomCommands(egg_info):
20+
"""This runs as part of building an sdist"""
21+
22+
def finalize_options(self):
23+
"""Run program to create JSON tables"""
24+
os.system(f"{sys.executable} -m spacy download {lang}")
25+
os.system(f"{sys.executable} -m nltk.downloader 'wordnet2022 omw")
26+
super().finalize_options()
27+
4728

4829
# FIXME:
4930
# consider using langid3 and pyenchant
5031

5132
setup(
52-
name="pymathics-natlang",
53-
version=__version__,
54-
packages=find_namespace_packages(include=["pymathics.*"]),
55-
install_requires=[
56-
"Mathics3>=8.0.0",
57-
"click>=8.0",
58-
"joblib>=1.0.1",
59-
"langid", # replace with a supported newer package, e.g. via spacy
60-
"llvmlite>=0.36",
61-
"nltk>=3.8.0",
62-
"PatternLite",
63-
"pyenchant>=3.2.0",
64-
"pycountry>=3.2.0",
65-
"spacy>=3.4",
66-
"wasabi<1.1.0,>=0.8.2",
67-
],
33+
cmdclass={"egg_info": CustomCommands},
6834
zip_safe=False,
69-
maintainer="Mathics3 Group",
70-
maintainer_email="rb@dustyfeet.com",
71-
long_description=long_description,
72-
long_description_content_type="text/x-rst",
73-
# metadata for upload to PyPI
74-
classifiers=[
75-
"Intended Audience :: Developers",
76-
"Intended Audience :: Science/Research",
77-
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
78-
"Programming Language :: Python",
79-
"Programming Language :: Python :: 3.8",
80-
"Programming Language :: Python :: 3.9",
81-
"Programming Language :: Python :: 3.10",
82-
"Programming Language :: Python :: 3.11",
83-
"Programming Language :: Python :: 3.12",
84-
"Programming Language :: Python :: Implementation :: CPython",
85-
"Programming Language :: Python :: Implementation :: PyPy",
86-
"Topic :: Scientific/Engineering",
87-
"Topic :: Scientific/Engineering :: Mathematics",
88-
"Topic :: Scientific/Engineering :: Physics",
89-
"Topic :: Software Development :: Interpreters",
90-
"Topic :: Scientific/Engineering :: Human Machine Interfaces",
91-
"Topic :: Text Processing",
92-
"Topic :: Text Processing :: Linguistic",
93-
],
94-
# TODO: could also include long_description, download_url,
9535
)
96-
97-
os.system("%s -m spacy download %s" % (sys.executable, lang))
98-
os.system("%s -m nltk.downloader 'wordnet2022 omw" % sys.executable)

0 commit comments

Comments
 (0)