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
12 changes: 5 additions & 7 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [macOS]
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -24,12 +24,10 @@ jobs:
brew install asymptote
python3 -m pip install --upgrade pip
# Can comment out when next Mathics core and Mathics-scanner are released
# python3 -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
# python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
# git clone https://github.com/Mathics3/mathics-core
# (cd mathics-core && pip3 install -e .[full])
# (cd mathics-core && bash ./admin-tools/make-op-tables.sh)
python -m pip install Mathics3[full]
git clone https://github.com/Mathics3/mathics-scanner
(cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh)
git clone https://github.com/Mathics3/mathics-core
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full])
- name: Install mathicsscript
run: |
make
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.13', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -22,14 +22,11 @@ jobs:
run: |
sudo apt-get update -qq && sudo apt-get install -qq liblapack-dev llvm-dev asymptote
python3 -m pip install --upgrade pip
# Can comment out 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]
# python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
# git clone https://github.com/Mathics3/mathics-core
# (cd mathics-core && pip3 install -e .[full])
# (cd mathics-core && bash ./admin-tools/make-op-tables.sh)
# python -m pip install Mathics3[full]
pip install -e .
# We can comment out when next Mathics core and Mathics-scanner are released
git clone https://github.com/Mathics3/mathics-scanner
(cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh)
git clone https://github.com/Mathics3/mathics-core
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full])
- name: Install mathicsscript
run: |
make
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [windows]
python-version: ['3.10', '3.12']
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -24,12 +24,12 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install wheel
set LLVM_DIR="C:\Program Files\LLVM"
# Can comment out 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
# bash -c '(cd mathics-core && pip3 install -e .[full])'
# bash -c '(cd mathics-core && bash ./admin-tools/make-op-tables.sh)'
python -m pip install Mathics3[full]
# We can comment out when next Mathics core and Mathics-scanner are released
git clone https://github.com/Mathics3/mathics-scanner
bash -c '(cd mathics-scanner && python -m pip install -e . && bash ./admin-tools/make-JSON-tables.sh)'
git clone https://github.com/Mathics3/mathics-core
bash -c '(cd mathics-core && ./admin-tools/make-JSON-tables.sh && python -m pip install -e .)'
python -m pip install -e .
- name: Install mathicsscript
run: |
make
Expand Down
9 changes: 7 additions & 2 deletions mathicsscript/bindkeys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021-2022, 2024 Rocky Bernstein <[email protected]>
# Copyright (C) 2021-2022, 2024-2025 Rocky Bernstein <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand All @@ -22,6 +22,8 @@
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.filters import Condition
from sys import version_info
import contextlib
import pathlib
import re

Expand Down Expand Up @@ -144,7 +146,10 @@ def read_inputrc(read_init_file_fn: Callable, use_unicode: bool) -> None:
# GNU Readline inputrc $include's paths are relative to itself,
# so chdir to its directory before reading the file.
parent_dir = pathlib.Path(__file__).parent.absolute()
with parent_dir:
path_context_fn = (
parent_dir if version_info < (3, 11) else contextlib.chdir(parent_dir)
)
with path_context_fn:
inputrc = "inputrc-unicode" if use_unicode else "inputrc-no-unicode"
try:
read_init_file_fn(str(parent_dir / "data" / inputrc))
Expand Down
32 changes: 14 additions & 18 deletions mathicsscript/termshell.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2020-2022, 2024, 2025 Rocky Bernstein <[email protected]>

from columnize import columnize

import locale
import os
import os.path as osp
import pathlib
import sys

from typing import Optional

from mathics_pygments.lexer import MathematicaLexer, MToken
import mathics_scanner.location

from colorama import init as colorama_init
from columnize import columnize
from mathics.core.atoms import String, Symbol
from mathics.core.attributes import attribute_string_to_number
from mathics.core.expression import (
Expression,
# strip_context,
from_python,
)
from mathics.core.expression import Expression, from_python # strip_context,
from mathics.core.rules import Rule
from mathics.core.symbols import SymbolNull
from mathics.core.systemsymbols import SymbolMessageName
from mathics_scanner.location import ContainerKind
from mathics.session import get_settings_value, set_settings_value

from mathics_pygments.lexer import MathematicaLexer, MToken
from pygments import format, highlight, lex
from pygments.formatters.terminal import TERMINAL_COLORS
from pygments.formatters import Terminal256Formatter
from pygments.formatters.terminal import TERMINAL_COLORS
from pygments.styles import get_all_styles
from pygments.util import ClassNotFound

# FIXME: __main__ shouldn't be needed. Fix term_background
from term_background.__main__ import is_dark_background

mma_lexer = MathematicaLexer()

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

from colorama import init as colorama_init

# FIXME: __main__ shouldn't be needed. Fix term_background
from term_background.__main__ import is_dark_background

# Set up mathicsscript configuration directory
CONFIGHOME = os.environ.get("XDG_CONFIG_HOME", osp.expanduser("~/.config"))
CONFIGDIR = osp.join(CONFIGHOME, "mathicsscript")
Expand Down Expand Up @@ -86,11 +80,11 @@ def __init__(
self,
definitions,
style: Optional[str],
want_completion: bool,
_: bool,
use_unicode: bool,
prompt: bool,
):
super().__init__("<stdin>")
super().__init__([], ContainerKind.STREAM)
self.input_encoding = locale.getpreferredencoding()
self.lineno = 0
self.terminal_formatter = None
Expand Down Expand Up @@ -284,6 +278,8 @@ def reset_lineno(self):
def feed(self):
prompt_str = self.get_in_prompt() if self.prompt else ""
result = self.read_line(prompt_str) + "\n"
if mathics_scanner.location.TRACK_LOCATIONS:
self.container.append(self.source_text)
if result == "\n":
return "" # end of input
self.lineno += 1
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ build-backend = "setuptools.build_meta"
name = "mathicsscript"
description = "Command-line interface to Mathics3"
dependencies = [
"Mathics_Scanner>=1.4.1",
"Mathics3 >= 8.0.0",
"Mathics_Scanner>1.4.1",
"Mathics3 >= 8.0.1",
"click",
"colorama",
"columnize",
Expand All @@ -22,7 +22,7 @@ dependencies = [
"mathics_pygments>=1.0.2",
"term-background >= 1.0.1",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
readme = "README.rst"
license = {text = "GPL-3.0-only"}
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
Expand All @@ -34,11 +34,11 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"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",
Expand Down
Loading