Skip to content

Commit

Permalink
Fix AOT tests for PackageCompiler 1.x (JuliaPy#768)
Browse files Browse the repository at this point in the history
* Fix AOT tests for PackageCompiler 1.x

* Make sure PyCall is compiled into aot/sys.so
  • Loading branch information
tkf authored May 2, 2020
1 parent b30f56c commit dfc2022
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ matrix:
# https://github.com/pytest-dev/pytest/pull/3893

- &test-aot
name: "AOT (Julia: 1.0)"
name: "AOT (Julia: 1.4)"
language: julia
os: linux
env: PYTHON=python3
julia: 1.0
julia: 1.4
script:
- julia --color=yes -e 'using Pkg; Pkg.add("PackageCompiler")'
- julia --color=yes -e 'using Pkg; pkg"add PackageCompiler@1"'
- julia --color=yes aot/compile.jl
- aot/assert_has_pycall.jl
- aot/runtests.sh
after_success: skip
- {<<: *test-aot, name: "AOT (Julia: nightly)", julia: nightly}
Expand Down
14 changes: 14 additions & 0 deletions aot/assert_has_pycall.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# -*- mode: julia -*-
#=
thisdir="$(dirname "${BASH_SOURCE[0]}")"
exec "$thisdir/julia.sh" --startup-file=no "$@" ${BASH_SOURCE[0]}
=#

pkgid = Base.PkgId(Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0"), "PyCall")
sysimage_path = unsafe_string(Base.JLOptions().image_file)
if haskey(Base.loaded_modules, pkgid)
@info "PyCall is compiled in: `$(sysimage_path)`"
else
error("PyCall is not compiled in: ", sysimage_path)
end
19 changes: 10 additions & 9 deletions aot/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
exec "${JULIA:-julia}" "$@" ${BASH_SOURCE[0]}
=#

using Libdl
using PackageCompiler
using Pkg

Pkg.activate(@__DIR__)
Pkg.add("MacroTools")
Pkg.develop(PackageSpec(name="PyCall", path=dirname(@__DIR__)))
Pkg.build("PyCall")
Pkg.activate()

using PackageCompiler
sysout, _curr_syso = compile_incremental(
joinpath(@__DIR__, "Project.toml"),
joinpath(@__DIR__, "precompile.jl"),
sysimage_path = joinpath(@__DIR__, "sys.$(Libdl.dlext)")
create_sysimage(
[:PyCall],
sysimage_path = sysimage_path,
project = @__DIR__(),
precompile_execution_file = joinpath(@__DIR__, "precompile.jl"),
)

pysysout = joinpath(@__DIR__, basename(sysout))
cp(sysout, pysysout, force=true)

write(joinpath(@__DIR__, "_julia_path"), Base.julia_cmd().exec[1])

@info "System image: $pysysout"
@info "System image: $sysimage_path"
14 changes: 0 additions & 14 deletions aot/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
# Activate ./Project.toml. Excluding `"@v#.#"` from `Base.LOAD_PATH`
# to make compilation more reproducible.
using Pkg
empty!(Base.LOAD_PATH)
append!(Base.LOAD_PATH, ["@", "@stdlib"])
Pkg.activate(@__DIR__)

# Manually invoking `__init__` to workaround:
# https://github.com/JuliaLang/julia/issues/22910

import MacroTools
isdefined(MacroTools, :__init__) && MacroTools.__init__()

using PyCall
PyCall.__init__()
PyCall.pyimport("sys")[:executable]

has_numpy = try
Expand Down

0 comments on commit dfc2022

Please sign in to comment.