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

target 'library_pytest' not declared in package '' #19

Open
ibolit opened this issue Dec 9, 2022 · 6 comments
Open

target 'library_pytest' not declared in package '' #19

ibolit opened this issue Dec 9, 2022 · 6 comments

Comments

@ibolit
Copy link

ibolit commented Dec 9, 2022

What I am doing:
I copied the WORKSPACE setup verbatim and added a poetry dependency to one of my targets. This configuration worked, then I worked on some other Bazel functionality for my project. When I tried running tests after I was done with my other functionality, the rules_poetry seem to no longer work.

That other functionality has nothing to do with poetry or pip, but it does involve building wheels from my source code, it uses the standard python_rules py_package and py_wheel for that.

What is the problem:
When I run bazel test ..., I get this error:

bazel test ...
ERROR: /Users/me/Work/dialog_platform/_experimental_lib_for_bazel/BUILD.bazel:16:8: no such target '@poetry//:library_fastapi': target 'library_fastapi' not declared in package '' defined by /private/var/tmp/_bazel_me/69e3e7ed8e1fbf19ba79afe448a27e50/external/poetry/BUILD and referenced by '//_experimental_lib_for_bazel:test_experimental_lib_for_bazel'
ERROR: /Users/me/Work/dialog_platform/_experimental_lib_for_bazel/BUILD.bazel:16:8: no such target '@poetry//:library_pytest': target 'library_pytest' not declared in package '' defined by /private/var/tmp/_bazel_me/69e3e7ed8e1fbf19ba79afe448a27e50/external/poetry/BUILD and referenced by '//_experimental_lib_for_bazel:test_experimental_lib_for_bazel'
ERROR: Analysis of target '//_experimental_lib_for_bazel:test_experimental_lib_for_bazel' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.432s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

This is the complete output of the command.

I tried reproducing this problem on another computer, but couldn't.

I tried running bazel clean and cleaning my poetry caches as well. It did not help

@NathanHowell
Copy link
Contributor

what is in the generated build file private/var/tmp/_bazel_me/69e3e7ed8e1fbf19ba79afe448a27e50/external/poetry/BUILD ?

@ibolit
Copy link
Author

ibolit commented Dec 12, 2022

Hello, sorry, I was off work.

Here are the contents of /private/var/tmp/_bazel_me/69e3e7ed8e1fbf19ba79afe448a27e50/external/poetry/BUILD

load("//:defs.bzl", "download_wheel")
load("//:defs.bzl", "noop")
load("//:defs.bzl", "pip_install")

@NathanHowell
Copy link
Contributor

@ibolit can you make a self contained repro? do you know if you have multiple repo rules named poetry that could lead to one being overwritten?

@ibolit
Copy link
Author

ibolit commented Dec 14, 2022

@NathanHowell I am not sure I can, I will try some time later. I seriously suspect something "got broken" while I was working on my own rules, because, for one thing, the "regular" poetry stopped installing some packages (like, pytest), it just hung and did nothing, but that stopped when I cleaned poetry caches.

About other rules named poetry — I did have that at some point. I am using an inhouse tool that seemed to require a poetry executable, which only checked that an executable named poetry existed and that it was indeed executable, but didn't use it, so I wrote an sh_binary with the name poetry to satisfy that. However, it turned out that I could use that inouse tool without it checking for poetry, so I removed that sh_binary altogether.

For now, I have replaced rules_poetry with rules_python/pip_parse, but using poetry would be much more preferable. I will try and check if the commits with poetry_rules work on my colleagues' machines.

Are there any more files I could check or caches I could clean besides bazel clean?

@ibolit
Copy link
Author

ibolit commented Dec 14, 2022

@NathanHowell After I wrote the previous thing, I asked myself that last question and then googled it. I found this:

rm -r $(bazel info repository_cache)

After that, my commits that still have rule_poetry in them, started working again.

In fact, you mentioning other targets named poetry helped me a lot. Thank you for your patience.

@ibolit ibolit closed this as completed Dec 14, 2022
@ibolit
Copy link
Author

ibolit commented Dec 14, 2022

Sorry, I checked again. It didn't start working

Some more information that might be useful:

Our poetry version is 1.2.2

When I try to run bazel test on my py_test target, I get a lot of these lines in my bazel stderr:

DEBUG: /private/var/tmp/_bazel_me/69e3e7ed8e1fbf19ba79afe448a27e50/external/com_sonia_rules_poetry/rules_poetry/poetry.bzl:80:18: Skipping pytest

Seemingly, for all of the dependencies in my pyproject.toml, not just pytest

@ibolit ibolit reopened this Dec 14, 2022
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

2 participants