Skip to content
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
32 changes: 32 additions & 0 deletions .github/workflows/autoblack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
# If all Python code in the pull request is compliant with Black then this Action does nothing.
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
# https://github.com/cclauss/autoblack

name: autoblack
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install click
run: pip install 'click==8.0.4'
- name: Install Black
run: pip install 'black==25.1.0'
- name: Run black --check .
run: black --check .
- name: If needed, commit black changes to the pull request
if: failure()
run: |
black .
git config --global user.name 'autoblack'
git config --global user.email 'rocky@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: Format Python code with Black"
git push
32 changes: 32 additions & 0 deletions .github/workflows/isort-and-black-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
# If all Python code in the pull request is compliant with Black then this Action does nothing.
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
# https://github.com/cclauss/autoblack

name: isort and black check
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install click, black and isort
run: pip install 'click==8.0.4' 'black==25.1.0' 'isort==5.13.2'
- name: Run isort --check .
run: isort --check .
- name: Run black --check .
run: black --check .
# - name: If needed, commit black changes to the pull request
# if: failure()
# run: |
# black .
# git config --global user.name 'autoblack'
# git config --global user.email 'rocky@users.noreply.github.com'
# git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
# git checkout $GITHUB_HEAD_REF
# git commit -am "fixup: Format Python code with Black"
# git push
38 changes: 38 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Mathics3-Module-pyICU (ubuntu)

on:
push:
branches: [ master ]
pull_request:
branches: '**'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install libicu-dev
python -m pip install --upgrade pip
python -m pip install pytest
# # Go over and comment out stuff when next Mathics core and Mathics-scanner are released
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
# git clone https://github.com/Mathics3/mathics-core
# (cd mathics-core && pip3 install -e .[full])
# (cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
# python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
- name: install Mathic3 PyICU Module
run: |
python -m pip install Mathics3 PyICU
python -m pip install --no-build-isolation -e .
- name: Test Mathics3 PyICU Module
run: |
make check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*~
.python-version
/ChangeLog
/Mathics3_Module_PyICU.egg-info
/build
/dist
/pymathics_language.egg-info
Expand Down
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# A GNU Makefile to run various tasks - compatibility for us old-timers.

# Note: This makefile include remake-style target comments.
# These comments before the targets start with #:
# remake --tasks to shows the targets and the comments

GIT2CL ?= admin-tools/git2cl
PYTHON ?= python3
PIP ?= pip3
RM ?= rm
LANG = en

.PHONY: all build \
check clean \
develop dist doc doc-data \
pypi-setup \
pytest \
rmChangeLog \
test

#: Default target - same as "develop"
all: develop

#: build everything needed to install
build:
$(PYTHON) ./setup.py build

#: Make PyPI distribution
dist:
./admin-tools/make-dist.sh

#: Check Python version, and install PyPI dependencies
pypi-setup:
$(PIP) install -e .

#: Set up to run from the source tree
develop: pypi-setup
$(PIP) install -e .

# Run tests
check: pytest

#: Remove derived files
clean: clean-pyc

#: Remove old PYC files
clean-pyc:
@find . -name "*.pyc" -type f -delete

#: Run py.test tests. Use environment variable "o" for pytest options
pytest:
pytest test $o


# #: Make Mathics PDF manual
# doc mathics.pdf: mathics/doc/tex/data
# (cd mathics/doc/tex && $(MAKE) mathics.pdf)

#: Remove ChangeLog
rmChangeLog:
$(RM) ChangeLog || true

#: Create a ChangeLog from git via git log and git2cl
ChangeLog: rmChangeLog
git log --pretty --numstat --summary | $(GIT2CL) >$@
patch ChangeLog < ChangeLog-spell-corrected.diff
5 changes: 2 additions & 3 deletions pymathics/language/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Pymathics Language
"""Mathics3 Module PyICU

This module provides Mathics functions and varialbles to work with
Lanugages and Translations
Languages and Translations.
"""


from pymathics.language.__main__ import Alphabet
from pymathics.language.version import __version__

Expand Down
7 changes: 4 additions & 3 deletions pymathics/language/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# PyICU: human-language alphabets and locales


from icu import Locale, LocaleData
from typing import List, Optional

from mathics.builtin.base import Builtin
from icu import Locale, LocaleData
from mathics.core.atoms import String
from mathics.core.builtin import Builtin
from mathics.core.convert.expression import to_mathics_list

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

py_language_name = language_name.value
locale = language2locale.get(py_language_name, py_language_name)
print(locale)
if locale not in availableLocales:
return
alphabet_set = LocaleData(locale).getExemplarSet(0, 0)
Expand Down Expand Up @@ -70,7 +71,7 @@ class Alphabet(Builtin):

summary_text = "lowercase letters in an alphabet"

def apply(self, alpha: String, evaluation):
def eval(self, alpha: String, evaluation):
"""Alphabet[alpha_String]"""
alphabet_list = eval_alphabet(alpha)
if alphabet_list is None:
Expand Down
2 changes: 1 addition & 1 deletion pymathics/language/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# well as importing into Python. That's why there is no
# space around "=" below.
# fmt: off
__version__="5.0.0" # noqa
__version__="9.0.0" # noqa
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]
requires = [
"setuptools",
"Mathics3-Module-Base >= 9.0.0",
"Mathics3>=9.0.0",
"PyICU>=2.9",
]
build-backend = "setuptools.build_meta"

[project]
name = "Mathics3-Module-PyICU"
description = 'Mathics3 Hello, World! module'
dependencies = [
"Mathics3-Module-Base >= 9.0.0",
"Mathics3 >= 9.0.0",
"PyICU>=2.9",
]
requires-python = ">=3.10"
readme = "README.rst"
license = "GPL-3.0-or-later"
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
maintainers = [
{name = "Mathics Group", email = "mathics-devel@googlegroups.com"},
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Software Development :: Interpreters",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Mathics3/Mathics3-Module-PyICU"
Downloads = "https://github.com/Mathics3/Mathics-Module-PyICU/releases"

[project.optional-dependencies]
dev = [
"pytest",
]

[tool.setuptools]
packages = [
"pymathics.language",
]

[tool.setuptools.dynamic]
version = {attr = "pymathics.language.__version__"}
66 changes: 0 additions & 66 deletions setup.py

This file was deleted.

Loading