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

Implement proper, language-agnostic handling of runfiles trees #2339

Open
cnsgsz opened this issue Jan 5, 2017 · 7 comments
Open

Implement proper, language-agnostic handling of runfiles trees #2339

cnsgsz opened this issue Jan 5, 2017 · 7 comments
Assignees
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request

Comments

@cnsgsz
Copy link

cnsgsz commented Jan 5, 2017

I have a python test named foo whose main is foo.py that depends on cpp binary. I have it set up as recommended in #703. It works when it is run in bazel test.

However, I sometimes want to run the python test manually by invoking foo (the executable python script that's generated by bazel that sits in the same bazel-bin directory as foo.runfiles). However it complains that the cpp binary cannot be found.

I tried something like #231, but sys.argv[0] points to foo.py and it does not seem straightforward to get the cpp binary path from there?

It is not just for python test. Sometime I have a python binary that depends on cpp binary too. But I assume they are similar.

Since bazel generates foo and put the specified data in foo.runfiles already, it seems natural that I should be able to just specify some relative path as in #703, call foo from any cwd, and foo does the work to make sure the cpp binary can be found based on the relative path? Or is it possible for foo to pass foo.py some environment variable RUNFILES_DIR that foo.py can use like os.path.join(RUNFILES_DIR, "relative/path/to/cpp/binary")?

@ulfjack
Copy link
Contributor

ulfjack commented Jan 24, 2017

We had to roll back the change. Why isn't that commit linked here?

@lberki
Copy link
Contributor

lberki commented Jan 31, 2017

So, after some consultation with @ulfjack , I realized that we can't solve this in a principled way without figuring out how runfiles trees should work in general. Therefore, I'm changing this bug to "we should really figure out how runfiles trees should work" in general.

@lberki lberki changed the title access cpp binary from python binary Implement proper, language-agnostic handling of runfiles trees Jan 31, 2017
@damienmg damienmg added this to the 1.0 milestone Feb 2, 2017
@damienmg damienmg added P2 We'll consider working on this in future. (Assignee optional) type: feature request labels Feb 2, 2017
@meisterT
Copy link
Member

@lberki is this a P2?

@meisterT meisterT removed this from the 1.0 milestone May 12, 2020
@lberki lberki added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels May 27, 2020
@jin jin added team-Local-Exec Issues and PRs for the Execution (Local) team and removed category: misc > misc labels Mar 1, 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 2+ 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 Apr 26, 2023
@meisterT meisterT added untriaged team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Local-Exec Issues and PRs for the Execution (Local) team labels Apr 26, 2023
@fmeum
Copy link
Collaborator

fmeum commented Apr 26, 2023

The recommended way to access runfiles is now to use the runfiles libraries (among others@rules_python//python/runfiles, @bazel_tools//tools/java/runfiles, @bazel_tools//tools/cpp/runfiles, @bazel_tools//tools/bash/runfiles).

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Apr 27, 2023
@cnsgsz
Copy link
Author

cnsgsz commented May 14, 2023

Will it suffice to use paths relative to a repo's root directory? When would these runfiles libraries be necessary?
Using the relative paths seems to work for bazel run and bazel test. It should also work in the deployment of the runfiles by setting CWD appropriately?

@fmeum
Copy link
Collaborator

fmeum commented May 14, 2023

@cnsgsz If you only ever reference files in your main repository, exclusively target a Unix variant and don't run your targets as part of build actions, then you don't need runfiles libraries. In all other cases you are likely better off with them.

@comius comius added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request
Projects
None yet
Development

No branches or pull requests

9 participants