Skip to content

Commit 74fcf17

Browse files
authored
Merge pull request #18 from Mathics3/optional-ujson
Optional ujson
2 parents 4e2d885 + ce38a5e commit 74fcf17

File tree

8 files changed

+31
-10
lines changed

8 files changed

+31
-10
lines changed

.github/workflows/osx.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25+
pip install -e .
2526
- name: Install Mathics Scanner
2627
run: |
2728
make
2829
- name: Test Mathics Scanner
2930
run: |
30-
pip install pytest
31+
pip install -r requirements-dev.txt
32+
pip install -r requirements-extra.txt
3133
python -m mathics_scanner.generate.build_tables
3234
make check

.github/workflows/ubuntu.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24+
pip install -e .
2425
- name: Install Mathics_Scanner
2526
run: |
2627
make
2728
- name: Test Mathics Scanner
2829
run: |
29-
pip install pytest
30+
pip install -r requirements-dev.txt
31+
pip install -r requirements-extra.txt
3032
python -m mathics_scanner.generate.build_tables
3133
make check

.github/workflows/windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25+
pip install -e .
2526
- name: Install Mathics_Scanner
2627
run: |
2728
python setup.py install
2829
- name: Test Mathics
2930
run: |
30-
pip install pytest
3131
pip install -r requirements-dev.txt
32+
pip install -r requirements-extra.txt
3233
python mathics_scanner/generate/build_tables.py
3334
py.test test

mathics_scanner/characters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
"""
88

99
import re
10-
import ujson
1110
import os
1211
import pkg_resources
1312

13+
try:
14+
import ujson
15+
except ImportError:
16+
import json as ujson
17+
1418
ROOT_DIR = pkg_resources.resource_filename("mathics_scanner", "")
1519

1620
# Load the conversion tables from disk

mathics_scanner/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# This file is suitable for sourcing inside POSIX shell as
55
# well as importing into Python. That's why there is no
66
# space around "=" below.
7-
__version__="1.2.0" # noqa
7+
__version__="1.2.1.dev0" # noqa

requirements-dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
PyYAML
2-
click
31
pytest

requirements-extra.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Optional packages which add functionality or speed things up
2+
ujson

setup.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
[email protected] and ask for help.
2626
"""
2727

28+
import re
2829
import sys
2930
import os.path as osp
3031
import platform
31-
import subprocess
32-
from setuptools import setup, Command, Extension
32+
from setuptools import setup
3333

3434
# Ensure user has the correct Python version
3535
if sys.version_info < (3, 6):
@@ -62,11 +62,22 @@ def read(*rnames):
6262
# General Requirements
6363
INSTALL_REQUIRES = [
6464
"chardet", # Used in mathics_scanner.feed
65-
"ujson", # Used in mathics_scanner.characters
65+
"PyYAML", # Used in mathics-generate-json-table
66+
# "ujson", # Optional Used in mathics_scanner.characters
6667
"click", # Usin in CLI: mathics-generate-json-table
6768
]
6869

6970

71+
extra_requires = []
72+
for line in open("requirements-extra.txt").read().split("\n"):
73+
if line and not line.startswith("#"):
74+
requires = re.sub(r"([^#]+)(\s*#.*$)?", r"\1", line)
75+
extra_requires.append(requires)
76+
77+
EXTRA_REQUIRES = {
78+
"full": extra_requires
79+
}
80+
7081
def subdirs(root, file="*.*", depth=10):
7182
for k in range(depth):
7283
yield root + "*/" * k + file
@@ -80,6 +91,7 @@ def subdirs(root, file="*.*", depth=10):
8091
"mathics_scanner.generate",
8192
],
8293
install_requires=INSTALL_REQUIRES,
94+
extra_requires=EXTRA_REQUIRES,
8395
entry_points={
8496
"console_scripts": [
8597
"mathics-generate-json-table=mathics_scanner.generate.build_tables:main"

0 commit comments

Comments
 (0)