Skip to content

Commit c3edf3f

Browse files
authored
Convert to 9.0.0 API (#2)
Convert to 9.0.0 API. Add testing. Black and isort
1 parent 5309177 commit c3edf3f

File tree

11 files changed

+293
-73
lines changed

11 files changed

+293
-73
lines changed

.github/workflows/autoblack.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
2+
# If all Python code in the pull request is compliant with Black then this Action does nothing.
3+
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
4+
# https://github.com/cclauss/autoblack
5+
6+
name: autoblack
7+
on: [pull_request]
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.13
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: 3.13
17+
- name: Install click
18+
run: pip install 'click==8.0.4'
19+
- name: Install Black
20+
run: pip install 'black==25.1.0'
21+
- name: Run black --check .
22+
run: black --check .
23+
- name: If needed, commit black changes to the pull request
24+
if: failure()
25+
run: |
26+
black .
27+
git config --global user.name 'autoblack'
28+
git config --global user.email 'rocky@users.noreply.github.com'
29+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
30+
git checkout $GITHUB_HEAD_REF
31+
git commit -am "fixup: Format Python code with Black"
32+
git push
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
2+
# If all Python code in the pull request is compliant with Black then this Action does nothing.
3+
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
4+
# https://github.com/cclauss/autoblack
5+
6+
name: isort and black check
7+
on: [pull_request]
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.13
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: 3.13
17+
- name: Install click, black and isort
18+
run: pip install 'click==8.0.4' 'black==25.1.0' 'isort==5.13.2'
19+
- name: Run isort --check .
20+
run: isort --check .
21+
- name: Run black --check .
22+
run: black --check .
23+
# - name: If needed, commit black changes to the pull request
24+
# if: failure()
25+
# run: |
26+
# black .
27+
# git config --global user.name 'autoblack'
28+
# git config --global user.email 'rocky@users.noreply.github.com'
29+
# git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
30+
# git checkout $GITHUB_HEAD_REF
31+
# git commit -am "fixup: Format Python code with Black"
32+
# git push

.github/workflows/ubuntu.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Mathics3-Module-pyICU (ubuntu)
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: '**'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.12', '3.13']
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
sudo apt install libicu-dev
24+
python -m pip install --upgrade pip
25+
python -m pip install pytest
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+
- name: install Mathic3 PyICU Module
33+
run: |
34+
python -m pip install Mathics3 PyICU
35+
python -m pip install --no-build-isolation -e .
36+
- name: Test Mathics3 PyICU Module
37+
run: |
38+
make check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*~
22
.python-version
33
/ChangeLog
4+
/Mathics3_Module_PyICU.egg-info
45
/build
56
/dist
67
/pymathics_language.egg-info

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# A GNU Makefile to run various tasks - compatibility for us old-timers.
2+
3+
# Note: This makefile include remake-style target comments.
4+
# These comments before the targets start with #:
5+
# remake --tasks to shows the targets and the comments
6+
7+
GIT2CL ?= admin-tools/git2cl
8+
PYTHON ?= python3
9+
PIP ?= pip3
10+
RM ?= rm
11+
LANG = en
12+
13+
.PHONY: all build \
14+
check clean \
15+
develop dist doc doc-data \
16+
pypi-setup \
17+
pytest \
18+
rmChangeLog \
19+
test
20+
21+
#: Default target - same as "develop"
22+
all: develop
23+
24+
#: build everything needed to install
25+
build:
26+
$(PYTHON) ./setup.py build
27+
28+
#: Make PyPI distribution
29+
dist:
30+
./admin-tools/make-dist.sh
31+
32+
#: Check Python version, and install PyPI dependencies
33+
pypi-setup:
34+
$(PIP) install -e .
35+
36+
#: Set up to run from the source tree
37+
develop: pypi-setup
38+
$(PIP) install -e .
39+
40+
# Run tests
41+
check: pytest
42+
43+
#: Remove derived files
44+
clean: clean-pyc
45+
46+
#: Remove old PYC files
47+
clean-pyc:
48+
@find . -name "*.pyc" -type f -delete
49+
50+
#: Run py.test tests. Use environment variable "o" for pytest options
51+
pytest:
52+
pytest test $o
53+
54+
55+
# #: Make Mathics PDF manual
56+
# doc mathics.pdf: mathics/doc/tex/data
57+
# (cd mathics/doc/tex && $(MAKE) mathics.pdf)
58+
59+
#: Remove ChangeLog
60+
rmChangeLog:
61+
$(RM) ChangeLog || true
62+
63+
#: Create a ChangeLog from git via git log and git2cl
64+
ChangeLog: rmChangeLog
65+
git log --pretty --numstat --summary | $(GIT2CL) >$@
66+
patch ChangeLog < ChangeLog-spell-corrected.diff

pymathics/language/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
"""Pymathics Language
1+
"""Mathics3 Module PyICU
22
33
This module provides Mathics functions and varialbles to work with
4-
Lanugages and Translations
4+
Languages and Translations.
55
"""
66

7-
87
from pymathics.language.__main__ import Alphabet
98
from pymathics.language.version import __version__
109

pymathics/language/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
# PyICU: human-language alphabets and locales
1010

1111

12-
from icu import Locale, LocaleData
1312
from typing import List, Optional
1413

15-
from mathics.builtin.base import Builtin
14+
from icu import Locale, LocaleData
1615
from mathics.core.atoms import String
16+
from mathics.core.builtin import Builtin
1717
from mathics.core.convert.expression import to_mathics_list
1818

1919
availableLocales = Locale.getAvailableLocales()
@@ -27,6 +27,7 @@ def eval_alphabet(language_name: String) -> Optional[List[String]]:
2727

2828
py_language_name = language_name.value
2929
locale = language2locale.get(py_language_name, py_language_name)
30+
print(locale)
3031
if locale not in availableLocales:
3132
return
3233
alphabet_set = LocaleData(locale).getExemplarSet(0, 0)
@@ -70,7 +71,7 @@ class Alphabet(Builtin):
7071

7172
summary_text = "lowercase letters in an alphabet"
7273

73-
def apply(self, alpha: String, evaluation):
74+
def eval(self, alpha: String, evaluation):
7475
"""Alphabet[alpha_String]"""
7576
alphabet_list = eval_alphabet(alpha)
7677
if alphabet_list is None:

pymathics/language/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# well as importing into Python. That's why there is no
66
# space around "=" below.
77
# fmt: off
8-
__version__="5.0.0" # noqa
8+
__version__="9.0.0" # noqa

pyproject.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"Mathics3-Module-Base >= 9.0.0",
5+
"Mathics3>=9.0.0",
6+
"PyICU>=2.9",
7+
]
8+
build-backend = "setuptools.build_meta"
9+
10+
[project]
11+
name = "Mathics3-Module-PyICU"
12+
description = 'Mathics3 Hello, World! module'
13+
dependencies = [
14+
"Mathics3-Module-Base >= 9.0.0",
15+
"Mathics3 >= 9.0.0",
16+
"PyICU>=2.9",
17+
]
18+
requires-python = ">=3.10"
19+
readme = "README.rst"
20+
license = "GPL-3.0-or-later"
21+
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
22+
maintainers = [
23+
{name = "Mathics Group", email = "mathics-devel@googlegroups.com"},
24+
]
25+
classifiers = [
26+
"Intended Audience :: Developers",
27+
"Intended Audience :: Science/Research",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
33+
"Programming Language :: Python :: Implementation :: CPython",
34+
"Programming Language :: Python :: Implementation :: PyPy",
35+
"Topic :: Scientific/Engineering",
36+
"Topic :: Scientific/Engineering :: Mathematics",
37+
"Topic :: Software Development :: Interpreters",
38+
]
39+
dynamic = ["version"]
40+
41+
[project.urls]
42+
Homepage = "https://github.com/Mathics3/Mathics3-Module-PyICU"
43+
Downloads = "https://github.com/Mathics3/Mathics-Module-PyICU/releases"
44+
45+
[project.optional-dependencies]
46+
dev = [
47+
"pytest",
48+
]
49+
50+
[tool.setuptools]
51+
packages = [
52+
"pymathics.language",
53+
]
54+
55+
[tool.setuptools.dynamic]
56+
version = {attr = "pymathics.language.__version__"}

setup.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)