Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom package orderer and fixed package orderer sort logic #1680

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/rez/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setup_parser(parser, completions=False):

def command(opts, parser, extra_arg_groups=None):
from rez.config import config
from rez.utils.yaml import dump_yaml
from rez.utils.yaml import dump_yaml, YamlDumpable
from rez.utils.data_utils import convert_json_safe

if opts.search_list:
Expand All @@ -54,7 +54,7 @@ def command(opts, parser, extra_arg_groups=None):
except KeyError:
raise ValueError("no such setting: %r" % opts.FIELD)

if isinstance(data, (dict, list)):
if isinstance(data, (dict, list, YamlDumpable)):
if opts.json:
txt = json.dumps(convert_json_safe(data))
else:
Expand Down
20 changes: 16 additions & 4 deletions src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ def _validate(self, data):
if self.key in self.config.overrides:
return data

if not self.config.locked:

# next, env-var
# next, env-var
if self._env_var_name and not self.config.locked:
value = os.getenv(self._env_var_name)
if value is not None:
if self.key in _deprecated_settings:
Expand Down Expand Up @@ -361,6 +360,19 @@ def _parse_env_var(self, value):
return value


class PackageOrderers(Setting):
@cached_class_property
def schema(cls):
from rez.package_order import from_pod, OrdererDict
return Or(
Schema(And(
[Use(from_pod)],
Use(OrdererDict)
)), None)

_env_var_name = None


config_schema = Schema({
"packages_path": PathList,
"plugin_path": PathList,
Expand Down Expand Up @@ -496,7 +508,7 @@ def _parse_env_var(self, value):
"env_var_separators": Dict,
"variant_select_mode": VariantSelectMode_,
"package_filter": OptionalDictOrDictList,
"package_orderers": OptionalDictOrDictList,
"package_orderers": PackageOrderers,
"new_session_popen_args": OptionalDict,
"context_tracking_amqp": OptionalDict,
"context_tracking_extra_fields": OptionalDict,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
name = "pyvariants"
version = "2"

variants = [["python-2.7.0"], ["python-2.6.8", "nada"]]
variants = [
["python-2.7.0"],
["python-2.6.8", "nada"],
["python-2.6.8"],
["nada"],
]
31 changes: 31 additions & 0 deletions src/rez/data/tests/solver/packages/reorderable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name = 'reorderable'

versions = [
"3.1.1",
"3.0.0",
"2.2.1",
"2.2.0",
"2.1.5",
"2.1.1",
"2.1.0",
"2.0.6",
"2.0.5",
"2.0.0",
"1.9.1",
"1.9.0",
]

# Note - we've intentionally left out timestamps for 2.2.0 and 1.9.1 to
# make sure the system still works
version_overrides = {
"3.1.1": {"timestamp": 1470728488},
"3.0.0": {"timestamp": 1470728486},
"2.1.5": {"timestamp": 1470728484},
"2.2.1": {"timestamp": 1470728482},
"2.1.1": {"timestamp": 1470728480},
"2.1.0": {"timestamp": 1470728478},
"2.0.6": {"timestamp": 1470728476},
"2.0.5": {"timestamp": 1470728474},
"2.0.0": {"timestamp": 1470728472},
"1.9.0": {"timestamp": 1470728470},
}
Loading