Skip to content

Commit

Permalink
change behavior of Knitro.jl when shared lib is not detected (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
frapac authored Jun 3, 2022
1 parent 216e8b8 commit e631362
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 3 additions & 5 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ for path in reverse(paths_to_try)
end
end

if get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true"
write_depsfile("", "julia_registryci_automerge")
elseif !found_knitro
error("Unable to locate KNITRO installation, " *
"please check your environment variable KNITRODIR.")
if !found_knitro
write_depsfile("", "")
end

13 changes: 9 additions & 4 deletions src/KNITRO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@ end
using Libdl, SparseArrays
import Base: show

const KNITRO_VERSION = if libknitro == "julia_registryci_automerge"
VersionNumber(11, 0, 0) # Fake a valid version for AutoMerge
else
const IS_KNITRO_LOADED = endswith(libknitro, Libdl.dlext)

const KNITRO_VERSION = if IS_KNITRO_LOADED
len = 15
out = zeros(Cchar, len)
ccall((:KTR_get_release, libknitro), Any, (Cint, Ptr{Cchar}), len, out)
res = String(strip(String(convert(Vector{UInt8}, out)), '\0'))
VersionNumber(split(res, " ")[2])
else
VersionNumber(0, 0, 0) # Fake a version for AutoMerge
end

if KNITRO_VERSION < v"11.0"
if KNITRO_VERSION != v"0.0.0" && KNITRO_VERSION < v"11.0"
error(
"You have installed version $KNITRO_VERSION of Artelys Knitro, which is not supported
by KNITRO.jl. We require a Knitro version greater than 11.0.
",
)
end

has_knitro() = IS_KNITRO_LOADED
knitro_version() = KNITRO_VERSION

include("libknitro.jl")
include("C_wrapper.jl")
include("callbacks.jl")
Expand Down

0 comments on commit e631362

Please sign in to comment.