Skip to content

Commit 391afc7

Browse files
authored
Merge pull request #2898 from alicevision/dev/psutilDep
[core] Rez plugins: Ensure dependencies for `meshroom_compute` are present This PR introduces a mechanism to ensure that required dependencies for meshroom_compute, specifically psutil, are always included in the node execution environment for rez plugins. Dependencies for meshroom_compute are added to the environment without specifying any version or attempting to match Meshroom's, in order for it to be set directly during the environment resolution.
2 parents e9e637d + 9b94471 commit 391afc7

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

meshroom/core/desc/node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
_MESHROOM_ROOT = Path(meshroom.__file__).parent.parent.as_posix()
1919
_MESHROOM_COMPUTE = (Path(_MESHROOM_ROOT) / "bin" / "meshroom_compute").as_posix()
20+
_MESHROOM_COMPUTE_DEPS = ["psutil"]
2021

2122

2223
class MrNodeType(enum.Enum):

meshroom/core/plugins.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from meshroom.common import BaseObject
1616
from meshroom.core import desc
17-
from meshroom.core.desc.node import _MESHROOM_ROOT
17+
from meshroom.core.desc.node import _MESHROOM_ROOT, _MESHROOM_COMPUTE_DEPS
1818

1919

2020
def validateNodeDesc(nodeDesc: desc.Node) -> list:
@@ -161,10 +161,10 @@ def __init__(self, folder: str, configEnv: dict[str: str], uri: str = ""):
161161

162162
def resolveRezSubrequires(self) -> list[str]:
163163
"""
164-
Return the list of packages defined for the node execution. These execution packages are named
165-
subrequires.
166-
Note: If a package does not have a version number, the version is aligned with the main Meshroom
167-
environment (if this package is defined).
164+
Return the list of packages defined for the node execution. These execution packages are
165+
named subrequires.
166+
Note: If a package does not have a version number, the version is aligned with the main
167+
Meshroom environment (if this package is defined).
168168
"""
169169
subrequires = os.environ.get(f"{self.uri.upper()}_SUBREQUIRES", "").split(os.pathsep)
170170
if not subrequires:
@@ -184,8 +184,8 @@ def resolveRezSubrequires(self) -> list[str]:
184184
resolvedVersions[name] = version
185185
logging.debug("Packages in the current environment: " + ", ".join(currentEnvPackages))
186186

187-
# Take packages with the set versions for those which have one, and try to take packages in the current
188-
# environment (if they are resolved in it)
187+
# Take packages with the set versions for those which have one, and try to take packages
188+
# in the current environment (if they are resolved in it)
189189
for package in subrequires:
190190
packageTuple = self.REZ_DELIMITER_PATTERN.split(package, maxsplit=1)
191191
match len(packageTuple):
@@ -202,6 +202,19 @@ def resolveRezSubrequires(self) -> list[str]:
202202
# The subrequires ask for a specific version
203203
packages.append(package)
204204

205+
def extractPackageName(packageString: str) -> str:
206+
return self.REZ_DELIMITER_PATTERN.split(packageString, maxsplit=1)[0]
207+
packageNames = [extractPackageName(package) for package in packages]
208+
209+
for package in _MESHROOM_COMPUTE_DEPS:
210+
# For packages that are required by meshroom_compute, do not specify any version
211+
# or align it with Meshroom's: the version will be found during the resolution of
212+
# the environment based on the other packages.
213+
# If any of these packages is already part of the environment a plugin's dependency,
214+
# do not add it
215+
if package not in packageNames:
216+
packages.append(package)
217+
205218
logging.debug("Packages for the execution environment: " + ", ".join(packages))
206219
return packages
207220

0 commit comments

Comments
 (0)