Skip to content

Commit

Permalink
Issue AcademySoftwareFoundation#1557 - Add support for overriding bui…
Browse files Browse the repository at this point in the history
…lt-in bind modules.

Signed-off-by: Michael Nowakowski <m_nowakowski@apple.com>
  • Loading branch information
Pantsworth committed Jan 17, 2024
1 parent 7e8617d commit 980eab9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Empty file.
3 changes: 3 additions & 0 deletions src/rez/data/tests/bind/os.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Custom bind module override
"""
8 changes: 4 additions & 4 deletions src/rez/package_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def get_bind_modules(verbose=False):
"""Get available bind modules.
Returns:
dict: Map of (name, filepath) listing all bind modules.
dict[str, str]: Map of (name, filepath) listing all bind modules.
"""
builtin_path = os.path.join(module_root_path, "bind")
searchpaths = config.bind_module_path + [builtin_path]
searchpaths = [builtin_path] + config.bind_module_path
bindnames = {}

for path in searchpaths:
Expand Down Expand Up @@ -85,14 +85,14 @@ def bind_package(name, path=None, version_range=None, no_deps=False,
Args:
name (str): Package name.
path (str): Package path to install into; local packages path if None.
version_range (`VersionRange`): If provided, only bind the software if
version_range (rez.vendor.version.version.VersionRange): If provided, only bind the software if
it falls within this version range.
no_deps (bool): If True, don't bind dependencies.
bind_args (list of str): Command line options.
quiet (bool): If True, suppress superfluous output.
Returns:
List of `Variant`: The variant(s) that were installed as a result of
list[rez.packages.Variant]: The variant(s) that were installed as a result of
binding this package.
"""
pending = set([name])
Expand Down
23 changes: 23 additions & 0 deletions src/rez/tests/test_bind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
test package_bind module
"""
import os
import unittest
from rez import package_bind
from rez.tests.util import TestBase


class TestPackageBind(TestBase):
def test_os_module_override(self):
"""Test that bind_module_path can override built-in bind modules"""
self.update_settings(dict(
bind_module_path=[self.data_path("bind")]
))

os_module_path = os.path.join(self.data_path("bind"), "os.py")
os_bind_module = package_bind.find_bind_module("os")
self.assertEqual(os_bind_module, os_module_path)


if __name__ == '__main__':
unittest.main()

0 comments on commit 980eab9

Please sign in to comment.