Skip to content

Commit

Permalink
Merge pull request #11 from davidlatwe/buildtime-variants
Browse files Browse the repository at this point in the history
Buildtime variants
  • Loading branch information
davidlatwe authored May 24, 2021
2 parents 23213eb + b062d7c commit 98c5bd4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 12 additions & 1 deletion src/deliver/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ def main():
parser.add_argument("--release", action="store_true")
opts, remains = parser.parse_known_args()

# for case like:
#
# `tests.test_manifest.TestManifest.test_buildtime_variants`
#
# which requires to scan packages to list out current available variants,
# we resolve the request here again and append loader paths for including
# developer packages in that scan.
#
solver = RequestSolver()
solver.resolve(opts.PKG)

# build/release
#
settings = {
"packages_path": solver.installed_packages_path,
# developer packages loader paths appended, see comment above.
"packages_path": solver.installed_packages_path + solver.loader.paths,
}
with override_config(settings):
command = "release" if opts.release else "build"
Expand Down
18 changes: 12 additions & 6 deletions src/deliver/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def __repr__(self):
variant_index_regex = re.compile(r"(.+)\[([0-9]+)]")


def split_variant_request(request):
"""Parse request string and split up variant index"""
result = variant_index_regex.split(request)
index = None
if not result[0]:
request, index = result[1:3]
index = int(index)

return PackageRequest(request), index


class RequestSolver(object):
"""Package installation manifest resolver"""

Expand Down Expand Up @@ -127,13 +138,8 @@ def resolve(self, *requests):

for request in requests:
# parse variant index
result = variant_index_regex.split(request)
index = None
if not result[0]:
request, index = result[1:3]
index = int(index)
_request, index = split_variant_request(request)
# filtering requests
_request = PackageRequest(request)
if _request.conflict:
conflicts.append(request)
else:
Expand Down
9 changes: 3 additions & 6 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,10 @@ def test_resolve_with_external(self):
def test_buildtime_variants(self):
@early()
def variants():
from rez import packages
bindings = ["pyqt", "pyside"]
if building:
return [[binding] for binding in bindings]
else:
from rez import packages
return [[binding] for binding in bindings
if packages.get_latest_package_from_string(binding)]
return [[binding] for binding in bindings
if packages.get_latest_package_from_string(binding)]

self.dev_repo.add("shim", build_command=False, variants=variants)
self.dev_repo.add("pyqt", build_command=False)
Expand Down

0 comments on commit 98c5bd4

Please sign in to comment.