Skip to content

Commit

Permalink
Use Xpress_jll for binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 1, 2024
1 parent b5bc1e7 commit 57c5350
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
version: ['1.6', '1'] # Test against LTS and current minor release
os: [windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
arch: [x64]
steps:
- uses: actions/checkout@v2
Expand All @@ -30,12 +30,14 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
env:
SECRET_XPRS_WIN: ${{ secrets.XPRS_WIN_900 }}
SECRET_XPRL_WIN: ${{ secrets.XPRL_WIN_900 }}
SECRET_XPRA_WIN: ${{ secrets.XPAUTH_XPR }}
- uses: julia-actions/julia-runtest@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/odow/Xpress_jll.jl"
Pkg.test()
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ version = "0.16.2"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
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]
MathOptInterface = "1"
Expand Down
30 changes: 16 additions & 14 deletions src/Xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# 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.

__precompile__()

module Xpress

using Libdl
Expand All @@ -14,14 +12,12 @@ module Xpress

if isfile(depsjl_path)
include(depsjl_path)
elseif !haskey(ENV, "XPRESS_JL_NO_DEPS_ERROR")
error("XPRESS cannot be loaded. Please run Pkg.build(\"Xpress\").")
const libxprs = joinpath(xpressdlpath, string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext))
else
const xpressdlpath = ""
import Xpress_jll
const libxprs = Xpress_jll.libxprs
end

const libxprs = joinpath(xpressdlpath, string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext))

### imports

import Base.show, Base.copy
Expand Down Expand Up @@ -52,14 +48,20 @@ module Xpress

function initialize()
Libdl.dlopen(libxprs)
userlic()
try
userlic()

Check warning on line 52 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L51-L52

Added lines #L51 - L52 were not covered by tests
catch err
license = joinpath(

Check warning on line 54 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L54

Added line #L54 was not covered by tests
dirname(dirname(libxprs)), "license", "community-xpauth.xpr")
try
@assert isfile(license)
userlic(; xpauth_path = license)

Check warning on line 58 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L56-L58

Added lines #L56 - L58 were not covered by tests
catch
rethrow(err)

Check warning on line 60 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L60

Added line #L60 was not covered by tests
end
end
init() # Call XPRSinit for initialization
# free is not strictly necessary since destroyprob is called
# inthe finalizer.
# the user can call free if needed.
# leaving it uncommented results in many print errors becaus
# it is called prior to finalizers.
# atexit(free) # Call free when process terminates
return

Check warning on line 64 in src/Xpress.jl

View check run for this annotation

Codecov / codecov/patch

src/Xpress.jl#L64

Added line #L64 was not covered by tests
end

include("MOI/MOI_wrapper.jl")
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ println("Optimizer version: $(Xpress.get_version())")
"xprs_callbacks",
"Derivative",
]
@testset "$(file)" for file in readdir(folder)
include(joinpath(folder, file))
@testset "$(file)" for file in readdir(joinpath(@__DIR__, folder))
include(joinpath(@__DIR__, folder, file))
end
end

Expand Down

0 comments on commit 57c5350

Please sign in to comment.