diff --git a/src/rez/package_py_utils.py b/src/rez/package_py_utils.py index bd1ad9ba1..a1066ee22 100644 --- a/src/rez/package_py_utils.py +++ b/src/rez/package_py_utils.py @@ -29,6 +29,9 @@ def expand_requirement(request): Returns: str: Expanded request string. """ + if '*' not in request: + return request + from rez.vendor.version.requirement import VersionedObject, Requirement from rez.packages_ import get_latest_package diff --git a/src/rez/package_resources_.py b/src/rez/package_resources_.py index 4f9d30a24..feaada688 100644 --- a/src/rez/package_resources_.py +++ b/src/rez/package_resources_.py @@ -393,7 +393,7 @@ class _Metas(AttributeForwardMeta, LazyAttributeMeta): pass schema = variant_schema # forward Package attributes onto ourself - keys = schema_keys(package_schema) - set(["requires", "variants"]) + keys = schema_keys(package_schema) - set(["variants"]) def _uri(self): index = self.index @@ -418,11 +418,6 @@ def _root(self): root = os.path.join(self.base, self.subpath) return root - #@cached_property - #def requires(self): - # reqs = self.parent.requires or [] - # return reqs + self.variant_requires - @cached_property def variant_requires(self): index = self.index diff --git a/src/rez/rex.py b/src/rez/rex.py index 5b70556f9..08760cf17 100644 --- a/src/rez/rex.py +++ b/src/rez/rex.py @@ -1158,6 +1158,8 @@ def compile_code(cls, code, filename=None, exec_namespace=None): code.exec_(globals_=exec_namespace) else: exec pyc in exec_namespace + except RexError: + raise except SourceCodeError as e: reraise(e, RexError) except error_class as e: @@ -1195,8 +1197,14 @@ def execute_function(self, func, *nargs, **kwargs): try: return fn(*nargs, **kwargs) + except RexError: + raise except error_class as e: + from inspect import getfile + stack = traceback.format_exc() + filename = getfile(func) + raise RexError("Failed to exec %s:\n\n%s" % (filename, stack)) def get_output(self, style=OutputStyle.file): diff --git a/src/rez/tests/test_packages.py b/src/rez/tests/test_packages.py index 836bd39ee..d17d0daef 100644 --- a/src/rez/tests/test_packages.py +++ b/src/rez/tests/test_packages.py @@ -184,20 +184,21 @@ def test_5(self): def test_6(self): """test variant iteration.""" - expected_data_ = dict( + expected_data = dict( name="variants_py", version=Version("2.0"), description="package with variants", base=os.path.join(self.py_packages_path, "variants_py", "2.0"), + requires=[PackageRequest("python-2.7")], commands=SourceCode('env.PATH.append("{root}/bin")')) requires_ = ["platform-linux", "platform-osx"] package = get_package("variants_py", "2.0") for i, variant in enumerate(package.iter_variants()): - expected_data = expected_data_.copy() - expected_data["requires"] = [PackageRequest('python-2.7'), - PackageRequest(requires_[i])] + #expected_data = expected_data_.copy() + #expected_data["requires"] = [PackageRequest('python-2.7'), + # PackageRequest(requires_[i])] data = variant.validated_data() self.assertDictEqual(data, expected_data) self.assertEqual(variant.index, i) diff --git a/src/rez/utils/data_utils.py b/src/rez/utils/data_utils.py index 3b187b174..0965d68f4 100644 --- a/src/rez/utils/data_utils.py +++ b/src/rez/utils/data_utils.py @@ -465,7 +465,7 @@ def func(self, key, attr, schema): @classmethod def _make_getter(cls, key, attribute, optional, key_schema): def getter(self): - if key not in self._data: + if key not in (self._data or {}): if optional: return None raise self.schema_error("Required key is missing: %r" % key) diff --git a/src/rezplugins/package_repository/filesystem.py b/src/rezplugins/package_repository/filesystem.py index 58ecb040c..4b574589a 100644 --- a/src/rezplugins/package_repository/filesystem.py +++ b/src/rezplugins/package_repository/filesystem.py @@ -760,11 +760,15 @@ def _create_variant(self, variant, dry_run=False, overrides=None): new_package_data.pop("variants", None) package_changed = False - for key in package_build_only_keys: - new_package_data.pop(key, None) + def remove_build_keys(obj): + for key in package_build_only_keys: + obj.pop(key, None) + + remove_build_keys(new_package_data) if existing_package: existing_package_data = existing_package.validated_data() + remove_build_keys(existing_package_data) # detect case where new variant introduces package changes outside of variant data_1 = existing_package_data.copy()