Fix OpenCV detection on Ubuntu (#35336)
* fix OpenCV detection on Ubuntu * Update package.py * Simplify version detection * remove superfluous `return`
This commit is contained in:
parent
f34f207bdc
commit
055263fa3c
1 changed files with 17 additions and 12 deletions
|
@ -822,35 +822,40 @@ class Opencv(CMakePackage, CudaPackage):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def determine_version(cls, lib):
|
def determine_version(cls, lib):
|
||||||
ver = None
|
|
||||||
for ext in library_extensions:
|
for ext in library_extensions:
|
||||||
pattern = None
|
|
||||||
if ext == "dylib":
|
if ext == "dylib":
|
||||||
# Darwin switches the order of the version compared to Linux
|
# Darwin switches the order of the version compared to Linux
|
||||||
pattern = re.compile(r"lib(\S*?)_(\S*)\.(\d+\.\d+\.\d+)\.%s" % ext)
|
pattern = re.compile(r"libopencv_(\S*?)\.(\d+\.\d+\.\d+)\.%s" % ext)
|
||||||
else:
|
else:
|
||||||
pattern = re.compile(r"lib(\S*?)_(\S*)\.%s\.(\d+\.\d+\.\d+)" % ext)
|
pattern = re.compile(r"libopencv_(\S*?)\.%s\.(\d+\.\d+\.\d+)" % ext)
|
||||||
match = pattern.search(lib)
|
match = pattern.search(lib)
|
||||||
if match:
|
if match:
|
||||||
ver = match.group(3)
|
return match.group(2)
|
||||||
return ver
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def determine_variants(cls, libs, version_str):
|
def determine_variants(cls, libs, version_str):
|
||||||
variants = []
|
variants = []
|
||||||
remaining_modules = set(Opencv.modules)
|
remaining_modules = set(cls.modules + cls.contrib_modules)
|
||||||
|
contrib_module_set = set(cls.contrib_modules)
|
||||||
|
has_contrib = False
|
||||||
for lib in libs:
|
for lib in libs:
|
||||||
for ext in library_extensions:
|
for ext in library_extensions:
|
||||||
pattern = None
|
pattern = None
|
||||||
if ext == "dylib":
|
if ext == "dylib":
|
||||||
# Darwin switches the order of the version compared to Linux
|
# Darwin switches the order of the version compared to Linux
|
||||||
pattern = re.compile(r"lib(\S*?)_(\S*)\.(\d+\.\d+\.\d+)\.%s" % ext)
|
pattern = re.compile(r"libopencv_(\S*)\.(\d+\.\d+\.\d+)\.%s" % ext)
|
||||||
else:
|
else:
|
||||||
pattern = re.compile(r"lib(\S*?)_(\S*)\.%s\.(\d+\.\d+\.\d+)" % ext)
|
pattern = re.compile(r"libopencv_(\S*)\.%s\.(\d+\.\d+\.\d+)" % ext)
|
||||||
match = pattern.search(lib)
|
match = pattern.search(lib)
|
||||||
if match and not match.group(2) == "core":
|
if match:
|
||||||
variants.append("+" + match.group(2))
|
name = match.group(1)
|
||||||
remaining_modules.remove(match.group(2))
|
if name in contrib_module_set:
|
||||||
|
has_contrib = True
|
||||||
|
if name in remaining_modules:
|
||||||
|
variants.append("+" + name)
|
||||||
|
remaining_modules.remove(name)
|
||||||
|
if has_contrib:
|
||||||
|
variants.append("+contrib")
|
||||||
|
|
||||||
# If libraries are not found, mark those variants as disabled
|
# If libraries are not found, mark those variants as disabled
|
||||||
for mod in remaining_modules:
|
for mod in remaining_modules:
|
||||||
|
|
Loading…
Reference in a new issue