Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find interpreter for pip hub #1867

Closed
SDAChess opened this issue Apr 24, 2024 · 4 comments
Closed

Unable to find interpreter for pip hub #1867

SDAChess opened this issue Apr 24, 2024 · 4 comments

Comments

@SDAChess
Copy link

馃悶 bug report

Affected Rule

Probably a missuse on my end but pip.parse

Is this a regression?

No.

Description

When trying to use rules_python to fetch dependencies from Pypi with Bzlmod I'm running into this error message:

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: Traceback (most recent call last):
	File "/home/nvidia/.cache/bazel/_bazel_nvidia/73a3c98af12e8cd8cdc191f6b030862f/external/rules_python~/python/private/bzlmod/pip.bzl", line 355, column 30, in _pip_impl
		_create_whl_repos(module_ctx, pip_attr, hub_whl_map, whl_overrides)
	File "/home/nvidia/.cache/bazel/_bazel_nvidia/73a3c98af12e8cd8cdc191f6b030862f/external/rules_python~/python/private/bzlmod/pip.bzl", line 111, column 17, in _create_whl_repos
		fail((
Error in fail: Unable to find interpreter for pip hub 'deps' for python_version=3.10: Make sure a corresponding `python.toolchain(python_version="3.10")` call exists
ERROR: error evaluating module extension pip in @@rules_python~//python/extensions:pip.bzl
INFO: Elapsed time: 7.249s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED:
    Fetching module extension pip in @@rules_python~//python/extensions:pip.bzl; starting

馃敩 Minimal Reproduction

I am running Bazel into a Docker container which as base image as Ubuntu 22.04.

Dockerfile:

FROM ubuntu:22.04

RUN apt update -y

RUN apt install apt-transport-https curl gnupg -y

RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel-archive-keyring.gpg
RUN mv bazel-archive-keyring.gpg /usr/share/keyrings
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list

RUN apt update -y && apt install bazel -y

RUN apt install python3 python3-pip -y

RUN useradd -ms /bin/bash test
USER test
WORKDIR /home/test
COPY . .

MODULE.bzl:

module(
    name = "test",
    version = "0.1.0",
)

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

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

python.toolchain(
    python_version = "3.10",
    is_default = True,
)

pip.parse(
    hub_name = "deps",
    python_version = "3.10",
    requirements_lock = "//:requirements.txt",
)

use_repo(pip, "deps")

requirements.txt:

asyncio

BUILD:

load("@deps//:requirements.bzl", "requirement")

py_binary(
    name = "test",
    srcs = [
        "test.py",
    ],
    deps = [
        requirement("asyncio"),
    ],
    main = "test.py"
)
@SDAChess
Copy link
Author

I'm thinking this is related to Debian disabling global pip install but I want to make sure.

@pat-jpnk
Copy link

pat-jpnk commented May 6, 2024

I can't test this at this very moment, but if the following documentation example is correct:

https://github.com/bazelbuild/rules_python/blob/main/examples/pip_parse/MODULE.bazel

It stands out to me that in your code the use_extension takes a different parameter:

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

While in the example, the following label is being used:

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

@aignas
Copy link
Collaborator

aignas commented May 13, 2024

Closing as it is more of a support question rather than a bug.

@aignas aignas closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@jab
Copy link

jab commented May 17, 2024

If the following is wrong:

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

...then are the https://rules-python.readthedocs.io/en/stable/toolchains.html#root-modules docs wrong too? Those docs are also missing the initial python/ component before extensions:python.bzl. I followed those docs and hit this issue, which I resolved by adding the missing python/ to the path.

(This actually took a while to debug since the error message did not make it obvious what the problem was.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants