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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rules_python version used in rules_pkg conflict with version 0.34.0 of rules_python, if rules_pkg is loaded first and then rules_python #882

Open
sjonnalagadda opened this issue Aug 16, 2024 · 1 comment
Labels
P3 An issue that we are not working on but will review quarterly

Comments

@sjonnalagadda
Copy link

sjonnalagadda commented Aug 16, 2024

The error is:

ERROR: BUILD.bazel:4:25: //:requirements_test: no such attribute 'src' in 'py_test' rule (did you mean 'srcs'?)

Here is the setup

WORKSPACE file contents


# https://github.com/uber/hermetic_cc_toolchain/blob/main/examples/rules_cc/WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


http_archive(
    name = "rules_pkg",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz",
        "https://github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz",
    ],
    sha256 = "d20c951960ed77cb7b341c2a59488534e494d5ad1d30c4818c736d57772a9fef",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

http_archive(
    name = "rules_python",
    sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
    strip_prefix = "rules_python-0.34.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz",
)


# "Installation" for rules_python
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
    name = "python_toolchain",
    python_version = "3.11.3",
)

load("@python_toolchain//:defs.bzl", "interpreter")

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

BUILD file contents

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


compile_pip_requirements(
    name = "requirements",
    src = "requirements.in",
    requirements_txt = "requirements_lock.txt",
)
`
requirements.in file contents

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


compile_pip_requirements(
    name = "requirements",
    src = "requirments.in",
    requirements_txt = "requirements_lock.txt",
)

Run command

bazelisk run //:requirements.update

@aiuto
Copy link
Collaborator

aiuto commented Aug 28, 2024

What is the bzlmod behavior?

But on a deeper level, people should always load their fundamental toolchains first.
And, of course, deps.bzl pattern loads should always be conditional on needing the repo.

@aiuto aiuto added the P3 An issue that we are not working on but will review quarterly label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 An issue that we are not working on but will review quarterly
Projects
None yet
Development

No branches or pull requests

2 participants