Skip to content

Commit b176302

Browse files
authored
Track mathics-scanner API changes (#96)
Track changes to the Mathics3 Scanner API for location information - need to bump Mathics-Scanner and Mathics-core minimum versions Drop Python 3.8 and start testing with 3.13
1 parent d978d16 commit b176302

File tree

6 files changed

+43
-47
lines changed

6 files changed

+43
-47
lines changed

.github/workflows/macos.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [macOS]
15-
python-version: ['3.9', '3.10', '3.11']
15+
python-version: ['3.10', '3.11', '3.12']
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
@@ -24,12 +24,10 @@ jobs:
2424
brew install asymptote
2525
python3 -m pip install --upgrade pip
2626
# Can comment out when next Mathics core and Mathics-scanner are released
27-
# python3 -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-op-tables.sh)
32-
python -m pip install Mathics3[full]
27+
git clone https://github.com/Mathics3/mathics-scanner
28+
(cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh)
29+
git clone https://github.com/Mathics3/mathics-core
30+
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full])
3331
- name: Install mathicsscript
3432
run: |
3533
make

.github/workflows/ubuntu.yml

Lines changed: 6 additions & 9 deletions
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.8', '3.9', '3.10', '3.11', '3.12']
14+
python-version: ['3.13', '3.9', '3.10', '3.11', '3.12']
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -22,14 +22,11 @@ jobs:
2222
run: |
2323
sudo apt-get update -qq && sudo apt-get install -qq liblapack-dev llvm-dev asymptote
2424
python3 -m pip install --upgrade pip
25-
# Can comment out 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-
# python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[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-op-tables.sh)
31-
# python -m pip install Mathics3[full]
32-
pip install -e .
25+
# We can comment out when next Mathics core and Mathics-scanner are released
26+
git clone https://github.com/Mathics3/mathics-scanner
27+
(cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh)
28+
git clone https://github.com/Mathics3/mathics-core
29+
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full])
3330
- name: Install mathicsscript
3431
run: |
3532
make

.github/workflows/windows.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [windows]
15-
python-version: ['3.10', '3.12']
15+
python-version: ['3.11', '3.12']
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Set up Python ${{ matrix.python-version }}
@@ -24,12 +24,12 @@ jobs:
2424
python3 -m pip install --upgrade pip
2525
python3 -m pip install wheel
2626
set LLVM_DIR="C:\Program Files\LLVM"
27-
# Can comment out when next Mathics core and Mathics-scanner are released
28-
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
29-
# git clone https://github.com/Mathics3/mathics-core
30-
# bash -c '(cd mathics-core && pip3 install -e .[full])'
31-
# bash -c '(cd mathics-core && bash ./admin-tools/make-op-tables.sh)'
32-
python -m pip install Mathics3[full]
27+
# We can comment out when next Mathics core and Mathics-scanner are released
28+
git clone https://github.com/Mathics3/mathics-scanner
29+
bash -c '(cd mathics-scanner && python -m pip install -e . && bash ./admin-tools/make-JSON-tables.sh)'
30+
git clone https://github.com/Mathics3/mathics-core
31+
bash -c '(cd mathics-core && ./admin-tools/make-JSON-tables.sh && python -m pip install -e .)'
32+
python -m pip install -e .
3333
- name: Install mathicsscript
3434
run: |
3535
make

mathicsscript/bindkeys.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2021-2022, 2024 Rocky Bernstein <[email protected]>
2+
# Copyright (C) 2021-2022, 2024-2025 Rocky Bernstein <[email protected]>
33
# This program is free software: you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
55
# the Free Software Foundation, either version 3 of the License, or
@@ -22,6 +22,8 @@
2222
from prompt_toolkit.enums import EditingMode
2323
from prompt_toolkit.key_binding import KeyBindings
2424
from prompt_toolkit.filters import Condition
25+
from sys import version_info
26+
import contextlib
2527
import pathlib
2628
import re
2729

@@ -144,7 +146,10 @@ def read_inputrc(read_init_file_fn: Callable, use_unicode: bool) -> None:
144146
# GNU Readline inputrc $include's paths are relative to itself,
145147
# so chdir to its directory before reading the file.
146148
parent_dir = pathlib.Path(__file__).parent.absolute()
147-
with parent_dir:
149+
path_context_fn = (
150+
parent_dir if version_info < (3, 11) else contextlib.chdir(parent_dir)
151+
)
152+
with path_context_fn:
148153
inputrc = "inputrc-unicode" if use_unicode else "inputrc-no-unicode"
149154
try:
150155
read_init_file_fn(str(parent_dir / "data" / inputrc))

mathicsscript/termshell.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
# -*- coding: utf-8 -*-
22
# Copyright (C) 2020-2022, 2024, 2025 Rocky Bernstein <[email protected]>
33

4-
from columnize import columnize
5-
64
import locale
75
import os
86
import os.path as osp
97
import pathlib
108
import sys
11-
129
from typing import Optional
1310

14-
from mathics_pygments.lexer import MathematicaLexer, MToken
11+
import mathics_scanner.location
1512

13+
from colorama import init as colorama_init
14+
from columnize import columnize
1615
from mathics.core.atoms import String, Symbol
1716
from mathics.core.attributes import attribute_string_to_number
18-
from mathics.core.expression import (
19-
Expression,
20-
# strip_context,
21-
from_python,
22-
)
17+
from mathics.core.expression import Expression, from_python # strip_context,
2318
from mathics.core.rules import Rule
2419
from mathics.core.symbols import SymbolNull
2520
from mathics.core.systemsymbols import SymbolMessageName
21+
from mathics_scanner.location import ContainerKind
2622
from mathics.session import get_settings_value, set_settings_value
27-
23+
from mathics_pygments.lexer import MathematicaLexer, MToken
2824
from pygments import format, highlight, lex
29-
from pygments.formatters.terminal import TERMINAL_COLORS
3025
from pygments.formatters import Terminal256Formatter
26+
from pygments.formatters.terminal import TERMINAL_COLORS
3127
from pygments.styles import get_all_styles
3228
from pygments.util import ClassNotFound
3329

30+
# FIXME: __main__ shouldn't be needed. Fix term_background
31+
from term_background.__main__ import is_dark_background
32+
3433
mma_lexer = MathematicaLexer()
3534

3635
ALL_PYGMENTS_STYLES = list(get_all_styles())
@@ -41,11 +40,6 @@
4140
color_scheme[MToken.OPERATOR] = ("magenta", "ansibrightmagenta")
4241
color_scheme[MToken.NUMBER] = ("ansiblue", "ansibrightblue")
4342

44-
from colorama import init as colorama_init
45-
46-
# FIXME: __main__ shouldn't be needed. Fix term_background
47-
from term_background.__main__ import is_dark_background
48-
4943
# Set up mathicsscript configuration directory
5044
CONFIGHOME = os.environ.get("XDG_CONFIG_HOME", osp.expanduser("~/.config"))
5145
CONFIGDIR = osp.join(CONFIGHOME, "mathicsscript")
@@ -86,11 +80,11 @@ def __init__(
8680
self,
8781
definitions,
8882
style: Optional[str],
89-
want_completion: bool,
83+
_: bool,
9084
use_unicode: bool,
9185
prompt: bool,
9286
):
93-
super().__init__("<stdin>")
87+
super().__init__([], ContainerKind.STREAM)
9488
self.input_encoding = locale.getpreferredencoding()
9589
self.lineno = 0
9690
self.terminal_formatter = None
@@ -284,6 +278,8 @@ def reset_lineno(self):
284278
def feed(self):
285279
prompt_str = self.get_in_prompt() if self.prompt else ""
286280
result = self.read_line(prompt_str) + "\n"
281+
if mathics_scanner.location.TRACK_LOCATIONS:
282+
self.container.append(self.source_text)
287283
if result == "\n":
288284
return "" # end of input
289285
self.lineno += 1

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ build-backend = "setuptools.build_meta"
1111
name = "mathicsscript"
1212
description = "Command-line interface to Mathics3"
1313
dependencies = [
14-
"Mathics_Scanner>=1.4.1",
15-
"Mathics3 >= 8.0.0",
14+
"Mathics_Scanner>1.4.1",
15+
"Mathics3 >= 8.0.1",
1616
"click",
1717
"colorama",
1818
"columnize",
@@ -22,7 +22,7 @@ dependencies = [
2222
"mathics_pygments>=1.0.2",
2323
"term-background >= 1.0.1",
2424
]
25-
requires-python = ">=3.8"
25+
requires-python = ">=3.9"
2626
readme = "README.rst"
2727
license = {text = "GPL-3.0-only"}
2828
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
@@ -34,11 +34,11 @@ classifiers = [
3434
"Intended Audience :: Science/Research",
3535
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
3636
"Programming Language :: Python",
37-
"Programming Language :: Python :: 3.8",
3837
"Programming Language :: Python :: 3.9",
3938
"Programming Language :: Python :: 3.10",
4039
"Programming Language :: Python :: 3.11",
4140
"Programming Language :: Python :: 3.12",
41+
"Programming Language :: Python :: 3.13",
4242
"Programming Language :: Python :: Implementation :: CPython",
4343
"Programming Language :: Python :: Implementation :: PyPy",
4444
"Topic :: Scientific/Engineering",

0 commit comments

Comments
 (0)