Skip to content

Commit b95e524

Browse files
authored
Merge pull request #508 from MilesCranmer/fix-tests
Fix CI test suite and and remove Python 2.7 support
2 parents 56a7391 + ebb3b3b commit b95e524

File tree

12 files changed

+37
-44
lines changed

12 files changed

+37
-44
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,15 @@ jobs:
2424
julia-version:
2525
- '1.0'
2626
- '1.6'
27-
- '~1.7.0-rc1'
28-
- 'nightly'
27+
- '1.7'
28+
- '1.8'
2929
exclude:
3030
- os: ubuntu-latest
3131
architecture: x86
3232
- os: macos-latest
3333
architecture: x86
3434
- os: macos-latest
3535
julia-version: '1.6'
36-
- os: windows-latest
37-
architecture: x86
38-
python-version: '3.10' # not added yet?
3936
- os: windows-latest
4037
julia-version: '1.6'
4138
- os: macos-latest
@@ -56,19 +53,11 @@ jobs:
5653
architecture: x64
5754
python-version: '3.8'
5855
julia-version: '1'
59-
# Python 2.7 (TODO: drop):
60-
- os: ubuntu-latest
61-
architecture: x64
62-
python-version: '2.7'
63-
julia-version: '1'
64-
- os: windows-latest
65-
architecture: x64
66-
python-version: '2.7'
67-
julia-version: '1'
6856
fail-fast: false
69-
name: Test ${{ matrix.os }} ${{ matrix.architecture }}
70-
Python ${{ matrix.python-version }}
71-
Julia ${{ matrix.julia-version }}
57+
name: Test
58+
py${{ matrix.python-version }}
59+
jl${{ matrix.julia-version }}
60+
${{ matrix.os }} ${{ matrix.architecture }}
7261
steps:
7362
- uses: actions/checkout@v1
7463
- name: Setup python

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Welcome to PyJulia’s documentation!
55

66
Experimenting with developing a better interface to
77
`Julia language <https://julialang.org/>`_ that works with
8-
`Python <https://www.python.org/>`_ 2 & 3 and Julia v1.0+.
8+
`Python <https://www.python.org/>`_ 3 and Julia v1.0+.
99

10-
PyJulia is tested against Python versions 2.7, 3.5, 3.6, and 3.7.
10+
PyJulia is tested against Python versions 3.5+
1111

1212
.. toctree::
1313
:maxdepth: 2

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def pyload(path):
5959

6060
# Specify the Python versions you support here. In particular, ensure
6161
# that you indicate whether you support Python 2, Python 3 or both.
62-
'Programming Language :: Python :: 2',
63-
'Programming Language :: Python :: 2.7',
6462
'Programming Language :: Python :: 3',
6563
'Programming Language :: Python :: 3.4',
6664
'Programming Language :: Python :: 3.5',
@@ -79,6 +77,7 @@ def pyload(path):
7977
packages=find_packages("src"),
8078
package_dir={"": "src"},
8179
package_data={"julia": ["*.jl"]},
80+
python_requires=">=3.4",
8281
extras_require={
8382
# Update `ci/test-upload/tox.ini` when "test" is changed:
8483
"test": [

src/julia/libjulia.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,6 @@ def __init__(self, libjulia_path, bindir, sysimage):
216216
'Julia library ("libjulia") not found! {}'.format(libjulia_path)
217217
)
218218

219-
# fixes a specific issue with python 2.7.13
220-
# ctypes.windll.LoadLibrary refuses unicode argument
221-
# http://bugs.python.org/issue29294
222-
if sys.version_info >= (2, 7, 13) and sys.version_info < (2, 7, 14):
223-
libjulia_path = libjulia_path.encode("ascii")
224-
225219
with self._pathhack():
226220
self.libjulia = ctypes.PyDLL(libjulia_path, ctypes.RTLD_GLOBAL)
227221

src/julia/magic.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from __future__ import absolute_import, print_function
2121

22+
import inspect
2223
import sys
2324
import warnings
2425

@@ -48,8 +49,7 @@ def no_var_expand(f):
4849

4950
@magics_class
5051
class JuliaMagics(Magics):
51-
"""A set of magics useful for interactive work with Julia.
52-
"""
52+
"""A set of magics useful for interactive work with Julia."""
5353

5454
highlight = Bool(
5555
True,
@@ -109,12 +109,20 @@ def julia(self, line, cell=None):
109109
"""
110110
src = unicode(line if cell is None else cell)
111111

112+
caller_frame = inspect.currentframe()
113+
if caller_frame is None:
114+
caller_frame = sys._getframe(3) # May not work.
115+
112116
# We assume the caller's frame is the first parent frame not in the
113117
# IPython module. This seems to work with IPython back to ~v5, and
114118
# is at least somewhat immune to future IPython internals changes,
115119
# although by no means guaranteed to be perfect.
116-
caller_frame = sys._getframe(3)
117-
while caller_frame.f_globals.get("__name__").startswith("IPython"):
120+
while any(
121+
(
122+
caller_frame.f_globals.get("__name__").startswith("IPython"),
123+
caller_frame.f_globals.get("__name__").startswith("julia"),
124+
)
125+
):
118126
caller_frame = caller_frame.f_back
119127

120128
return_value = "nothing" if src.strip().endswith(";") else ""

src/julia/pytestplugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def pytest_configure(config):
125125

126126
@pytest.fixture(scope="session")
127127
def julia(request):
128-
""" pytest fixture for providing a `Julia` instance. """
128+
"""pytest fixture for providing a `Julia` instance."""
129129
if not request.config.getoption("julia"):
130130
pytest.skip("--no-julia is given.")
131131

@@ -136,7 +136,7 @@ def julia(request):
136136

137137
@pytest.fixture(scope="session")
138138
def juliainfo(julia):
139-
""" pytest fixture for providing `JuliaInfo` instance. """
139+
"""pytest fixture for providing `JuliaInfo` instance."""
140140
return _JULIA_INFO
141141

142142

src/julia/tests/conftest.py

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

44
@pytest.fixture(scope="session")
55
def Main(julia):
6-
""" pytest fixture for providing a Julia `Main` name space. """
6+
"""pytest fixture for providing a Julia `Main` name space."""
77
from julia import Main
88

99
return Main

src/julia/tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_call_error(julia):
3737

3838

3939
def test_call_julia_function_with_python_args(Main):
40-
assert list(Main.map(Main.uppercase, array.array("u", [u"a", u"b", u"c"]))) == [
40+
assert list(Main.map(Main.uppercase, array.array("u", ["a", "b", "c"]))) == [
4141
"A",
4242
"B",
4343
"C",
@@ -129,7 +129,7 @@ def test_getattr_submodule(Main):
129129
def test_star_import_julia_module(julia, tmp_path):
130130
# Create a Python module __pyjulia_star_import_test
131131
path = tmp_path / "__pyjulia_star_import_test.py"
132-
path.write_text(u"from julia.Base.Enums import *")
132+
path.write_text("from julia.Base.Enums import *")
133133
sys.path.insert(0, str(tmp_path))
134134

135135
import __pyjulia_star_import_test

src/julia/tests/test_juliaoptions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ def test_as_args(kwargs, args):
1818
assert JuliaOptions(**kwargs).as_args() == args
1919

2020

21-
@pytest.mark.parametrize("kwargs", [
22-
dict(compiled_modules="invalid value"),
23-
dict(bindir=123456789),
24-
])
21+
@pytest.mark.parametrize(
22+
"kwargs",
23+
[
24+
dict(compiled_modules="invalid value"),
25+
dict(bindir=123456789),
26+
],
27+
)
2528
def test_valueerror(kwargs):
2629
with pytest.raises(ValueError) as excinfo:
2730
JuliaOptions(**kwargs)

src/julia/tests/test_magic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def f():
125125
return ret
126126
f()
127127
""") == "local"
128-
128+
129129
def test_global_scope(run_cell):
130130
assert run_cell("""
131131
x = "global"

0 commit comments

Comments
 (0)