Skip to content

Commit d13bd61

Browse files
committed
[core] plugins: Correctly handle installed virtual envs on Linux
1 parent 0e46cbe commit d13bd61

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

meshroom/core/plugins.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,33 @@ class DirTreeProcessEnv(ProcessEnv):
9797
def __init__(self, folder: str, configEnv: dict[str: str]):
9898
super().__init__(folder, configEnv, envType=ProcessEnvType.DIRTREE)
9999

100-
venvLibPaths = glob.glob(f'{folder}/lib*/python[0-9].[0-9]*/site-packages', recursive=False)
100+
# If there is a virtual environment, it is expected to be named "venv".
101+
# Beside the virtual environment, a standard "bin"/"lib"/"lib64" hierarchy at
102+
# the top level of the plugin folder is expected.
103+
venvFolder = Path(folder, "venv")
101104

102-
self.binPaths: list = [str(Path(folder, "bin"))]
103-
self.libPaths: list = [str(Path(folder, "lib")), str(Path(folder, "lib64"))]
104-
self.pythonPaths: list = [str(Path(folder))] + self.binPaths + venvLibPaths
105+
# Find all the libs that are not directly at the "lib*"-level
106+
envLibPaths = glob.glob(f'{folder}/lib*/python[0-9].[0-9]*/site-packages', recursive=False)
107+
108+
self.binPaths: list = [str(Path(folder, "bin")), str(Path(venvFolder, "bin"))]
109+
self.libPaths: list = [str(Path(folder, "lib")), str(Path(folder, "lib64")),
110+
str(Path(venvFolder, "lib")), str(Path(venvFolder, "lib64"))]
111+
self.pythonPaths: list = [str(Path(folder)), str(Path(venvFolder))] + \
112+
self.binPaths + envLibPaths
105113

106114
if sys.platform == "win32":
107115
# For Windows platforms, try and include the content of the virtual env if it exists
108116
# The virtual env is expected to be named "venv"
109-
venvPath = Path(folder, "venv", "Lib", "site-packages")
110-
if venvPath.exists():
111-
self.pythonPaths.append(venvPath.as_posix())
117+
venvLibPath = Path(venvFolder, "Lib", "site-packages")
118+
if venvLibPath.exists():
119+
self.pythonPaths.append(venvLibPath.as_posix())
112120
else:
113121
# For Linux platforms, lib paths may need to be discovered recursively to be properly
114122
# added to LD_LIBRARY_PATH
115123
extraLibPaths = []
116124
regex = re.compile(r"^lib(\d{2})?$")
117-
for venvPath in venvLibPaths:
118-
for path, directories, _ in os.walk(venvPath):
125+
for envPath in envLibPaths:
126+
for path, directories, _ in os.walk(envPath):
119127
for directory in directories:
120128
if re.match(regex, directory):
121129
extraLibPaths.append(os.path.join(path, directory))
@@ -137,7 +145,6 @@ def __init__(self, folder: str, configEnv: dict[str: str]):
137145
self._env[k] = val
138146

139147

140-
141148
class RezProcessEnv(ProcessEnv):
142149
"""
143150
"""

0 commit comments

Comments
 (0)