File tree Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Original file line number Diff line number Diff line change 55from os .path import isfile
66import os .path
77from glob import glob
8+ import re
89from os import environ
910import numbers
1011from cffi import FFI
5354
5455if "GUROBI_HOME" in environ :
5556 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+
5960 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})[.].*"
7063
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
7368
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
7973
8074if lib_path is None :
8175 for major_ver in reversed (range (6 , 11 )):
You can’t perform that action at this time.
0 commit comments