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

glob in WORKSPACE files (and .bzl files loaded by same) #11935

Closed
shs96c opened this issue Aug 12, 2020 · 8 comments
Closed

glob in WORKSPACE files (and .bzl files loaded by same) #11935

shs96c opened this issue Aug 12, 2020 · 8 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@shs96c
Copy link
Contributor

shs96c commented Aug 12, 2020

Description of the feature request:

A glob() function for repository rules would be useful for repo rules.

Use cases include:

  • Setting a dependency on e.g. a lockfile that may or may not exist with something like glob(“my.lockfile”, allow_empty=True). This would be useful for rules_jvm_external where a user has to know whether rules have been pinned or not when re-pinning.
  • Providing a bunch of vendored dependencies needed by a repo rule (e.g. python wheels or jars we want to generate rules for).

Feature requests: what underlying problem are you trying to solve with this feature?

Sometimes, it's just not possible or it's impractical to enumerate all the inputs while writing the entry in a WORKSPACE file. In addition, it requires a file to be present, and sometimes it's useful to check for the presence of the file itself.

What's the output of bazel info release?

3.4.1

@gregestren gregestren added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged type: feature request labels Aug 13, 2020
@philwo philwo added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Nov 25, 2020
@wt
Copy link
Contributor

wt commented Sep 21, 2021

I would love to see this so that I could glob in diffs for a http_repository. That would be awesome.

@wt
Copy link
Contributor

wt commented Sep 21, 2021

Oh, and I am using release 4.1.0rc4.

@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 24, 2023
@fmeum
Copy link
Collaborator

fmeum commented May 24, 2023

Cc @Wyverald, this seems related to your proposal

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label May 25, 2023
@bcsgh
Copy link

bcsgh commented Feb 27, 2024

Another use case would be to collect state that a generated repo rule depends on. In my case I'm wanting to expose the git tags on the current HEAD so that they can be passed as tags to oci_push.remote_tags. I can get the repository_rule to re-sync when HEAD changes by depending on @//:.git/HEAD but that only works for pre known paths.

FWIW; adding this would if anything make things more hermetic because repository_rule()s can already reach out to thing that are not listed. This would allow such cases to at least try to update correctly.

@Wyverald
Copy link
Member

dupe of #20952 (which is fixed in 7.1.0; see cherry-pick PR #21435)

@Wyverald Wyverald closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@bcsgh
Copy link

bcsgh commented Feb 28, 2024

@Wyverald do you have a link to the relevant end user documentation? After reading through the referenced issue, I'm not clear on what was actually done there or what I should be using to solve this use case.

@Wyverald
Copy link
Member

The new method repository_ctx.watch() allows you to watch for changes to one path (and methods such as repository_ctx.read() gain a new parameter that automatically causes them to start watching); path.readdir() now has a new parameter that allows you to watch for changes in the entries directly under a directory; and repository_ctx.watch_tree() allows you to watch for changes to everything under a directory tree.

These changes will be included in the 7.1.0 release notes (which are still being edited right now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants