File tree 1 file changed +14
-20
lines changed
1 file changed +14
-20
lines changed Original file line number Diff line number Diff line change 5
5
from os .path import isfile
6
6
import os .path
7
7
from glob import glob
8
+ import re
8
9
from os import environ
9
10
import numbers
10
11
from cffi import FFI
53
54
54
55
if "GUROBI_HOME" in environ :
55
56
if platform .lower ().startswith ("win" ):
56
- libfile = glob (
57
- os . path . join ( os . environ [ "GUROBI_HOME" ], "bin \\ gurobi[0-9][0-9][0-9] .dll")
58
- )
57
+ lib_path_dir = os . path . join ( os . environ [ "GUROBI_HOME" ], "bin" , "*" )
58
+ pattern = r" gurobi( [0-9]{2,3}) .dll"
59
+
59
60
else :
60
- libfile = glob (
61
- os .path .join (os .environ ["GUROBI_HOME" ], "lib/libgurobi[0-9][0-9][0-9].*" )
62
- )
63
- if not libfile :
64
- libfile = glob (
65
- os .path .join (
66
- os .environ ["GUROBI_HOME" ],
67
- "lib/libgurobi.so.[0-9].[0-9].[0-9].*" ,
68
- )
69
- )
61
+ lib_path_dir = os .path .join (os .environ ["GUROBI_HOME" ], "lib" , "*" )
62
+ pattern = r"libgurobi([0-9]{2,3})[.].*"
70
63
71
- if libfile :
72
- lib_path = libfile [0 ]
64
+ for libfile in glob (lib_path_dir ):
65
+ match = re .match (pattern , os .path .basename (libfile ))
66
+ if match :
67
+ lib_path = libfile
73
68
74
- # checking gurobi version
75
- s1 = lib_path .split ('"' )[- 1 ].split ("/" )[- 1 ]
76
- vs = [c for c in s1 if c .isdigit ()]
77
- major_ver = vs [0 ]
78
- minor_ver = vs [1 ]
69
+ # checking gurobi version
70
+ major_ver = match .group (1 )[:- 1 ]
71
+ minor_ver = match .group (1 )[- 1 ]
72
+ break
79
73
80
74
if lib_path is None :
81
75
for major_ver in reversed (range (6 , 11 )):
You can’t perform that action at this time.
0 commit comments