Skip to content

Commit dfc2022

Browse files
authored
Fix AOT tests for PackageCompiler 1.x (#768)
* Fix AOT tests for PackageCompiler 1.x * Make sure PyCall is compiled into aot/sys.so
1 parent b30f56c commit dfc2022

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ matrix:
4949
# https://github.com/pytest-dev/pytest/pull/3893
5050

5151
- &test-aot
52-
name: "AOT (Julia: 1.0)"
52+
name: "AOT (Julia: 1.4)"
5353
language: julia
5454
os: linux
5555
env: PYTHON=python3
56-
julia: 1.0
56+
julia: 1.4
5757
script:
58-
- julia --color=yes -e 'using Pkg; Pkg.add("PackageCompiler")'
58+
- julia --color=yes -e 'using Pkg; pkg"add PackageCompiler@1"'
5959
- julia --color=yes aot/compile.jl
60+
- aot/assert_has_pycall.jl
6061
- aot/runtests.sh
6162
after_success: skip
6263
- {<<: *test-aot, name: "AOT (Julia: nightly)", julia: nightly}

aot/assert_has_pycall.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# -*- mode: julia -*-
3+
#=
4+
thisdir="$(dirname "${BASH_SOURCE[0]}")"
5+
exec "$thisdir/julia.sh" --startup-file=no "$@" ${BASH_SOURCE[0]}
6+
=#
7+
8+
pkgid = Base.PkgId(Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0"), "PyCall")
9+
sysimage_path = unsafe_string(Base.JLOptions().image_file)
10+
if haskey(Base.loaded_modules, pkgid)
11+
@info "PyCall is compiled in: `$(sysimage_path)`"
12+
else
13+
error("PyCall is not compiled in: ", sysimage_path)
14+
end

aot/compile.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
exec "${JULIA:-julia}" "$@" ${BASH_SOURCE[0]}
55
=#
66

7+
using Libdl
8+
using PackageCompiler
79
using Pkg
10+
811
Pkg.activate(@__DIR__)
9-
Pkg.add("MacroTools")
1012
Pkg.develop(PackageSpec(name="PyCall", path=dirname(@__DIR__)))
1113
Pkg.build("PyCall")
1214
Pkg.activate()
1315

14-
using PackageCompiler
15-
sysout, _curr_syso = compile_incremental(
16-
joinpath(@__DIR__, "Project.toml"),
17-
joinpath(@__DIR__, "precompile.jl"),
16+
sysimage_path = joinpath(@__DIR__, "sys.$(Libdl.dlext)")
17+
create_sysimage(
18+
[:PyCall],
19+
sysimage_path = sysimage_path,
20+
project = @__DIR__(),
21+
precompile_execution_file = joinpath(@__DIR__, "precompile.jl"),
1822
)
1923

20-
pysysout = joinpath(@__DIR__, basename(sysout))
21-
cp(sysout, pysysout, force=true)
22-
2324
write(joinpath(@__DIR__, "_julia_path"), Base.julia_cmd().exec[1])
2425

25-
@info "System image: $pysysout"
26+
@info "System image: $sysimage_path"

aot/precompile.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
# Activate ./Project.toml. Excluding `"@v#.#"` from `Base.LOAD_PATH`
2-
# to make compilation more reproducible.
3-
using Pkg
4-
empty!(Base.LOAD_PATH)
5-
append!(Base.LOAD_PATH, ["@", "@stdlib"])
6-
Pkg.activate(@__DIR__)
7-
8-
# Manually invoking `__init__` to workaround:
9-
# https://github.com/JuliaLang/julia/issues/22910
10-
11-
import MacroTools
12-
isdefined(MacroTools, :__init__) && MacroTools.__init__()
13-
141
using PyCall
15-
PyCall.__init__()
162
PyCall.pyimport("sys")[:executable]
173

184
has_numpy = try

0 commit comments

Comments
 (0)