Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ jobs:
julia-version:
- '1.0'
- '1.6'
- '~1.7.0-rc1'
- 'nightly'
- '1.7'
- '1.8'
exclude:
- os: ubuntu-latest
architecture: x86
- os: macos-latest
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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Welcome to PyJulia’s documentation!

Experimenting with developing a better interface to
`Julia language <https://julialang.org/>`_ that works with
`Python <https://www.python.org/>`_ 2 & 3 and Julia v1.0+.
`Python <https://www.python.org/>`_ 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
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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": [
Expand Down
6 changes: 0 additions & 6 deletions src/julia/libjulia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 12 additions & 4 deletions src/julia/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from __future__ import absolute_import, print_function

import inspect
import sys
import warnings

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
)
):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I think this, and the change to use inspect, fixes it! Turned the test back on.

caller_frame = caller_frame.f_back

return_value = "nothing" if src.strip().endswith(";") else ""
Expand Down
4 changes: 2 additions & 2 deletions src/julia/pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/julia/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/julia/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/julia/tests/test_juliaoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/julia/tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def f():
return ret
f()
""") == "local"

def test_global_scope(run_cell):
assert run_cell("""
x = "global"
Expand Down
2 changes: 1 addition & 1 deletion src/julia/tests/test_runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = py3
[testenv]
deps =
pytest-cov
coverage < 5
coverage < 6
extras =
test
commands =
Expand Down Expand Up @@ -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}
Expand Down