Skip to content

Commit b9f34e1

Browse files
authored
Revise to use pyproject (#33)
* Revise to use pyproject * Try to get OSX CI working again * Give up on addressing OSX enchant issue * pattern.en is now pattern.text.en * Remove Python 3.9 support
1 parent 0eac512 commit b9f34e1

File tree

7 files changed

+121
-107
lines changed

7 files changed

+121
-107
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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@ on:
99
jobs:
1010
build:
1111
env:
12-
LDFLAGS: "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lunwind"
13-
CPPFLAGS; "-I/opt/homebrew/opt/llvm/include"
12+
LDFLAGS: "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/unwind -lunwind"
13+
CPPFLAGS: "-I/opt/homebrew/opt/llvm/include"
1414
runs-on: macos-latest
1515
strategy:
1616
matrix:
1717
os: [macOS]
18-
python-version: ['3.9']
18+
python-version: ['3.13']
1919
steps:
2020
- uses: actions/checkout@v4
2121
- name: Set up Python ${{ matrix.python-version }}
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
25-
- name: Install OS dependencies
25+
- name: Install dependencies
2626
run: |
27-
brew install llvm tesseract enchant mysql
27+
brew update
28+
brew install llvm lld tesseract enchant mysql
2829
python -m pip install --upgrade pip
2930
pip install pytest pyenchant
30-
PYENCHANT_VERBOSE_FIND=1 python -c 'import enchant'
31-
32-
# Can comment out when next Mathics core and Mathics-scanner are released
33-
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
34-
# Can remove after next Mathics-core release
35-
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
36-
(cd src/mathics3 && bash ./admin-tools/make-op-tables.sh)
37-
# python -m pip install Mathics3[full]
38-
- name: Install pymathics.natlang
31+
# Go over and comment out stuff when next Mathics core and Mathics-scanner are released
32+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
33+
git clone https://github.com/Mathics3/mathics-core
34+
(cd mathics-core && pip3 install -e .[full])
35+
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
36+
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
37+
python -m pip install -e .
38+
- name: Install Mathics3 natlang Module
3939
run: |
4040
make develop
4141
- name: Test natlang

.github/workflows/ubuntu.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pymathics.natlang (ubuntu)
1+
name: pymathics.natlang (Ubuntu)
22

33
on:
44
push:
@@ -11,8 +11,8 @@ 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+
# 3.9 works but it takes a long time to gather dependencies
15+
python-version: ['3.10', '3.11', '3.12', '3.13']
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
@@ -21,18 +21,18 @@ jobs:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24-
# python -m pip install --upgrade pip
24+
python -m pip install --upgrade pip
2525
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]
33-
- name: install pymathics natlang
26+
# Go over and comment out stuff when next Mathics core and Mathics-scanner are released
27+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
28+
git clone https://github.com/Mathics3/mathics-core
29+
(cd mathics-core && pip3 install -e .[full])
30+
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
31+
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
32+
python -m pip install -e .
33+
- name: Install Mathics3 natlang Module
3434
run: |
3535
make develop
36-
- name: Test natlang
36+
- name: Test natlang Mathics3 Module
3737
run: |
3838
make -j3 check

.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

pymathics/natlang/nltk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from itertools import chain
88

99
import nltk
10-
from pattern.en import lexeme, pluralize
10+
from pattern.text.en import lexeme, pluralize
1111

1212
from mathics.builtin.codetables import iso639_3
1313
from mathics.core.atoms import String

pyproject.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
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.10"
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.10",
48+
"Programming Language :: Python :: 3.11",
49+
"Programming Language :: Python :: 3.12",
50+
"Programming Language :: Python :: 3.13",
51+
"Programming Language :: Python :: Implementation :: CPython",
52+
"Programming Language :: Python :: Implementation :: PyPy",
53+
"Topic :: Scientific/Engineering",
54+
"Topic :: Scientific/Engineering :: Mathematics",
55+
"Topic :: Software Development :: Interpreters",
56+
]
57+
dynamic = ["version"]
58+
59+
[project.urls]
60+
Homepage = "https://github.com/Mathics3/pymathics-natlang"
61+
Downloads = "https://github.com/Mathics3/pymathics-natlang/releases"
62+
63+
[project.optional-dependencies]
64+
dev = [
65+
"pytest",
66+
]
67+
68+
[tool.setuptools]
69+
packages = [
70+
"pymathics.natlang",
71+
]
72+
73+
[tool.setuptools.dynamic]
74+
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)