Skip to content

compile_pip_requirements in package below workspace root level not working on Windows#1129

Description

@e8y

馃悶 bug report

Affected Rule

compile_pip_requirements

Is this a regression?

Unsure

Description

I'm trying to use compile_pip_requirements to create a requirements_lock.txt file from a requirements.in file. I don't have the requirements_lock.txt file yet, so I'm trying to use this rule to create it for the first time.

First, I had to comment out everything in my workspace / build files referring to the requirements_lock.txt input to avoid getting errors. This seems to be a usability quirk---I was hoping that running bazel run //mypackage:requirements.update would work without triggering the other rules that depend on requirements_lock.txt (i.e., from bazel build).

After cleaning that up, I then get the following error(s):

PS C:\work\workspace_root\mypackage> bazel run requirements.update
INFO: Analyzed target //mypackage:requirements.update (52 packages loaded, 1050 targets configured).
INFO: Found 1 target...
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25: PythonZipper mypackage/requirements.update.zip failed: missing input file '//mypackage:requirements_lock.txt'
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25: PythonZipper mypackage/requirements.update.zip failed: 1 input file(s) do not exist
Target //mypackage:requirements.update failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25 PythonZipper mypackage/requirements.update.zip failed: 1 input file(s) do not exist

馃敩 Minimal Reproduction

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
    strip_prefix = "rules_python-0.19.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz",
)

mypackage/BUILD

load("@rules_python//python:pip.bzl", "compile_pip_requirements")
compile_pip_requirements(
    name = "requirements",
    #extra_args = ["--allow-unsafe"],
    requirements_in = "//mypackage:requirements.in",  # also tried just "requirements.in"
    requirements_txt = "//mypackage:requirements_lock.txt",  # also tried just "requirements_lock.txt"
    visibility = ["//visibility:public"],
)

Command

> cd workspace_root
> bazel run //mypackage:requirements.update

Also tried the following, with the same result:

> cd mypackage
> bazel run requirements.update

I also tried just touching an empty requirements_lock.txt file but get the same result.

馃敟 Exception or Error




PS C:\work\workspace_root\mypackage> bazel run requirements.update
INFO: Analyzed target //mypackage:requirements.update (52 packages loaded, 1050 targets configured).
INFO: Found 1 target...
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25: PythonZipper mypackage/requirements.update.zip failed: missing input file '//mypackage:requirements_lock.txt'
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25: PythonZipper mypackage/requirements.update.zip failed: 1 input file(s) do not exist
Target //mypackage:requirements.update failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: C:/work/workspace_root\mypackage/BUILD:36:25 PythonZipper mypackage/requirements.update.zip failed: 1 input file(s) do not exist

馃實 Your Environment

Operating System:

  
Windows 10, 64-bit (Version 21H2, Build 19044.2604)
  

Output of bazel version:

  
Bazelisk version: v1.16.0
Build label: 6.1.0
Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Mar 6 17:11:12 2023 (1678122672)
Build timestamp: 1678122672
Build timestamp as int: 1678122672
  

Rules_python version:

  
0.19.0
  

Anything else relevant?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days if there is no new activity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions