Skip to content

Commit b81c389

Browse files
author
Christopher Doris
committed
Merge remote-tracking branch 'origin/main' into v1
2 parents 19119b6 + b9aafe9 commit b81c389

File tree

24 files changed

+240
-35
lines changed

24 files changed

+240
-35
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ jobs:
5656
fail-fast: true
5757
matrix:
5858
os: [ubuntu-latest, windows-latest, macos-latest]
59-
pyversion: ["3.x", "3.7"]
59+
pyversion: ["3.x", "3.8"]
6060
steps:
6161
- uses: actions/checkout@v3
6262
- name: Set up Python ${{ matrix.pyversion }}
6363
uses: actions/setup-python@v4
6464
with:
6565
python-version: ${{ matrix.pyversion }}
66-
- name: Set up Julia 1.10.0
66+
- name: Set up Julia
6767
uses: julia-actions/setup-julia@v1
6868
with:
69-
version: '1.10.0'
69+
version: '1'
7070
- name: Install dependencies
7171
run: |
7272
python -m pip install --upgrade pip
73-
pip install flake8 pytest pytest-cov
73+
pip install flake8 pytest pytest-cov nbval numpy
7474
cp pysrc/juliacall/juliapkg-dev.json pysrc/juliacall/juliapkg.json
7575
pip install -e .
7676
- name: Lint with flake8
@@ -81,7 +81,7 @@ jobs:
8181
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
8282
- name: Run tests
8383
run: |
84-
pytest -s --cov=pysrc
84+
pytest -s --nbval --cov=pysrc ./pytest/
8585
- name: Upload coverage to Codecov
8686
uses: codecov/codecov-action@v2
8787
env:

CondaPkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version = "<=julia"
33

44
[deps.python]
55
build = "**cpython**"
6-
version = ">=3.7,<4"
6+
version = ">=3.8,<4"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PythonCall"
22
uuid = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
33
authors = ["Christopher Doris <github.com/cjdoris>"]
4-
version = "0.9.17"
4+
version = "0.9.20"
55

66
[deps]
77
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Bringing [**Python®**](https://www.python.org/) and [**Julia**](https://juliala
1414
- Fast non-copying conversion of numeric arrays in either direction: modify Python arrays (e.g. `bytes`, `array.array`, `numpy.ndarray`) from Julia or Julia arrays from Python.
1515
- Helpful wrappers: interpret Python sequences, dictionaries, arrays, dataframes and IO streams as their Julia counterparts, and vice versa.
1616
- Beautiful stack-traces.
17-
- Supports modern systems: tested on Windows, MacOS and Linux, 64-bit, Julia 1.6.1 upwards and Python 3.7 upwards.
17+
- Supports modern systems: tested on Windows, MacOS and Linux, 64-bit, Julia 1.6.1 upwards and Python 3.8 upwards.
1818

1919
⭐ If you like this, a GitHub star would be lovely thank you. ⭐
2020

@@ -45,4 +45,4 @@ The existing package [PyCall](https://github.com/JuliaPy/PyCall.jl) is another s
4545
- PythonCall by default never copies mutable objects when converting, but instead directly wraps the mutable object. This means that modifying the converted object modifies the original, and conversion is faster.
4646
- PythonCall does not usually automatically convert results to Julia values, but leaves them as Python objects. This makes it easier to do Pythonic things with these objects (e.g. accessing methods) and is type-stable.
4747
- PythonCall installs dependencies into a separate Conda environment for each Julia project. This means each Julia project can have an isolated set of Python dependencies.
48-
- PythonCall supports Julia 1.6.1+ and Python 3.7+ whereas PyCall supports Julia 0.7+ and Python 2.7+.
48+
- PythonCall supports Julia 1.6.1+ and Python 3.8+ whereas PyCall supports Julia 0.7+ and Python 2.7+.

docs/src/compat.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ The `juliacall` IPython extension adds these features to your IPython session:
6767

6868
The extension is experimental and unstable - the API can change at any time.
6969

70-
Enable the extension with `%load_ext juliacall`.
71-
See [the IPython docs](https://ipython.readthedocs.io/en/stable/config/extensions/).
70+
You can explicitly enable the extension with `%load_ext juliacall`, but
71+
it will automatically be loaded if `juliacall` is imported and IPython is detected.
72+
You can disable this behavior with an [environment variable](@ref julia-config).
7273

7374
The `%%julia` cell magic can synchronise variables between Julia and Python by listing them
7475
on the first line:
@@ -88,6 +89,9 @@ In [5]: z
8889
Out[5]: '2^8 = 256'
8990
```
9091

92+
Also see [the IPython docs](https://ipython.readthedocs.io/en/stable/config/extensions/)
93+
for more information on extensions.
94+
9195
## Asynchronous Julia code (including Makie)
9296

9397
Asynchronous Julia code will not normally run while Python is executing, unless it is in a

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Bringing [**Python®**](https://www.python.org/) and [**Julia**](https://juliala
77
- Fast non-copying conversion of numeric arrays in either direction: modify Python arrays (e.g. `bytes`, `array.array`, `numpy.ndarray`) from Julia or Julia arrays from Python.
88
- Helpful wrappers: interpret Python sequences, dictionaries, arrays, dataframes and IO streams as their Julia counterparts, and vice versa.
99
- Beautiful stack-traces.
10-
- Works anywhere: tested on Windows, MacOS and Linux, 32- and 64-bit, Julia Julia 1.6.1 upwards and Python 3.7 upwards.
10+
- Works anywhere: tested on Windows, MacOS and Linux, 32- and 64-bit, Julia Julia 1.6.1 upwards and Python 3.8 upwards.

docs/src/juliacall.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ be configured in two ways:
123123
| `-X juliacall-sysimage=<file>` | `PYTHON_JULIACALL_SYSIMAGE=<file>` | Use the given system image. |
124124
| `-X juliacall-threads=<N\|auto>` | `PYTHON_JULIACALL_THREADS=<N\|auto>` | Launch N threads. |
125125
| `-X juliacall-warn-overwrite=<yes\|no>` | `PYTHON_JULIACALL_WARN_OVERWRITE=<yes\|no>` | Enable or disable method overwrite warnings. |
126+
| `-X juliacall-autoload-ipython-extension=<yes\|no>` | `PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=<yes\|no>` | Enable or disable IPython extension autoloading. |

docs/src/pycall.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ Note also that JuliaCall will use a separate Julia project for each virtual/cond
7272

7373
### Compatibility
7474

75-
PyCall supports Julia 0.7+ and Python 2.7+, whereas PythonCall supports Julia 1.6.1+ and Python 3.7+. PyCall requires numpy to be installed, PythonCall doesn't (it provides the same fast array access through the buffer protocol and array interface).
75+
PyCall supports Julia 0.7+ and Python 2.7+, whereas PythonCall supports Julia 1.6.1+ and Python 3.8+. PyCall requires numpy to be installed, PythonCall doesn't (it provides the same fast array access through the buffer protocol and array interface).

docs/src/releasenotes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
## Unreleased (v1)
44
* `PythonCall.GC` is now more like `Base.GC`: `enable(true)` replaces `enable()`, `enable(false)` replaces `disable()`, and `gc()` is added.
55

6+
## 0.9.20 (2024-05-01)
7+
* The IPython extension is now automatically loaded upon import if IPython is detected.
8+
* JuliaCall now compatible with Julia 1.10.3.
9+
* Minimum supported Python version is now 3.8.
10+
11+
## 0.9.19 (2024-03-19)
12+
* Bug fixes.
13+
14+
## 0.9.18 (2024-03-18)
15+
* Bug fixes.
16+
617
## 0.9.17 (2024-03-16)
718
* Bug fixes.
819

pysrc/juliacall/__init__.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This module gets modified by PythonCall when it is loaded, e.g. to include Core, Base
22
# and Main modules.
33

4-
__version__ = '0.9.17'
4+
__version__ = '0.9.20'
55

66
_newmodule = None
77

@@ -248,8 +248,30 @@ def jlstr(x):
248248
"PYTHON_JULIACALL_HANDLE_SIGNALS=no."
249249
)
250250

251-
init()
251+
# Next, automatically load the juliacall extension if we are in IPython or Jupyter
252+
CONFIG['autoload_ipython_extension'] = choice('autoload_ipython_extension', ['yes', 'no'])[0]
253+
if CONFIG['autoload_ipython_extension'] in {'yes', None}:
254+
try:
255+
get_ipython = sys.modules['IPython'].get_ipython
256+
257+
if CONFIG['autoload_ipython_extension'] is None:
258+
# Only let the user know if it was not explicitly set
259+
print(
260+
"Detected IPython. Loading juliacall extension. See https://juliapy.github.io/PythonCall.jl/stable/compat/#IPython"
261+
)
262+
263+
load_ipython_extension(get_ipython())
264+
except Exception as e:
265+
if CONFIG['autoload_ipython_extension'] == 'yes':
266+
# Only warn if the user explicitly requested the extension to be loaded
267+
warnings.warn(
268+
"Could not load juliacall extension in Jupyter notebook: " + str(e)
269+
)
270+
pass
271+
252272

253273
def load_ipython_extension(ip):
254274
import juliacall.ipython
255275
juliacall.ipython.load_ipython_extension(ip)
276+
277+
init()

pysrc/juliacall/juliapkg-dev.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"julia": "~1.6.1, ~1.7, ~1.8, ~1.9, =1.10.0",
2+
"julia": "~1.6.1, ~1.7, ~1.8, ~1.9, =1.10.0, ^1.10.3",
33
"packages": {
44
"PythonCall": {
55
"uuid": "6099a3de-0909-46bc-b1f4-468b9a2dfc0d",
6-
"version": "=0.9.17",
6+
"version": "=0.9.20",
77
"path": "../..",
88
"dev": true
99
}

pysrc/juliacall/juliapkg.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"julia": "~1.6.1, ~1.7, ~1.8, ~1.9, =1.10.0",
2+
"julia": "~1.6.1, ~1.7, ~1.8, ~1.9, =1.10.0, ^1.10.3",
33
"packages": {
44
"PythonCall": {
55
"uuid": "6099a3de-0909-46bc-b1f4-468b9a2dfc0d",
6-
"version": "=0.9.17"
6+
"version": "=0.9.20"
77
}
88
}
99
}

pytest/test_nb.ipynb

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"# NBVAL_IGNORE_OUTPUT\n",
10+
"import numpy as np\n",
11+
"from juliacall import Main as jl"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 2,
17+
"metadata": {},
18+
"outputs": [
19+
{
20+
"name": "stdout",
21+
"output_type": "stream",
22+
"text": [
23+
"3\n"
24+
]
25+
}
26+
],
27+
"source": [
28+
"%%julia\n",
29+
"\n",
30+
"# Automatically activates Julia magic\n",
31+
"\n",
32+
"x = 1\n",
33+
"println(x + 2)"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": 3,
39+
"metadata": {},
40+
"outputs": [
41+
{
42+
"name": "stdout",
43+
"output_type": "stream",
44+
"text": [
45+
"4\n"
46+
]
47+
}
48+
],
49+
"source": [
50+
"%julia println(x + 3)"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 4,
56+
"metadata": {},
57+
"outputs": [
58+
{
59+
"data": {
60+
"text/plain": [
61+
"1.0"
62+
]
63+
},
64+
"execution_count": 4,
65+
"metadata": {},
66+
"output_type": "execute_result"
67+
}
68+
],
69+
"source": [
70+
"jl.cos(0)"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": 5,
76+
"metadata": {},
77+
"outputs": [
78+
{
79+
"data": {
80+
"text/plain": [
81+
"f (generic function with 1 method)"
82+
]
83+
},
84+
"execution_count": 5,
85+
"metadata": {},
86+
"output_type": "execute_result"
87+
}
88+
],
89+
"source": [
90+
"%%julia\n",
91+
"\n",
92+
"function f(x::AbstractArray)\n",
93+
" sum(x)\n",
94+
"end"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 6,
100+
"metadata": {},
101+
"outputs": [
102+
{
103+
"data": {
104+
"text/plain": [
105+
"6"
106+
]
107+
},
108+
"execution_count": 6,
109+
"metadata": {},
110+
"output_type": "execute_result"
111+
}
112+
],
113+
"source": [
114+
"jl.f(np.array([1, 2, 3]))"
115+
]
116+
}
117+
],
118+
"metadata": {
119+
"kernelspec": {
120+
"display_name": "Python 3 (ipykernel)",
121+
"language": "python",
122+
"name": "python3"
123+
},
124+
"language_info": {
125+
"codemirror_mode": {
126+
"name": "ipython",
127+
"version": 3
128+
},
129+
"file_extension": ".py",
130+
"mimetype": "text/x-python",
131+
"name": "python",
132+
"nbconvert_exporter": "python",
133+
"pygments_lexer": "ipython3",
134+
"version": "3.10.10"
135+
}
136+
},
137+
"nbformat": 4,
138+
"nbformat_minor": 2
139+
}

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = juliacall
3-
version = 0.9.17
3+
version = 0.9.20
44
description = Julia and Python in seamless harmony
55
long_description = file: README.md
66
long_description_content_type = text/markdown
@@ -15,7 +15,7 @@ zip_safe = False
1515
package_dir =
1616
=pysrc
1717
packages = juliacall
18-
python_requires = ~=3.7
18+
python_requires = ~=3.8
1919
install_requires =
2020
juliapkg ~=0.1.8
2121

src/Compat/Compat.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Misc bits and bobs for compatibility.
66
module Compat
77
using ..PythonCall: PythonCall # needed for docstring cross-refs
88
using ..Core
9-
using ..Core: C, Utils, pynew, incref, getptr, pycopy!, pymodulehooks, pyisnull, pybytes_asvector, pysysmodule, pyosmodule, pystr_fromUTF8
9+
using ..Core: Core, C, Utils, pynew, incref, getptr, pycopy!, pymodulehooks, pyisnull, pybytes_asvector, pysysmodule, pyosmodule, pystr_fromUTF8
1010
using ..Convert: pyconvert, @pyconvert
1111
using ..Wrap: PyArray, PyPandasDataFrame
1212
using Serialization: Serialization, AbstractSerializer, serialize, deserialize

src/Compat/gui.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function init_gui()
130130
pycopy!(new_event_loop_callback, g["new_event_loop_callback"])
131131

132132
# add a hook to automatically call fix_qt_plugin_path()
133-
fixqthook = Py(() -> (_Py.CONFIG.auto_fix_qt_plugin_path && fix_qt_plugin_path(); nothing))
133+
fixqthook = Py(() -> (Core.CONFIG.auto_fix_qt_plugin_path && fix_qt_plugin_path(); nothing))
134134
pymodulehooks.add_hook("PyQt4", fixqthook)
135135
pymodulehooks.add_hook("PyQt5", fixqthook)
136136
pymodulehooks.add_hook("PySide", fixqthook)

src/Compat/pycall.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function init_pycall(PyCall::Module)
1010
- Set the environment variable `PYTHON` to `PythonCall.C.CTX.exe_path` and rebuild PyCall. This forces PyCall
1111
to use the same interpreter as PythonCall, but needs to be repeated whenever you switch Julia environment.
1212
"""
13-
@eval function _Py.Py(x::$PyCall.PyObject)
13+
@eval function Core.Py(x::$PyCall.PyObject)
1414
C.CTX.matches_pycall::Bool || error($errmsg)
1515
return pynew(C.PyPtr($PyCall.pyreturn(x)))
1616
end

src/Core/Core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Defines the `Py` type and directly related functions.
55
"""
66
module Core
77

8-
const VERSION = v"0.9.17"
8+
const VERSION = v"0.9.20"
99
const ROOT_DIR = dirname(dirname(@__DIR__))
1010

1111
using ..PythonCall: PythonCall # needed for docstring cross-refs
@@ -14,7 +14,7 @@ using ..GC: GC
1414
using ..Utils: Utils
1515
using Base: @propagate_inbounds, @kwdef
1616
using Dates: Date, Time, DateTime, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond
17-
using MacroTools: @capture
17+
using MacroTools: MacroTools, @capture
1818
using Markdown: Markdown
1919

2020
include("Py.jl")

src/JlWrap/JlWrap.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using ..PythonCall: PythonCall
99
using ..Core
1010
using ..Core: C, Utils, pynew, @autopy, incref, decref, setptr!, getptr, pyjuliacallmodule, pycopy!, errcheck, errset, PyNULL, pyistuple, pyisnull, pyJuliaError, pydel!, pyistype, pytypecheck, pythrow, pytuple_getitem, pyisslice, pystr_asstring, pyosmodule, pyisstr
1111
using ..Convert: pyconvert, @pyconvert, PYCONVERT_PRIORITY_WRAP, pyconvert_add_rule, pyconvert_tryconvert, pyconvertarg, pyconvert_result
12+
using ..GC: GC
1213

1314
using Pkg: Pkg
1415
using Base: @propagate_inbounds, allocatedinline

0 commit comments

Comments
 (0)