bazelbuild / bazelbuild/bazel

Use of ctx.info_file and ctx.version_file in rule implementations

Open
#13,360 10 comments 0 reactions 1 assignee Claimed by @buildbreaker2021 View on GitHub
P2 team-Rules-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

### Description of the problem / feature request:

At the moment information in ctx.info_file and ctx.version_file cannot be used for rule implementation.

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

See for instance https://github.com/bazelbuild/rules_python/pull/451. Therein, I would like to use git info, routed via workspace status script, to make an output file name of a Python wheel. Since I cannot read a file from context, at the moment I process ctx.info_file and ctx.version_file in a separate Python script and then dump a wheel version to a .txt file. The new py_wheel_push rule in that PR consumes my .txt file and then assembles the correct file name. However, it is desirable that py_wheel rule already assembles the correct wheel name, which at the moment is not possible if I want to use info from workspace status -- e.g. a wheel version in py_wheel rule as `version = "{FOO}"`, where I expect FOO to be picked up from the workspace status.

Are there any plans to enable use of the workspace status in rule implementations?

### What operating system are you running Bazel on?

Ubuntu 18.04

### What's the output of `bazel info release`?

release 2.0.0

### Have you found anything relevant by searching the web?

The only thing I could find is that Bazel context cannot read files, and that's for good reasons as far as I understand.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.