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

package manager: allow overriding dependencies with local cache #20348

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dweiller
Copy link
Contributor

@dweiller dweiller commented Jun 19, 2024

This resolves #20180 (the package overriding portion not the proposed command for examining the dependency tree). While the issue is not accepted I've found this very useful myself and should be mergeable (sans any issues with the testing approach explained below), so I expect to continue updating/rebasing this PR until the issue is either accepted or rejected.

The approach taken is to change the package root written to the generated dependencies.zig file to point into the local cache. In addition a new .local_override field is added to facilitate warning messages produced by the build runner.

I have some tests for verifying the behaviour of the package overriding at configure time (i.e. that the correct build.zig is used for the package) and compile time (that the correct version of the package is used), but I'm not sure at the moment how to integrate them into the test system as I don't think there is a way to get the effect of passing the --global-cache-dir, --cache-dir and --system flags to standalone tests, which would be needed for checking that the right thing happens when these flags are passed to zig build.

PR #20281 implements the tool described in #20180 for examining the hashes of dependencies - it could be merged into this PR, but it is also useful separately and the two PRs are not inter-dependant.

@dweiller dweiller marked this pull request as draft June 19, 2024 08:50
@Cloudef
Copy link
Contributor

Cloudef commented Jun 21, 2024

Btw you should probably remove the draft marker

@dweiller
Copy link
Contributor Author

Btw you should probably remove the draft marker

I don't think it's ready to merge until I figure out at least a way to get tests integrated with the build system.

@dweiller
Copy link
Contributor Author

dweiller commented Jun 26, 2024

I've added tests to the CI by directly modifying the CI scripts for linux and macos runners (I don't know the ps1 script syntax, so thought I'd better not mess with those). This seemed to be the simplest way to pass the cache-related flags to zig build, but if the approach taken is not an appropriate strategy let me know and I'll come up with something else.

The downside of the approach taken is that running zig build test can't be used to locally run the dependency overriding tests - you need to change directory to test/dependency_override and run ./run-tests.sh script with a positional argument for the path to a Zig compiler. The upside is that all the testing logic and filesystem side-effects (other than some normal usage of the global cache) are isolated to the test/dependency_override directory. Since testing the behaviour depends on placing various versions of packages into the global, local and --system directories, achieving the same solely within build.zig is probably going to be more complicated.

There also isn't a Windows equivalent of the run-tests.sh script.

@dweiller dweiller marked this pull request as ready for review June 26, 2024 09:34
@dweiller dweiller force-pushed the local-pkg branch 2 times, most recently from 490097a to a8b5691 Compare June 26, 2024 14:43
@dweiller dweiller changed the title package manager: allow overriding deps with local cache package manager: allow overriding dependencies with local cache Jul 12, 2024
@dweiller
Copy link
Contributor Author

dweiller commented Jul 18, 2024

I've added tests to the CI by directly modifying the CI scripts for linux and macos runners (I don't know the ps1 script syntax, so thought I'd better not mess with those).

This will conflict with the work being done in the ci-scripts branch, but moving the CI script changes to the build.zig files but should be straightforward to port.

@dweiller dweiller force-pushed the local-pkg branch 2 times, most recently from 31ad131 to 68d8cac Compare August 21, 2024 03:29
@alexrp alexrp added this to the 0.14.0 milestone Jan 30, 2025
@andrewrk andrewrk removed this from the 0.14.0 milestone Mar 1, 2025
@dweiller dweiller marked this pull request as draft March 2, 2025 04:12
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

Successfully merging this pull request may close these issues.

ability to override packages locally
4 participants