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

pip_parse is not installing flask, asking for the packages jinja2, itsdangerous etc. for any python package like requests or pandas same issue is there. #1853

Closed
jigsnptel opened this issue Apr 17, 2024 · 2 comments

Comments

@jigsnptel
Copy link

continuoulsy asking packages for flask, if you include them in requirements.txt, it is asking for some other package. i am using bazel 7.1.1

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

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

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_11",
# Available versions are listed in @rules_python//python:versions.bzl.
python_version = "3.11",
)

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

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

pip_parse(
python_interpreter_target = interpreter,
name = "my_deps",
requirements_lock = "//third_party:requirements.txt",
environment = {
"PIP_REQUIRE_VIRTUALENV": "",
}

)

load("@my_deps//:requirements.bzl", "install_deps")

install_deps()

workspace. bazel file

load("@my_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_binary")

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

py_binary(
name = "main",
srcs = ["main.py"],
deps = ["//calc:calculator","@my_deps_flask//:pkg"
],

)BUILD.bazel file.

error msg: Fetching target dependencies for deps(//app:main) encountered an error: Evaluation of query "deps(//app:main)" failed: preloading transitive closure failed: no such package '@@my_deps_blinker//': The repository '@@my_deps_blinker' could not be resolved: Repository '@@my_deps_blinker' is not defined

@pat-jpnk
Copy link

pat-jpnk commented May 6, 2024

I have found that you need to use the pip_compile_requirements rule to create the requirements_lock.txt file. If you do so, all the packages that a module depends on will be added in that requirements_lock.txt file. I have made an example when I tried to get it working https://github.com/pat-jpnk/bazel_pip_example/tree/main

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

aignas commented May 13, 2024

We also have a examples/bzlmod and exmples/pip_parse examples. Consider looking at them.

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

3 participants