Skip to content

Commit f9aa60c

Browse files
authored
Merge pull request #689 from Mathics3/version-tweaking
Version tweaking
2 parents ed46c86 + a12c21c commit f9aa60c

File tree

6 files changed

+63
-18
lines changed

6 files changed

+63
-18
lines changed

CHANGES.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ CHANGES
66
5.0.3dev0
77
---------
88

9+
API
10+
+++
11+
12+
#. New function ``mathics.system_info.python_implementation()`` shows the Python Implementation, e.g. CPython, PyPy, Pyston that is running Python. This is included in the information ``mathics.system_info.mathics_system__system_info()`` returns and is used in ``$PythonImplementation``
13+
#. A list of optional software can be found in ``mathics.optional_software``. Versions of that software are included in ``mathics.version_info``.
14+
15+
16+
Package update
17+
..............
18+
19+
#. SymPy 1.11.1 accepted
20+
#. Numpy 1.24.0 accepted
21+
22+
923
New Builtins
1024
+++++++++++
1125

@@ -35,18 +49,21 @@ Documentation
3549
#. "Exponential Functional" split out from "Trigonometry Functions"
3650
#. A new section on "Accuracy and Precision" was included in the manual.
3751
#. "Forms of Input and Output" is its own section
52+
#. All Builtins have links to WMA pages.
53+
#. More url links to Wiki pages added; more internal cross links added.
3854

3955
Internals
4056
+++++++++
4157

4258
#. ``boxes_to_`` methods are now optional for ``BoxElement`` subclasses. Most of the code is now moved to the ``mathics.format`` submodule, and implemented in a more scalable way.
4359
#. ``mathics.builtin.inout`` was splitted in several modules (``inout``, ``messages``, ``layout``, ``makeboxes``) in order to improve the documentation.
44-
#. `from_mpmath` conversion supports a new parameter ``acc`` to set the accuracy of the number.
60+
#. ``from_mpmath`` conversion supports a new parameter ``acc`` to set the accuracy of the number.
4561
#. Operator name to unicode or ASCII comes from Mathics scanner character tables.
46-
#. ``eval*`` methods in `Builtin` classes are considerer as synonyms of ``apply*`` methods.
47-
#. Modularize and improve the way in which `Builtin` classes are selected to have an associated `Definition`.
48-
#. `_SetOperator.assign_elementary` was renamed as `_SetOperator.assign`. All the special cases are not handled by the `_SetOperator.special_cases` dict.
49-
62+
#. Builtin instance methods that start ``apply`` are considered rule matching and function application; the use of the name ``apply``is deprecated, when ``eval`` is intended.
63+
#. Modularize and improve the way in which ``Builtin`` classes are selected to have an associated ``Definition``.
64+
#. ``_SetOperator.assign_elementary`` was renamed as ``_SetOperator.assign``. All the special cases are not handled by the ``_SetOperator.special_cases`` dict.
65+
#. ``isort`` run over all Python files. More type annotations and docstrings on functions added.
66+
#. caching on immutable atoms like, ``String``, ``Integer``, ``Real``, etc. was improved; the ``__hash__()`` function was sped up. There is a small speedup overall from this at the expense of increased memory.
5067

5168

5269
Bugs

mathics/__init__.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,49 @@
22

33
import platform
44
import sys
5+
from importlib import import_module
6+
from typing import Dict
57

68
import mpmath
79
import numpy
810
import sympy
911

1012
from mathics.version import __version__
1113

12-
version_info = {
14+
# version_info contains a list of Python packages
15+
# and the versions infsalled or "Not installed"
16+
# if the package is not installed and "No version information"
17+
# if we can't get version infomation.
18+
version_info: Dict[str, str] = {
1319
"mathics": __version__,
14-
"sympy": sympy.__version__,
1520
"mpmath": mpmath.__version__,
1621
"numpy": numpy.__version__,
1722
"python": platform.python_implementation() + " " + sys.version.split("\n")[0],
23+
"sympy": sympy.__version__,
1824
}
1925

20-
try:
21-
import cython
22-
except ImportError:
23-
pass
24-
else:
25-
version_info["cython"] = cython.__version__
2626

27+
# optional_software contains a list of Python packages
28+
# that add functionality but are optional
29+
optional_software: Dict[str, str] = (
30+
"cython",
31+
"lxml",
32+
"networkx",
33+
"nltk",
34+
"psutil",
35+
"scikit-image",
36+
"scipy",
37+
"wordcloud",
38+
)
39+
40+
for package in optional_software:
41+
try:
42+
mod = import_module(package)
43+
package_version = mod.__dict__.get("__version__", "No version information")
44+
except ImportError:
45+
package_version = "Not installed"
46+
47+
version_info[package] = package_version
2748

2849
version_string = """Mathics {mathics}
2950
on {python}

mathics/doc/common_doc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,11 @@ def post_sub(text, post_substitutions):
632632
return text
633633

634634

635+
def skip_doc(cls):
636+
"""Returns True if we should skip cls in docstring extraction."""
637+
return cls.__name__.endswith("Box") or (hasattr(cls, "no_doc") and cls.no_doc)
638+
639+
635640
class Tests:
636641
# FIXME: add optional guide section
637642
def __init__(self, part: str, chapter: str, section: str, doctests):

mathics/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def main() -> int:
345345
)
346346
args, script_args = argparser.parse_known_args()
347347

348-
quit_command = "CTRL-BREAK" if sys.platform == "win32" else "CONTROL-D"
348+
quit_command = "CTRL-BREAK" if sys.platform in ("win32", "nt") else "CONTROL-D"
349349

350350
extension_modules = []
351351
if args.pyextensions:

mathics/system_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def python_implementation() -> str:
1515
"""
16-
Returns the Python implemnetation, e.g Pyston, PyPy, CPython...
16+
Returns the Python implementation, e.g Pyston, PyPy, CPython...
1717
"""
1818
if hasattr(sys, "pyston_version_info"):
1919
custom_version_info = sys.pyston_version_info

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535

3636
from setuptools import Extension, setup
3737

38-
is_PyPy = platform.python_implementation() == "PyPy"
38+
is_PyPy = platform.python_implementation() == "PyPy" or hasattr(
39+
sys, "pypy_version_info"
40+
)
3941

4042
INSTALL_REQUIRES = ["Mathics-Scanner >= 1.3.0.dev0"]
4143

@@ -49,13 +51,13 @@
4951
"recordclass",
5052
"numpy",
5153
"llvmlite<0.37",
52-
"sympy>=1.8,<1.9",
54+
"sympy>=1.8,<1.12",
5355
]
5456
if is_PyPy:
5557
print("Mathics does not support PyPy Python 3.6" % sys.version_info[:2])
5658
sys.exit(-1)
5759
else:
58-
INSTALL_REQUIRES += ["numpy<=1.24", "llvmlite", "sympy>=1.8, < 1.11"]
60+
INSTALL_REQUIRES += ["numpy<=1.24", "llvmlite", "sympy>=1.8, < 1.12"]
5961

6062
if not is_PyPy:
6163
INSTALL_REQUIRES += ["recordclass"]

0 commit comments

Comments
 (0)