rules_python
rules_python copied to clipboard
Allow requirements_in to be generated
PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- [x] Bugfix
- [ ] Feature (please, look at the "Scope of the project" section in the README.md file)
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:
What is the current behavior?
We generate the requirements_in file from various input files roughly like so:
genrule(
name = "generate_3.7_x86_requirements",
srcs = [
"requirements_base.in.txt",
"requirements_extra_37.in.txt",
],
outs = ["requirements_3.7_x86.txt"],
cmd = "cat $(SRCS) > $(OUTS)",
)
compile_pip_requirements(
name = "compile_requirements_3.7_x86",
requirements_in = ":requirements_3.7_x86.txt",
requirements_txt = "requirements_3.7_x86.lock.txt",
)
The current code errors out with a message like this:
Updating common/python/requirements_3.7_x86.lock.txt
Usage: pip_compile.py [OPTIONS] [SRC_FILES]...
Try 'pip_compile.py -h' for help.
Error: Invalid value for '[SRC_FILES]...': Path 'common/python/requirements_3.7_x86.txt' does not exist.
What is the new behavior?
This patch here fixes the issue by resolving the requirements_in path
before the tool cds into the workspace directory.
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No