Skip to content

Commit

Permalink
Add XPRESS_JL_LIBRARY
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 11, 2024
1 parent 2bdbc5b commit deb0a5d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ jobs:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
# - uses: julia-actions/julia-buildpkg@v1
# - uses: julia-actions/julia-runtest@v1
- name: Test
shell: julia --color=yes --project=. {0}
run: |
import Pkg
Pkg.pkg"add https://github.com/jump-dev/Xpress_jll.jl"
Pkg.test()
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ version = "0.16.2"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Xpress_jll = "308bddfa-7f95-4fa6-a557-f2c7addc1869"

[compat]
Downloads = "<0.0.1, 1"
Expand Down
7 changes: 6 additions & 1 deletion src/Lib/Lib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
module Lib

import ..Xpress
const libxprs = Xpress.libxprs
global libxprs = Xpress.libxprs

function _set_libxprs(new_libxprs)
global libxprs = new_libxprs
return
end

include("common.jl")
include("xprs.jl")
Expand Down
24 changes: 13 additions & 11 deletions src/Xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ import SparseArrays
# Load in `deps.jl`, complaining if it does not exist
const depsjl_path = joinpath(@__DIR__, "..", "deps", "deps.jl")

if isfile(depsjl_path)
include(depsjl_path)
const libxprs = joinpath(
xpressdlpath,
string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext),
)
else
import Xpress_jll
const libxprs = Xpress_jll.libxprs
end
libxprs = ""

include("Lib/Lib.jl")

Expand All @@ -45,7 +36,6 @@ const XPRS_ATTRIBUTES = Dict{String,Any}(
)

function initialize()
Libdl.dlopen(libxprs)
userlic()
init() # Call XPRSinit for initialization
return
Expand All @@ -55,6 +45,18 @@ include("MOI/MOI_wrapper.jl")
include("MOI/MOI_callbacks.jl")

function __init__()
if isfile(depsjl_path)
include(depsjl_path)
global libxprs = joinpath(
xpressdlpath,
string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext),
)
elseif haskey(ENV, "XPRESS_JL_LIBRARY")
global libxprs = ENV["XPRESS_JL_LIBRARY"]
elseif !haskey(ENV, "XPRESS_JL_NO_DEPS_ERROR")
error("XPRESS cannot be loaded. Please run Pkg.build(\"Xpress\").")

Check warning on line 57 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L54-L57

Added lines #L54 - L57 were not covered by tests
end
Lib._set_libxprs(libxprs)
if !haskey(ENV, "XPRESS_JL_NO_AUTO_INIT") &&
get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") != "true"
initialize()
Expand Down
3 changes: 2 additions & 1 deletion src/license.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function get_xpauthpath(xpauth_path = "", verbose::Bool = true)

# user´s lib dir
push!(candidates, joinpath(dirname(dirname(libxprs)), "bin", XPAUTH))
# Add the license location of Xpress_jll
# Add the license location of Xpress_jll. Make sure this is last, so that we
# find the user's license if one exists.
push!(
candidates,
joinpath(dirname(dirname(libxprs)), "license", "community-xpauth.xpr"),
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

import Pkg

if get(ENV, "CI", "false") == "true"
Pkg.pkg"add https://github.com/jump-dev/Xpress_jll.jl"
import Xpress_jll
ENV["XPRESS_JL_LIBRARY"] = Xpress_jll.libxprs
end

using Test
using Xpress

Expand Down

0 comments on commit deb0a5d

Please sign in to comment.