-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
[Bug]: Module not found (in this case pytest) #371
Comments
It appears that the order of my toolchains was wrong. This order works: python_register_toolchains(
name = "python3_10_6",
python_version = "3.10.6",
set_python_version_constraint = True,
)
load("@python3_10_6//:defs.bzl", python_3_10_6_interpreter = "interpreter")
# Default toolchain must go last
python_register_toolchains(
name = "python3_9_16",
python_version = "3.9.16",
)
load("@python3_9_16//:defs.bzl", python_interpreter = "interpreter") Perhaps this needs a better error message? |
That error message is from Python itself, so I'm not sure what rules_py could have done here. However, the toolchain ordering looks like it might be related to #363 |
It's generally quite hard to know which toolchain is being used and if you have configured things incorrectly. From the usage, I was under the impression that py_test(
name = "tests",
srcs = [
"tests/**/*.py",
],
main = "test.py",
python_version = "3.10.6", # <----- Set here
deps = [
requirement("pytest"),
],
) pip_parse(
name = "pypi",
requirements_lock = "//:requirements.txt",
python_interpreter_target = python_3_10_6_interpreter, # <----- Matches here
) But it actually depends on the order of toolchain registration. If you declare a |
Duplicate of #363 |
What happened?
I have a complex project but I will try to capture the import parts.
requirements.txt
contains pytest, among other things:My Bazel target imports pytest:
WORKSPACE
parses the requirements:By when I run the test, I get:
Version
Development (host) and target OS/architectures:
Output of
bazel --version
:bazel 6.4.0
Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file:Language(s) and/or frameworks involved: -
How to reproduce
Any other information?
No response
The text was updated successfully, but these errors were encountered: