Skip to content

Commit e631362

Browse files
authored
change behavior of Knitro.jl when shared lib is not detected (#219)
1 parent 216e8b8 commit e631362

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

deps/build.jl

+3-5
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ for path in reverse(paths_to_try)
4242
end
4343
end
4444

45-
if get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true"
46-
write_depsfile("", "julia_registryci_automerge")
47-
elseif !found_knitro
48-
error("Unable to locate KNITRO installation, " *
49-
"please check your environment variable KNITRODIR.")
45+
if !found_knitro
46+
write_depsfile("", "")
5047
end
48+

src/KNITRO.jl

+9-4
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ end
1010
using Libdl, SparseArrays
1111
import Base: show
1212

13-
const KNITRO_VERSION = if libknitro == "julia_registryci_automerge"
14-
VersionNumber(11, 0, 0) # Fake a valid version for AutoMerge
15-
else
13+
const IS_KNITRO_LOADED = endswith(libknitro, Libdl.dlext)
14+
15+
const KNITRO_VERSION = if IS_KNITRO_LOADED
1616
len = 15
1717
out = zeros(Cchar, len)
1818
ccall((:KTR_get_release, libknitro), Any, (Cint, Ptr{Cchar}), len, out)
1919
res = String(strip(String(convert(Vector{UInt8}, out)), '\0'))
2020
VersionNumber(split(res, " ")[2])
21+
else
22+
VersionNumber(0, 0, 0) # Fake a version for AutoMerge
2123
end
2224

23-
if KNITRO_VERSION < v"11.0"
25+
if KNITRO_VERSION != v"0.0.0" && KNITRO_VERSION < v"11.0"
2426
error(
2527
"You have installed version $KNITRO_VERSION of Artelys Knitro, which is not supported
2628
by KNITRO.jl. We require a Knitro version greater than 11.0.
2729
",
2830
)
2931
end
3032

33+
has_knitro() = IS_KNITRO_LOADED
34+
knitro_version() = KNITRO_VERSION
35+
3136
include("libknitro.jl")
3237
include("C_wrapper.jl")
3338
include("callbacks.jl")

0 commit comments

Comments
 (0)