Skip to content

Commit 1127641

Browse files
authored
start testing on free-threaded-python (ipython#15007)
2 parents 51dc045 + 6e350f7 commit 1127641

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
jobs:
1616
test:
1717
runs-on: ${{ matrix.os }}
18+
timeout-minutes: 15
1819
# Disable scheduled CI runs on forks
1920
if: github.event_name != 'schedule' || github.repository_owner == 'ipython'
2021
strategy:
@@ -28,13 +29,9 @@ jobs:
2829
- os: macos-latest
2930
python-version: "3.11"
3031
deps: test_extra
31-
# Tests minimal dependencies set
32+
# free threaded, not with all dependencies
3233
- os: ubuntu-latest
33-
python-version: "3.11"
34-
deps: test
35-
# Tests latest released Python version
36-
- os: ubuntu-latest
37-
python-version: "3.13"
34+
python-version: "3.14t"
3835
deps: test
3936
# Tests latest development Python version
4037
- os: ubuntu-latest
@@ -72,13 +69,13 @@ jobs:
7269
if: ${{ ! contains( matrix.python-version, 'dev' ) }}
7370
run: |
7471
python -m pip install --only-binary ':all:' --upgrade pip setuptools wheel build
75-
python -m pip install --only-binary ':all:' --no-binary curio --upgrade -e .[${{ matrix.deps }}]
72+
python -m pip install --no-binary curio --no-binary psutil --no-binary tornado --upgrade -e .[${{ matrix.deps }}]
7673
python -m pip install --only-binary ':all:' --upgrade check-manifest pytest-cov pytest
7774
- name: Install and update Python dependencies (dev?)
7875
if: ${{ contains( matrix.python-version, 'dev' ) }}
7976
run: |
8077
python -m pip install --pre --upgrade pip setuptools wheel build
81-
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --no-binary curio --upgrade -e .[${{ matrix.deps }}]
78+
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --no-binary curio --no-binary psutil --no-binary tornado --upgrade -e .[${{ matrix.deps }}]
8279
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --upgrade check-manifest pytest-cov
8380
- name: Try building with Python build
8481
if: runner.os != 'Windows' # setup.py does not support sdist on Windows

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test_extra = [
8080
"ipython[matplotlib]",
8181
"nbformat",
8282
"nbclient",
83-
"ipykernel",
83+
"ipykernel>6.30",
8484
"numpy>=1.25",
8585
"pandas>2.0",
8686
"trio",

tests/test_interactiveshell.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ class DerivedInterrupt(KeyboardInterrupt):
5050
pass
5151

5252

53+
def test_stream_performance(capsys) -> None:
54+
"""It should be fast to execute."""
55+
src = "for i in range(250_000): print(i)"
56+
start = time.perf_counter()
57+
ip.run_cell(src)
58+
end = time.perf_counter()
59+
# We try to read as otherwise on failure, pytest will print the 250k lines to stdout.
60+
capsys.readouterr()
61+
duration = end - start
62+
assert duration < 10
63+
64+
5365
class InteractiveShellTestCase(unittest.TestCase):
5466
def test_naked_string_cells(self):
5567
"""Test that cells with only naked strings are fully executed"""
@@ -85,15 +97,6 @@ def test_run_cell_multiline(self):
8597
self.assertEqual(res.success, True)
8698
self.assertEqual(res.result, None)
8799

88-
def test_stream_performance(self):
89-
"""It should be fast to execute."""
90-
src = "for i in range(250_000): print(i)"
91-
start = time.perf_counter()
92-
ip.run_cell(src)
93-
end = time.perf_counter()
94-
duration = end - start
95-
assert duration < 10
96-
97100
def test_multiline_string_cells(self):
98101
"Code sprinkled with multiline strings should execute (GH-306)"
99102
ip.run_cell("tmp=0")

tests/test_run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ def doctest_reset_del():
170170
# For some tests, it will be handy to organize them in a class with a common
171171
# setup that makes a temp file
172172

173+
import sysconfig
174+
175+
is_freethreaded = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
176+
173177

174178
class TestMagicRunPass(tt.TempFileMixin):
175179

@@ -294,6 +298,7 @@ def test_run_second(self):
294298
_ip.run_line_magic("run", empty.fname)
295299
assert _ip.user_ns["afunc"]() == 1
296300

301+
@pytest.mark.xfail(is_freethreaded, reason="C-third leaks on free-threaded python")
297302
def test_tclass(self):
298303
mydir = os.path.dirname(__file__)
299304
tc = os.path.join(mydir, "tclass")

0 commit comments

Comments
 (0)