Skip to content

pip.parse doesn't support python_interpreter (string) argument #1618

@rickeylev

Description

@rickeylev

🐞 bug report

Affected Rule

pip.parse

Is this a regression?

No

Description

The pip.parse() bzl mod extension accepts a python_interpreter arg, which is a string path
to some interpreter (basically an equiv to py_runtime.interpreter_path). This is an alternative to python_interpreter_target for specifying the interpreter to use.

This arg is, essentially, ignored. I think it is inherited from the workspace pip_parse attributes and got overlooked when implementing the bzlmod extension.

Looking through the code a bit, I think we just need to check .python_interpreter wherever we're checking for .python_interpreter_target.

🔬 Minimal Reproduction

Use pip.parse with the python_interpreter arg set. Specify a version of Python that isn't the default (e.g. 3.9), and don't register a toolchain for that version using python.toolchain. This will cause an error about being unable to find the hermetic runtimes, which shouldn't occur because they shouldn't be used.

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

pip.parse(
    hub_name = "syspy",
    python_interpreter = "/usr/bin/python3",
    python_version = "3.9",
)

🔥 Exception or Error


File "/.../rules_python~0.27.1/python/private/bzlmod/pip.bzl", line 298, column 30, in _pip_impl
                _create_whl_repos(module_ctx, pip_attr, hub_whl_map, whl_overrides)
        File "/.../rules_python~0.27.1/python/private/bzlmod/pip.bzl", line 91, column 17, in _create_whl_repos
                fail((
Error in fail: Unable to find interpreter for pip hub 'pip_deps' for python_version=3.9: Make sure a corresponding `python.toolchain(python_version="3.9")` call exists

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions