diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5868e17..8abbe999 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,8 +24,8 @@ jobs: julia-version: - '1.0' - '1.6' - - '~1.7.0-rc1' - - 'nightly' + - '1.7' + - '1.8' exclude: - os: ubuntu-latest architecture: x86 @@ -33,9 +33,6 @@ jobs: architecture: x86 - os: macos-latest julia-version: '1.6' - - os: windows-latest - architecture: x86 - python-version: '3.10' # not added yet? - os: windows-latest julia-version: '1.6' - os: macos-latest @@ -56,19 +53,11 @@ jobs: architecture: x64 python-version: '3.8' julia-version: '1' - # Python 2.7 (TODO: drop): - - os: ubuntu-latest - architecture: x64 - python-version: '2.7' - julia-version: '1' - - os: windows-latest - architecture: x64 - python-version: '2.7' - julia-version: '1' fail-fast: false - name: Test ${{ matrix.os }} ${{ matrix.architecture }} - Python ${{ matrix.python-version }} - Julia ${{ matrix.julia-version }} + name: Test + py${{ matrix.python-version }} + jl${{ matrix.julia-version }} + ${{ matrix.os }} ${{ matrix.architecture }} steps: - uses: actions/checkout@v1 - name: Setup python diff --git a/docs/source/index.rst b/docs/source/index.rst index c2d091be..85874225 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -5,9 +5,9 @@ Welcome to PyJulia’s documentation! Experimenting with developing a better interface to `Julia language `_ that works with -`Python `_ 2 & 3 and Julia v1.0+. +`Python `_ 3 and Julia v1.0+. -PyJulia is tested against Python versions 2.7, 3.5, 3.6, and 3.7. +PyJulia is tested against Python versions 3.5+ .. toctree:: :maxdepth: 2 diff --git a/setup.py b/setup.py index 5b1e4c85..6a1870e7 100644 --- a/setup.py +++ b/setup.py @@ -59,8 +59,6 @@ def pyload(path): # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', @@ -79,6 +77,7 @@ def pyload(path): packages=find_packages("src"), package_dir={"": "src"}, package_data={"julia": ["*.jl"]}, + python_requires=">=3.4", extras_require={ # Update `ci/test-upload/tox.ini` when "test" is changed: "test": [ diff --git a/src/julia/libjulia.py b/src/julia/libjulia.py index fb06693c..8caa2c3a 100644 --- a/src/julia/libjulia.py +++ b/src/julia/libjulia.py @@ -216,12 +216,6 @@ def __init__(self, libjulia_path, bindir, sysimage): 'Julia library ("libjulia") not found! {}'.format(libjulia_path) ) - # fixes a specific issue with python 2.7.13 - # ctypes.windll.LoadLibrary refuses unicode argument - # http://bugs.python.org/issue29294 - if sys.version_info >= (2, 7, 13) and sys.version_info < (2, 7, 14): - libjulia_path = libjulia_path.encode("ascii") - with self._pathhack(): self.libjulia = ctypes.PyDLL(libjulia_path, ctypes.RTLD_GLOBAL) diff --git a/src/julia/magic.py b/src/julia/magic.py index 37242b5b..8ecf9d1b 100644 --- a/src/julia/magic.py +++ b/src/julia/magic.py @@ -19,6 +19,7 @@ from __future__ import absolute_import, print_function +import inspect import sys import warnings @@ -48,8 +49,7 @@ def no_var_expand(f): @magics_class class JuliaMagics(Magics): - """A set of magics useful for interactive work with Julia. - """ + """A set of magics useful for interactive work with Julia.""" highlight = Bool( True, @@ -109,12 +109,20 @@ def julia(self, line, cell=None): """ src = unicode(line if cell is None else cell) + caller_frame = inspect.currentframe() + if caller_frame is None: + caller_frame = sys._getframe(3) # May not work. + # We assume the caller's frame is the first parent frame not in the # IPython module. This seems to work with IPython back to ~v5, and # is at least somewhat immune to future IPython internals changes, # although by no means guaranteed to be perfect. - caller_frame = sys._getframe(3) - while caller_frame.f_globals.get("__name__").startswith("IPython"): + while any( + ( + caller_frame.f_globals.get("__name__").startswith("IPython"), + caller_frame.f_globals.get("__name__").startswith("julia"), + ) + ): caller_frame = caller_frame.f_back return_value = "nothing" if src.strip().endswith(";") else "" diff --git a/src/julia/pytestplugin.py b/src/julia/pytestplugin.py index 4e1f3cdb..811ee4c3 100644 --- a/src/julia/pytestplugin.py +++ b/src/julia/pytestplugin.py @@ -125,7 +125,7 @@ def pytest_configure(config): @pytest.fixture(scope="session") def julia(request): - """ pytest fixture for providing a `Julia` instance. """ + """pytest fixture for providing a `Julia` instance.""" if not request.config.getoption("julia"): pytest.skip("--no-julia is given.") @@ -136,7 +136,7 @@ def julia(request): @pytest.fixture(scope="session") def juliainfo(julia): - """ pytest fixture for providing `JuliaInfo` instance. """ + """pytest fixture for providing `JuliaInfo` instance.""" return _JULIA_INFO diff --git a/src/julia/tests/conftest.py b/src/julia/tests/conftest.py index cf791b86..94178456 100644 --- a/src/julia/tests/conftest.py +++ b/src/julia/tests/conftest.py @@ -3,7 +3,7 @@ @pytest.fixture(scope="session") def Main(julia): - """ pytest fixture for providing a Julia `Main` name space. """ + """pytest fixture for providing a Julia `Main` name space.""" from julia import Main return Main diff --git a/src/julia/tests/test_core.py b/src/julia/tests/test_core.py index 41fdc4f0..b54e8cdf 100644 --- a/src/julia/tests/test_core.py +++ b/src/julia/tests/test_core.py @@ -37,7 +37,7 @@ def test_call_error(julia): def test_call_julia_function_with_python_args(Main): - assert list(Main.map(Main.uppercase, array.array("u", [u"a", u"b", u"c"]))) == [ + assert list(Main.map(Main.uppercase, array.array("u", ["a", "b", "c"]))) == [ "A", "B", "C", @@ -129,7 +129,7 @@ def test_getattr_submodule(Main): def test_star_import_julia_module(julia, tmp_path): # Create a Python module __pyjulia_star_import_test path = tmp_path / "__pyjulia_star_import_test.py" - path.write_text(u"from julia.Base.Enums import *") + path.write_text("from julia.Base.Enums import *") sys.path.insert(0, str(tmp_path)) import __pyjulia_star_import_test diff --git a/src/julia/tests/test_juliaoptions.py b/src/julia/tests/test_juliaoptions.py index 9e18ddf2..931438fd 100644 --- a/src/julia/tests/test_juliaoptions.py +++ b/src/julia/tests/test_juliaoptions.py @@ -18,10 +18,13 @@ def test_as_args(kwargs, args): assert JuliaOptions(**kwargs).as_args() == args -@pytest.mark.parametrize("kwargs", [ - dict(compiled_modules="invalid value"), - dict(bindir=123456789), -]) +@pytest.mark.parametrize( + "kwargs", + [ + dict(compiled_modules="invalid value"), + dict(bindir=123456789), + ], +) def test_valueerror(kwargs): with pytest.raises(ValueError) as excinfo: JuliaOptions(**kwargs) diff --git a/src/julia/tests/test_magic.py b/src/julia/tests/test_magic.py index 6fd7c279..daac7179 100644 --- a/src/julia/tests/test_magic.py +++ b/src/julia/tests/test_magic.py @@ -125,7 +125,7 @@ def f(): return ret f() """) == "local" - + def test_global_scope(run_cell): assert run_cell(""" x = "global" diff --git a/src/julia/tests/test_runtests.py b/src/julia/tests/test_runtests.py index 436ee4b0..36ff885e 100644 --- a/src/julia/tests/test_runtests.py +++ b/src/julia/tests/test_runtests.py @@ -7,7 +7,7 @@ def test_runtests_failure(tmp_path): testfile = tmp_path / "test.py" - testcode = u""" + testcode = """ def test_THIS_TEST_MUST_FAIL(): assert False """ diff --git a/tox.ini b/tox.ini index 68aff25c..bf1ce1d5 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py3 [testenv] deps = pytest-cov - coverage < 5 + coverage < 6 extras = test commands = @@ -79,7 +79,7 @@ changedir = {toxinidir}/docs [testenv:style] deps = isort == 4.3.17 - black == 19.3b0 + black == 22.3.0 commands = isort --recursive --check-only . black . {posargs:--check --diff}