Skip to content

Commit 68c24ee

Browse files
rockymmatera
andauthored
Use PyPI Timed-Threads for TimeConstrained[] (#1546)
Using newly released on PyPI Timed-Threads for `TimeConstrained[]` further running on Python 3.14+ packaging more easily. --------- Co-authored-by: mmatera <matera@fisica.unlp.edu.ar>
1 parent 1303c9a commit 68c24ee

File tree

9 files changed

+19
-31
lines changed

9 files changed

+19
-31
lines changed

.github/workflows/macos.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ jobs:
2828
python -m pip install --upgrade pip
2929
- name: Install Mathics3 with full Python dependencies
3030
run: |
31-
# First install our patched version of stopit
32-
git clone --depth 1 https://github.com/Mathics3/stopit.git
33-
cd stopit/
34-
pip install -e .
35-
cd ..
31+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
3632
# We can comment out after next Mathics-Scanner release
3733
# python -m pip install Mathics-Scanner[full]
3834
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]

.github/workflows/ubuntu-bench.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ jobs:
2525
run: |
2626
python -m pip install --upgrade pip
2727
python -m pip install pytest-benchmark
28-
# First install our patched version of stopit
29-
git clone --depth 1 https://github.com/Mathics3/stopit.git
30-
cd stopit/
31-
pip install -e .
32-
cd ..
3328
# We can comment out after next Mathics-Scanner release
3429
# python -m pip install Mathics-Scanner[full]
3530
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]

.github/workflows/ubuntu-cython.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ jobs:
2424
run: |
2525
sudo apt-get update -qq && sudo apt-get install -qq liblapack-dev llvm-dev tesseract-ocr
2626
python -m pip install --upgrade pip
27-
# First install our patched version of stopit
28-
git clone --depth 1 https://github.com/Mathics3/stopit.git
29-
cd stopit/
30-
pip install -e .
31-
cd ..
3227
# We can comment out after next Mathics-Scanner release
3328
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
3429
pip install -e .

.github/workflows/ubuntu.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ jobs:
2424
- name: Install Mathics3 with full dependencies
2525
run: |
2626
python -m pip install --upgrade pip
27-
# First install our patched version of stopit
28-
git clone --depth 1 https://github.com/Mathics3/stopit.git
29-
cd stopit/
27+
# We can comment out after next Mathics-Scanner release
28+
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
29+
git clone --depth 1 https://github.com/Mathics3/mathics-scanner.git
30+
# git clone --single-branch --branch operator-refactor-part1.5 https://github.com/Mathics3/mathics-scanner.git
31+
cd mathics-scanner/
3032
pip install -e .
3133
cd ..
3234
# We can comment out after next Mathics-Scanner release

.github/workflows/windows.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ jobs:
3333
set LLVM_DIR="C:\Program Files\LLVM"
3434
- name: Install Mathics3 with Python dependencies
3535
run: |
36-
# First install our patched version of stopit
37-
git clone --depth 1 https://github.com/Mathics3/stopit.git
38-
cd stopit/
39-
pip install -e .
40-
cd ..
4136
# We can comment out after next Mathics-Scanner release
4237
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
4338
pip install -e .

mathics/builtin/procedural.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ def eval(self, n, evaluation: Evaluation): # pylint: disable=unused-argument
529529
except ValueError:
530530
evaluation.message("Pause", "numnm", Expression(SymbolPause, n))
531531
return
532+
532533
eval_pause(sleep_time, evaluation)
533534
return SymbolNull
534535

mathics/eval/datetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def eval_pause(sleeptime: float, evaluation):
6666

6767

6868
if sys.platform == "emscripten":
69-
# from stopit import SignalTimeout as TimeoutHandler
69+
# from timed_threads import SignalTimeout as TimeoutHandler
7070

7171
def eval_timeconstrained(
7272
expr: BaseElement, timeout: float, failexpr: BaseElement, evaluation: Evaluation
@@ -75,7 +75,7 @@ def eval_timeconstrained(
7575
evaluation.message("TimeConstrained", "tcns")
7676

7777
else:
78-
from stopit import ThreadingTimeout as TimeoutHandler
78+
from timed_threads import ThreadingTimeout as TimeoutHandler
7979

8080
def eval_timeconstrained(
8181
expr: BaseElement, timeout: float, failexpr: BaseElement, evaluation: Evaluation

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ dependencies = [
2828
"requests",
2929
"scipy",
3030
"setuptools",
31-
# stopit is needed in TimeRemaining[]
32-
"stopit; platform_system != 'Emscripten'",
31+
# Timed-Threads is needed in TimeRemaining[]
32+
"Timed-Threads",
3333
"sympy>=1.13",
3434
]
3535
license = "GPL-3.0-or-later"

test/builtin/test_datentime.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
import pytest
1111

1212
try:
13-
from stopit import __version__ as stopit_version
13+
from timed_threads import __version__ as stopit_version
1414
except ImportError:
15-
have_stopit_for_timeconstrained = False
15+
have_timed_threads_for_timeconstrained = False
1616
else:
17-
have_stopit_for_timeconstrained = stopit_version.split(".")[:3] >= ["1", "1", "3"]
17+
have_timed_threads_for_timeconstrained = stopit_version.split(".")[:3] >= [
18+
"1",
19+
"1",
20+
"3",
21+
]
1822

1923

2024
@pytest.mark.skipif(
@@ -154,7 +158,7 @@ def test_private_doctests_datetime(str_expr, msgs, str_expected, fail_msg):
154158

155159

156160
@pytest.mark.skipif(
157-
sys.platform in ("emscripten",) or not have_stopit_for_timeconstrained,
161+
sys.platform in ("emscripten",) or not have_timed_threads_for_timeconstrained,
158162
reason="TimeConstrained[] is not supported in Pyodide or an unpatched 'stopit'",
159163
)
160164
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)