Skip to content

Commit

Permalink
-fixed most tests, one fail left
Browse files Browse the repository at this point in the history
  • Loading branch information
ajohns committed Feb 28, 2017
1 parent 70ed6d1 commit 8258507
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/rez/package_py_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions src/rez/package_resources_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/rez/rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 5 additions & 4 deletions src/rez/tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/rez/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/rezplugins/package_repository/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8258507

Please sign in to comment.