-
Notifications
You must be signed in to change notification settings - Fork 13
adds script for testing local msolve in AlgebraicSolving #124
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
Open
ederc
wants to merge
3
commits into
algebraic-solving:main
Choose a base branch
from
ederc:msolve-local
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # How to use the override scripts | ||
|
|
||
| ## Using AlgebraicSolving.jl with a different version of msolve than what `msolve_jll` provides | ||
|
|
||
| This can be useful for various reasons e.g., | ||
|
|
||
| - you need to test msolve.jl with a newer msolve version, perhaps even its master branch, | ||
| - you need to test with a msolve with custom compiler settings (e.g. to enable debugging), | ||
| - and so on. | ||
|
|
||
| For this to work, follow these instructions: | ||
|
|
||
| 1. Obtain a copy of the msolve sources, probably from a clone of the msolve git repository. | ||
| Let's say this is in directory `MSOLVEROOT`. | ||
|
|
||
| 2. Execute `./autogen.sh` in the `MSOLVEROOT` directory. | ||
|
|
||
| 3. Build msolve by executing the `etc/setup_override_dir.jl` script in the `override` environment. | ||
| Arguments: | ||
| - first argument: the `MSOLVEROOT` | ||
| - second argument: the directory where the override environment shall be installed, e.g. `/tmp/msolve_jll_override`. | ||
| - third argument (optional): a temp build directory to make use of incremental builds, | ||
| e.g. `/tmp/msolve_jll_override_build`. If not given, a temporary directory will be created | ||
| and deleted after the build. | ||
| - `--no-configure` (optional): if given, the script will not execute `./configure` in the `MSOLVEROOT`, | ||
| but assume that this has already been done. This can be useful if you want to save time by doing incremental builds, | ||
| or if you need to pass special arguments to `./configure` that the script does not know about. | ||
| - `--yes` (optional): if given, the script will not ask for confirmation before deleting the override directory (if it already exists). | ||
| - `--verbose` (optional): if given, the script will print more verbose output. | ||
|
|
||
| To give a concrete example you could invoke | ||
|
|
||
| julia --proj=override etc/setup_override_dir.jl $MSOLVEROOT /tmp/msolve_jll_override /tmp/msolve_jll_override_build | ||
|
|
||
| for the first time, and then for subsequent builds (after making changes to the msolve sources) you could invoke | ||
|
|
||
| julia --proj=override etc/setup_override_dir.jl $MSOLVEROOT /tmp/msolve_jll_override /tmp/msolve_jll_override_build --no-configure --yes | ||
|
|
||
| 4. Use the `etc/run_with_override.jl` script with the exact same Julia executable | ||
| and the override environment we just prepared. | ||
|
|
||
| julia --proj=override etc/run_with_override.jl /tmp/msolve_jll_override | ||
|
|
||
| 5. This opens a Julia session with the override in effect. You can now e.g. load AlgebraicSolving.jl | ||
| via `using AlgebraicSolving`, or install other packages (such as Oscar) and test with them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # | ||
| # parse arguments | ||
| # | ||
| length(ARGS) >= 1 || error("must provide path of msolve override directory as first argument") | ||
| msolveoverride = popfirst!(ARGS) | ||
|
|
||
| isdir(msolveoverride) || error("The given override path '$(msolveoverride)' is not a valid directory") | ||
| msolveoverride = abspath(msolveoverride) | ||
|
|
||
| # | ||
| # | ||
| # | ||
| @info "Install needed packages" | ||
| using Pkg | ||
| Pkg.develop(path=dirname(@__DIR__)) | ||
| Pkg.add(["msolve_jll"]) | ||
| Pkg.instantiate() | ||
|
|
||
| # | ||
| # | ||
| # | ||
| function add_jll_override(depot, pkgname, newdir) | ||
| pkgid = Base.identify_package("$(pkgname)_jll") | ||
| pkguuid = string(pkgid.uuid) | ||
| mkpath(joinpath(depot, "artifacts")) | ||
| open(joinpath(depot, "artifacts", "Overrides.toml"), "a") do f | ||
| write(f, """ | ||
| [$(pkguuid)] | ||
| $(pkgname) = "$(newdir)" | ||
| """) | ||
| end | ||
|
|
||
| # we need to make sure that precompilation is run again with the override in place | ||
| # (just running Pkg.precompile() does not seem to suffice) | ||
| run(`touch $(Base.locate_package(pkgid))`) | ||
| end | ||
|
|
||
| tmpdepot = mktempdir(; cleanup=true) | ||
| @info "Created temporary depot at $(tmpdepot)" | ||
|
|
||
| # create override file for msolve_jll | ||
| add_jll_override(tmpdepot, "msolve", msolveoverride) | ||
|
|
||
| # prepend our temporary depot to the depot list... | ||
| withenv( | ||
| "JULIA_DEPOT_PATH"=>tmpdepot*":"*join(DEPOT_PATH, ":"), | ||
| ) do | ||
|
|
||
| # ... and start Julia, by default with the same project environment | ||
| run(`$(Base.julia_cmd()) --project=$(Base.active_project()) $(ARGS)`) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # This Julia script sets up a directory with msolve compiled from a local path, | ||
| # then "installs" this msolve for use by the `run_with_override.jl` script | ||
|
|
||
| # | ||
| # parse arguments | ||
| # | ||
| length(ARGS) >= 1 || error("must provide path of msolve source directory as first argument") | ||
| length(ARGS) >= 2 || error("must provide path of destination directory as second argument") | ||
| msolve_prefix = popfirst!(ARGS) | ||
| prefix = popfirst!(ARGS) | ||
|
|
||
| if length(ARGS) > 0 && !startswith(ARGS[1], "--") | ||
| build_dir = popfirst!(ARGS) | ||
| else | ||
| build_dir = mktempdir(; cleanup = true) | ||
| end | ||
|
|
||
| run_configure = true | ||
| overwrite_allow = false | ||
| verbose = false | ||
| left_ARGS = String[] | ||
| while !isempty(ARGS) | ||
| arg = popfirst!(ARGS) | ||
| if arg == "--no-configure" | ||
| global run_configure = false | ||
| elseif arg == "--yes" | ||
| global overwrite_allow = true | ||
| elseif arg == "--verbose" | ||
| global verbose = true | ||
| else | ||
| push!(left_ARGS, arg) | ||
| end | ||
| end | ||
|
|
||
|
|
||
| # validate arguments | ||
| isdir(msolve_prefix) || error("The given msolve prefix '$(msolve_prefix)' is not a valid directory") | ||
| if ispath(prefix) | ||
| if !overwrite_allow | ||
| print("The given installation prefix '$(prefix)' already exists. Overwrite? [Y/n] ") | ||
| overwrite_allow = lowercase(readline()) in ["y", "yes", ""] | ||
| end | ||
| if overwrite_allow | ||
| rm(prefix; force=true, recursive=true) | ||
| else | ||
| error("Aborting") | ||
| end | ||
| end | ||
|
|
||
| # convert into absolute paths | ||
| mkpath(prefix) | ||
| prefix = abspath(prefix) | ||
| msolve_prefix = abspath(msolve_prefix) | ||
| mkpath(build_dir) | ||
| build_dir = abspath(build_dir) | ||
|
|
||
| # | ||
| # Install needed packages | ||
| # | ||
| @info "Install needed packages" | ||
| using Pkg | ||
| using Artifacts | ||
| Pkg.add(["JLLPrefixes"]) | ||
| Pkg.instantiate() | ||
|
|
||
| using JLLPrefixes | ||
|
|
||
| cd(build_dir) | ||
|
|
||
| if run_configure | ||
| @info "Configuring msolve in $(build_dir) for $(prefix)" | ||
|
|
||
| deps = ["GMP_jll", "FLINT_jll", "MPFR_jll"] | ||
| artifact_paths = collect_artifact_paths(deps) | ||
| deps_path = mktempdir(; cleanup=false) | ||
| deploy_artifact_paths(deps_path, artifact_paths) # collect all (transitive) dependencies into one tree | ||
|
|
||
| extraargs = [ | ||
| "CFLAGS=-I$(joinpath(deps_path, "include"))", | ||
| "LDFLAGS=-L$(joinpath(deps_path, "lib"))", | ||
| ] | ||
|
|
||
| configure_cmd = `$(msolve_prefix)/configure | ||
| --prefix=$(prefix) | ||
| $(extraargs) | ||
| $(left_ARGS) | ||
| ` | ||
|
|
||
| verbose && @show configure_cmd | ||
|
|
||
| # TODO: redirect the output of configure into a log file | ||
| @show run(configure_cmd) | ||
| end | ||
|
|
||
|
|
||
| @info "Building msolve in $(build_dir)" | ||
| run(`make -j$(Sys.CPU_THREADS) $(verbose ? "V=1" : [])`) | ||
|
|
||
| @info "Installing msolve to $(prefix)" | ||
| run(`make install $(verbose ? "V=1" : [])`) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.