Skip to content

pip.parse extension does not allow setting the hermetic python interpreter #930

@kirschem

Description

@kirschem

🐞 bug report

Affected Rule

The issue is caused by the rule: `pip.parse` extension

Is this a regression?

No.

Description

`pip.parse` allows setting a custom python interpreter. By default it relies on the one in the system. However, to improve hermeticity, I'd like to use the external one that is also used by the hermetic toolchain.

🔬 Minimal Reproduction

# MODULE.bazel

bazel_dep(name = "rules_python", version = "0.16.1")

python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_8",
    python_version = "3.8",
)

use_repo(python, "python3_8_toolchains", "python3_8_x86_64-unknown-linux-gnu")

register_toolchains(
    "@python3_8_toolchains//:all",
)

pip = use_extension("@rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
    python_interpreter_target = "@python3_8_x86_64-unknown-linux-gnu//:python",
)

use_repo(pip, "pip")

🔥 Exception or Error




ERROR: error loading package under directory 'bazel/toolchain/python/tests': no such package '@rules_python~0.16.1~pip~pip//': Unable to load package for @[unknown repo 'rules_python~0.16.1~python~python3_8_x86_64-unknown-linux-gnu' requested from @rules_python~0.16.1]//:WORKSPACE: The repository '@[unknown repo 'rules_python~0.16.1~python~python3_8_x86_64-unknown-linux-gnu' requested from @rules_python~0.16.1]' could not be resolved: No repository visible as '@rules_python~0.16.1~python~python3_8_x86_64-unknown-linux-gnu' from repository '@rules_python~0.16.1'

🌍 Your Environment

Operating System:

  
       Ubuntu 20
  

Output of bazel version:

  
    6.0.0rc4
  

Rules_python version:

  
    0.16.1
  

Anything else relevant?
I've also tried to supply the interpreter as a module on its own, not having it created by rules_python. Unfortunately, I'm running into the same visibility issues.

What is the correct way to also use the hermetic interpreter for pip?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions