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

Evaluate requirements expansion delaying in REP-002 #7

Closed
davidlatwe opened this issue Mar 31, 2021 · 1 comment
Closed

Evaluate requirements expansion delaying in REP-002 #7

davidlatwe opened this issue Mar 31, 2021 · 1 comment

Comments

@davidlatwe
Copy link
Owner

davidlatwe commented Mar 31, 2021

Before start, here are some references about tasks in REP-002 that are related :

  • 001: delay requirements expansion after resolve
  • 003: Add --env option to package build tools, related to REP-002.006
  • 006: Add requirements harden directive (new requirements expansion syntax)
  • 010: Add recipes_path config setting
  • 011: Implement rez-install tool and API

Allan reached out and have a quick talk about REP-002 on implementing REP-002.001 and REP-002.006 (delay requirements expansion). Which are highly related to this project. In matter of fact, this project is the implementation of REP-002.011, but in a different way.

What rez-deliver have done

- For the record, at this time being, this project is named rez-deliver. (may renamed afterward) -

Currently in rez-deliver when building a package, say package foo, rez-deliver loads all developer packages (via DeveloperPackage.from_path) into a memory repository,

yield DeveloperPackage.from_path(pkg_path)

and join them as normal packages with other already installed packages when resolving build-time context for foo. And recursively resolve more build-time contexts for each package from dependent package's context.resolved_packages.

context = self._build_context(variant)
for pkg in context.resolved_packages:
self.resolve(request=pkg.qualified_package_name,
variant_index=pkg.index)

Then, a full dependency list of foo has been generated with ordered, rez-deliver will start to install packages that are not yet been installed.

Now back to REP-002

From the description of REP-002, tasks 001 and 006 are parts of the prerequisites of 011, since one may have package requirement like "bar-1.*" in the developer package definition file that need to be expanded in build-time. But for the rez-install (REP-002.011), it may need to expand the requirement statement to the package that is not yet been installed. Hence REP-002.001 and REP-002.006, the expansion needs to be delayed till context resolver resolved.

However in this project, all developer packages are loaded into a memory package repository before build, so the requirement expansion can be done without a problem.

So maybe we don't have to delay it after all ? 🤔

But if we do implement the delaying, the Requirement object will have to store a few more data to let solver know that it need to be expanded after resolve and it cannot be solved with other regular requirements, owning to the VersionRange object cannot parse a range like "bar-1.*+" stated.

from rez.vendor.version.version import VersionRange
print(VersionRange("1.*+"))
# rez.vendor.version.util.VersionError: Syntax error in version range '1.*+': Syntax error in version range '1.*+'

This is an obstacle. Maybe we could convert that legacy expansion syntax "bar-1.*+" into what 006 introduced

"bar-1\\harden(2)"

before resolve, and harden(expand) it after resolve.

So say we addressed that, I guess those un-hardened requirements will be expanded with the --env bar-1.5 (REP-002.003), or iterate over recipes repository and expand it from there ?

Not sure, this need a bit more discuss.

@davidlatwe
Copy link
Owner Author

davidlatwe commented May 6, 2021

So maybe we don't have to delay it after all ?

We do need this in some cases, but just for building package.
As long as all required developer packages are in place and loaded as build-time status, it doesn't matter how requirement shall change in one package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant