Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GAP.jl usable as a Julia module with precompilation #249

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

sebasguts
Copy link
Contributor

@sebasguts sebasguts commented Jun 12, 2019

  • Move *.jl files from JuliaInterface to module itself
  • Add GAPTypes.jl package as dependency
  • Replaced MPtr by GapObj
  • Removed unnecessary libgap.jl
  • Moved MPtr call definition into init, eval into Main to not eval into a closed module

Resolves #265

@sebasguts sebasguts requested a review from fingolfin June 12, 2019 21:30
@codecov
Copy link

codecov bot commented Jun 12, 2019

Codecov Report

Merging #249 into master will increase coverage by 5.76%.
The diff coverage is 91.66%.

@@            Coverage Diff             @@
##           master     #249      +/-   ##
==========================================
+ Coverage   64.31%   70.07%   +5.76%     
==========================================
  Files          49       50       +1     
  Lines        3276     3262      -14     
==========================================
+ Hits         2107     2286     +179     
+ Misses       1169      976     -193
Impacted Files Coverage Δ
test/conversion.jl 100% <ø> (+100%) ⬆️
src/macros.jl 100% <ø> (ø)
src/ccalls.jl 98.38% <ø> (ø)
deps/build.jl 0% <ø> (ø) ⬆️
pkg/GAPJulia/JuliaInterface/read.g 100% <ø> (ø) ⬆️
src/julia_to_gap.jl 95.38% <0%> (ø)
src/gap_to_julia.jl 92.98% <100%> (ø)
src/GAP.jl 91.89% <100%> (+18.36%) ⬆️
src/gap2.jl 46% <92.85%> (ø)
... and 10 more

@sebasguts sebasguts force-pushed the enable_precompilation branch from 20a9a35 to 08ddcdd Compare June 13, 2019 08:47
pkg/GAPJulia/JuliaInterface/read.g Outdated Show resolved Hide resolved
src/GAP.jl Outdated Show resolved Hide resolved
src/GAP.jl Outdated Show resolved Hide resolved
src/GAP.jl Outdated Show resolved Hide resolved
src/GAP.jl Outdated Show resolved Hide resolved
src/ccalls.jl Outdated Show resolved Hide resolved
src/ccalls.jl Outdated Show resolved Hide resolved
src/ccalls.jl Outdated Show resolved Hide resolved
test/basics.jl Outdated Show resolved Hide resolved
src/julia_to_gap.jl Outdated Show resolved Hide resolved
@sebasguts sebasguts force-pushed the enable_precompilation branch 2 times, most recently from c8e491f to d88b5bd Compare June 14, 2019 14:14
@fingolfin fingolfin force-pushed the enable_precompilation branch from d88b5bd to 8c067bc Compare June 16, 2019 21:22
@sebasguts
Copy link
Contributor Author

Sorry, I was afk for the weekend. Will continue now.

@fingolfin fingolfin force-pushed the enable_precompilation branch 2 times, most recently from 7e4cfd1 to fb95746 Compare June 17, 2019 15:33
@sebasguts sebasguts force-pushed the enable_precompilation branch 4 times, most recently from 8293594 to 0b3e664 Compare June 18, 2019 15:22
deps/build.jl Outdated
println("DEPOT = ", DEPOT_PATH)

println("................ENV.............")
println(ENV)
Copy link
Member

Choose a reason for hiding this comment

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

Is this for debugging or is it meant to say here?

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

There are some kinks (see comments) but if you want, we can just merge this now and resolve those later (perhaps best to record them as issues, though)

## Hack to make GAPTypes available in the global package environment:
## For a moment, we set the Julia load path to the actual depot, i.e.,
## the env GAP.jl is installed to, to install GAPTypes.jl globally
julia_load_path_save = ENV["JULIA_LOAD_PATH"]
Copy link
Member

Choose a reason for hiding this comment

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

Is ENV["JULIA_LOAD_PATH"] guaranteed (by documentation / specification) to be set at this point? If it is not, then this line could throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this build script is (or better should, nobody is keeping you from shooting yourself in the foot) only executed by the package manager, yes, I am sure this is always set.

julia_load_path_save = ENV["JULIA_LOAD_PATH"]
pop!( ENV, "JULIA_LOAD_PATH" )
julia_executable = joinpath(julia_binary, "julia")
run(`$(julia_executable) -e 'import Pkg; Pkg.add("GAPTypes")'`)
Copy link
Member

Choose a reason for hiding this comment

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

Wow, that is a gross hack. I am also not quite sure why it is needed? Surely, GAP's configure also takes care of it? OK, perhaps the problem is that it inherits the JULIA_LOAD_PATH? But then at the very least, the comment above should explain so.

But I also wonder (very naively, so there is probably an easy answer why this won't work): couldn't we make the code in GAP more flexible, and ask it to first check if GAP.GAPTypes is available, then use that; if not, try to use GAPTypes directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I am painfully aware that this is gross, and should not be done this way. On the other hand, the Julia package manager sets this environment variable, too, which is also not very nice of it.

Actually, patching GAP this way would be possible, although not for the 4.10.2 release I guess. But then we can at least remove that hack afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will leave one more comment. The problem is that for the configure script, this somehow failed to give me the right responses when we asked for flags. I have no real idea why yet. This solution is merely the result of a lot of try-and-error.

src/GAP.jl Outdated Show resolved Hide resolved
* Move *.jl files from JuliaInterface to module itself
* Add GAPTypes.jl package as dependency
* Replaced MPtr by GapObj
* Removed unnecessary libgap.jl
* Moved MPtr call definition into init, eval into Main
  to not eval into a closed module
@sebasguts sebasguts force-pushed the enable_precompilation branch from 85ddeb5 to 5a1572f Compare June 19, 2019 09:45
@sebasguts sebasguts merged commit 5e104af into oscar-system:master Jun 19, 2019
@sebasguts sebasguts deleted the enable_precompilation branch June 19, 2019 14:27
@mohamed-barakat
Copy link
Contributor

I get the following error:

julia> using GAP
[ Info: Recompiling stale cache file ~/.julia/compiled/v1.1/GAP/YqHod.ji for GAP [c863536a-3901-11e9-33e7-d5cd0df7b904]
Adding path /Users/mo/.julia/dev/GAP/gap/.libs to DL_LOAD_PATH
 ┌───────┐   GAP 4.10dev-2052-gf30c1e4 of today
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-apple-darwin18.2.0-julia64-kv6
 Configuration:  gmp 6.1.2, Julia GC, Julia 1.1.0, readline
 Loading the library and packages ...
 Packages:   GAPDoc 1.6.2, PrimGrp 3.3.2, SmallGrp 1.3, TransGrp 2.0.4
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'
Error, MethodError: Cannot `convert` an object of type Main.ForeignGAP.MPtr to an object of type GAPTypes.GapObj
Closest candidates are:
  convert(::Type{T}, !Matched::T) where T at essentials.jl:154
ERROR: InitError: Error thrown by GAP
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] error_handler() at /Users/mo/.julia/dev/GAP/src/GAP.jl:47
 [3] initialize(::Array{String,1}, ::Array{String,1}, ::Ptr{Nothing}) at /Users/mo/.julia/dev/GAP/src/GAP.jl:67
 [4] (::getfield(GAP, Symbol("##3#4")))(::String, ::Ptr{Nothing}) at /Users/mo/.julia/dev/GAP/src/GAP.jl:97
 [5] __init__() at /Users/mo/.julia/dev/GAP/src/GAP.jl:115
 [6] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:633
 [7] _require_from_serialized(::String) at ./loading.jl:684
 [8] _require(::Base.PkgId) at ./loading.jl:967
 [9] require(::Base.PkgId) at ./loading.jl:858
 [10] require(::Module, ::Symbol) at ./loading.jl:853
during initialization of module GAP

@sebasguts sebasguts restored the enable_precompilation branch June 20, 2019 08:53
@sebasguts
Copy link
Contributor Author

Please do not put bug reports in closed PR's, but create an issue instead. Anyway, will investigate.

@mohamed-barakat
Copy link
Contributor

I was about to do that. This is just for reference.

@sebasguts
Copy link
Contributor Author

I have to admit, I cannot reproduce this. Did you update everything? Including GAP itself?

@mohamed-barakat
Copy link
Contributor

As you suggest, I deleted GAP.jl/gap for

pkg> build GAP

to work. Now using GAP works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make GAPTypes.jl a dependency in the Project.toml
3 participants