Skip to content

Commit 8db4a99

Browse files
committed
Merge branch 'master' into pr/Roger-luo/918
2 parents b1a461c + f77394b commit 8db4a99

File tree

11 files changed

+75
-37
lines changed

11 files changed

+75
-37
lines changed

.github/workflows/TagBot.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: TagBot
22
on:
3-
schedule:
4-
- cron: 0 * * * *
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
57
jobs:
68
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
710
runs-on: ubuntu-latest
811
steps:
912
- uses: JuliaRegistries/TagBot@v1

.github/workflows/aot.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ jobs:
1616
os:
1717
- ubuntu-latest
1818
architecture: [x64]
19-
python-version: ['3.8']
20-
julia-version: ['1.5', 'nightly']
19+
python-version: ['3.x']
20+
julia-version:
21+
- '1'
22+
- '~1.7.0-rc1'
23+
# - 'nightly' # TODO: reenable
2124
fail-fast: false
2225
env:
2326
PYTHON: python${{ matrix.python-version }}
@@ -34,6 +37,9 @@ jobs:
3437
architecture: ${{ matrix.architecture }}
3538
- run: python --version
3639
- run: python -m pip install --user numpy scipy
40+
- name: Install libpython2.7 for `find_libpython` test
41+
run: sudo apt-get install python2.7-dev
42+
if: ${{ matrix.python-version != '2.7' && matrix.os == 'ubuntu-latest' }}
3743
- name: Setup julia
3844
uses: julia-actions/setup-julia@v1
3945
with:

.github/workflows/conda.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
- macos-latest
1919
- windows-latest
2020
architecture: [x64]
21-
julia-version: ['1.5']
21+
julia-version: ['1']
2222
include:
2323
- os: windows-latest
2424
architecture: x86
25-
julia-version: '1.5'
25+
julia-version: '1'
2626
fail-fast: false
2727
env:
2828
PYTHON: ""
@@ -32,6 +32,9 @@ jobs:
3232
${{ matrix.os }} ${{ matrix.architecture }}
3333
steps:
3434
- uses: actions/checkout@v1
35+
- name: Install libpython2.7 for `find_libpython` test
36+
run: sudo apt-get install python2.7-dev
37+
if: ${{ matrix.python-version != '2.7' && matrix.os == 'ubuntu-latest' }}
3538
- name: Setup julia
3639
uses: julia-actions/setup-julia@v1
3740
with:

.github/workflows/system.yml

+25-7
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,40 @@ jobs:
1818
- macos-latest
1919
- windows-latest
2020
architecture: [x64]
21-
python-version: ['2.7', '3.8']
22-
julia-version: ['1.0', '1.5', 'nightly']
21+
python-version: ['3.x']
22+
julia-version:
23+
- '1.0'
24+
- '1'
25+
- 'nightly'
2326
include:
27+
# 32 bit Windows:
2428
- os: windows-latest
2529
architecture: x86
26-
python-version: '3.8'
30+
python-version: '3.x'
2731
julia-version: '1.5'
32+
# Sweep python-version and julia-version only on Ubuntu:
2833
- os: ubuntu-latest
2934
architecture: x64
30-
python-version: '3.7'
35+
python-version: '3.9'
36+
julia-version: '1'
37+
- os: ubuntu-latest
38+
architecture: x64
39+
python-version: '3.x'
3140
julia-version: '1.5'
3241
- os: ubuntu-latest
3342
architecture: x64
34-
python-version: '3.8'
43+
python-version: '3.x'
3544
julia-version: '1.4'
45+
# Test Python 2.7 only with a few combinations (TODO: drop 2.7).
46+
# Note that it does not work in macOS:
3647
- os: ubuntu-latest
3748
architecture: x64
38-
python-version: '3.8'
39-
julia-version: '1.3'
49+
python-version: '2.7'
50+
julia-version: '1'
51+
- os: windows-latest
52+
architecture: x64
53+
python-version: '2.7'
54+
julia-version: '1'
4055
fail-fast: false
4156
name: Test
4257
Julia ${{ matrix.julia-version }}
@@ -56,6 +71,9 @@ jobs:
5671
if: ${{ matrix.python-version != '2.7' }}
5772
- run: virtualenv --version
5873
if: ${{ matrix.python-version != '2.7' }}
74+
- name: Install libpython2.7 for `find_libpython` test
75+
run: sudo apt-get install python2.7-dev
76+
if: ${{ matrix.python-version != '2.7' && matrix.os == 'ubuntu-latest' }}
5977
- name: Setup julia
6078
uses: julia-actions/setup-julia@v1
6179
with:

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PyCall"
22
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
33
authors = ["Steven G. Johnson <[email protected]>", "Yichao Yu <[email protected]>", "Takafumi Arakaki <[email protected]>", "Simon Kornblith <[email protected]>", "Páll Haraldsson <[email protected]>", "Jon Malmaud <[email protected]>", "Jake Bolewski <[email protected]>", "Keno Fischer <[email protected]>", "Joel Mason <[email protected]>", "Jameson Nash <[email protected]>", "The JuliaPy development team"]
4-
version = "1.92.3"
4+
version = "1.92.4"
55

66
[deps]
77
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ install the files. Julia 0.7 or later is required.
2020

2121
The latest development version of PyCall is available from
2222
<https://github.com/JuliaPy/PyCall.jl>. If you want to switch to
23-
this after installing the package, run `Pkg.checkout("PyCall"); Pkg.build("PyCall")`.
23+
this after installing the package, run:
24+
25+
```julia
26+
Pkg.add(PackageSpec(name="PyCall", rev="master"))
27+
Pkg.build("PyCall")`
28+
```
2429

2530
By default on Mac and Windows systems, `Pkg.add("PyCall")`
2631
or `Pkg.build("PyCall")` will use the
@@ -298,7 +303,7 @@ use `PyDict` as the return type of a `pycall` returning a dictionary,
298303
or call `PyDict(o::PyObject)` on a dictionary object `o`. By
299304
default, a `PyDict` is an `Any => Any` dictionary (or actually `PyAny
300305
=> PyAny`) that performs runtime type inference, but if your Python
301-
dictionary has known, fixed types you can insteady use `PyDict{K,V}` given
306+
dictionary has known, fixed types you can instead use `PyDict{K,V}` given
302307
the key and value types `K` and `V` respectively.
303308

304309
Currently, passing Julia dictionaries to Python makes a copy of the Julia
@@ -359,7 +364,8 @@ and also by providing more type information to the Julia compiler.
359364
Python's [`eval`](https://docs.python.org/3/library/functions.html#eval) function, and returns the result
360365
converted to `PyAny`. Alternatively, `py"..."o` returns the raw `PyObject`
361366
(which can then be manually converted if desired). You can interpolate
362-
Julia variables and other expressions into the Python code with `$`,
367+
Julia variables and other expressions into the Python code (except for into
368+
Python strings contained in Python code), with `$`,
363369
which interpolates the *value* (converted to `PyObject`) of the given
364370
expression---data is not passed as a string, so this is different from
365371
ordinary Julia string interpolation. e.g. `py"sum($([1,2,3]))"` calls the
@@ -387,7 +393,7 @@ and also by providing more type information to the Julia compiler.
387393
* `pybuiltin(s)`: Look up `s` (a string or symbol) among the global Python
388394
builtins. If `s` is a string it returns a `PyObject`, while if `s` is a
389395
symbol it returns the builtin converted to `PyAny`. (You can also use `py"s"`
390-
to look up builtins or other Python globas.)
396+
to look up builtins or other Python globals.)
391397

392398
Occasionally, you may need to pass a keyword argument to Python that
393399
is a [reserved word](https://en.wikipedia.org/wiki/Reserved_word) in Julia.

deps/build.jl

+7-12
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mkpath(dirname(prefsfile))
4343
try # make sure deps.jl file is removed on error
4444
python = try
4545
let py = get(ENV, "PYTHON", isfile(prefsfile) ? readchomp(prefsfile) :
46-
(Sys.isunix() && !Sys.isapple()) || Sys.ARCH (:i686, :x86_64) ?
46+
(Sys.isunix() && !Sys.isapple()) ?
4747
whichfirst("python3", "python") : "Conda"),
4848
vers = isempty(py) || py == "Conda" ? v"0.0" : vparse(pyconfigvar(py,"VERSION","0.0"))
4949
if vers < v"2.7"
@@ -64,19 +64,14 @@ try # make sure deps.jl file is removed on error
6464
py
6565
end
6666
catch e1
67-
if Sys.ARCH in (:i686, :x86_64)
68-
if isa(e1, UseCondaPython)
69-
@info string("Using the Python distribution in the Conda package by default.\n",
70-
"To use a different Python version, set ENV[\"PYTHON\"]=\"pythoncommand\" and re-run Pkg.build(\"PyCall\").")
71-
else
72-
@info string( "No system-wide Python was found; got the following error:\n",
73-
"$e1\nusing the Python distribution in the Conda package")
74-
end
75-
abspath(Conda.PYTHONDIR, "python" * (Sys.iswindows() ? ".exe" : ""))
67+
if isa(e1, UseCondaPython)
68+
@info string("Using the Python distribution in the Conda package by default.\n",
69+
"To use a different Python version, set ENV[\"PYTHON\"]=\"pythoncommand\" and re-run Pkg.build(\"PyCall\").")
7670
else
77-
error("No system-wide Python was found; got the following error:\n",
78-
"$e1")
71+
@info string("No system-wide Python was found; got the following error:\n",
72+
"$e1\nusing the Python distribution in the Conda package")
7973
end
74+
abspath(Conda.PYTHONDIR, "python" * (Sys.iswindows() ? ".exe" : ""))
8075
end
8176

8277
use_conda = dirname(python) == abspath(Conda.PYTHONDIR)

src/PyCall.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ that you did not install $name in the Python version being used by PyCall.
512512
PyCall is currently configured to use the Julia-specific Python distribution
513513
installed by the Conda.jl package. To install the $name module, you can
514514
use `pyimport_conda("$(escape_string(name))", PKG)`, where PKG is the Anaconda
515-
package the contains the module $name, or alternatively you can use the
515+
package that contains the module $name, or alternatively you can use the
516516
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
517517
518518
Alternatively, if you want to use a different Python distribution on your

src/exception.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ end
140140
#########################################################################
141141
# Mapping of Julia Exception types to Python exceptions
142142

143-
const pyexc = Dict{DataType, PyPtr}()
143+
const pyexc = IdDict{DataType, PyPtr}()
144144
mutable struct PyIOError <: Exception end
145145

146146
function pyexc_initialize()
@@ -213,7 +213,7 @@ end
213213

214214
function pyraise(e, bt = nothing)
215215
eT = typeof(e)
216-
pyeT = haskey(pyexc::Dict, eT) ? pyexc[eT] : pyexc[Exception]
216+
pyeT = haskey(pyexc, eT) ? pyexc[eT] : pyexc[Exception]
217217
err = PyJlError(e, bt)
218218
ccall((@pysym :PyErr_SetObject), Cvoid, (PyPtr, PyPtr),
219219
pyeT, PyObject(err))

src/io.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
function ioraise(e, bt = nothing)
1212
if isa(e, MethodError) || isa(e, ErrorException)
1313
ccall((@pysym :PyErr_SetString), Cvoid, (PyPtr, Cstring),
14-
(pyexc::Dict)[PyIOError],
14+
pyexc[PyIOError],
1515
showerror_string(e, bt))
1616
else
1717
pyraise(e, bt)

test/check_deps_version.jl

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
using Test
2-
const desired_version = VersionNumber(ARGS[1])
2+
const desired_version_str = ARGS[1] # e.g., "2.7", "3.10.0", "3.x"
33
include("../deps/deps.jl")
4-
@testset "pyversion_build ≈ $desired_version" begin
4+
@testset "pyversion_build ≈ $desired_version_str" begin
5+
v = desired_version_str
6+
while endswith(v, ".x")
7+
v = v[1:end-2]
8+
end
9+
desired_version = VersionNumber(v)
510
@test desired_version.major == pyversion_build.major
6-
@test desired_version.minor == pyversion_build.minor
11+
if desired_version.minor != 0
12+
@test desired_version.minor == pyversion_build.minor
13+
end
714
if desired_version.patch != 0
815
@test desired_version.patch == pyversion_build.patch
916
end

0 commit comments

Comments
 (0)