Open thundergolfer opened 5 years ago
I just ran into py_test
having this same issue. Adding imports = [""]
allowed for correct importing.
This may be related to https://github.com/bazelbuild/bazel/issues/7067
Subpar appears to be enforcing the requirement for using fully qualified imports, whereas in py* rules you can currently get away without the prefix. In the future there appears to be an intention to enforce similar stricter rules in the py* rules, but it is not specified quite how that'd look or when.
Setting imports = [""]
causes subpar to behave the same as the py* rules do by adding an import path that py* is adding by default.
Description
I encountered some unexpected incompatibility between
py_binary
andpar_binary
, that belies this line "par_binary() is a drop-in replacement for py_binary() in your BUILD file".How to Reproduce
Subpar version:
Python Rules Version:
Given a
WORKSPACE
root of/example
, create abuggy
directory inside that, with the following:A.py
B.py
BUILD.bazel
Executing
bazel run --force_python=PY3 --python_path=$(which python3) //buggy:main
gives the following:But executing
bazel run --force_python=PY3 --python_path=$(which python3) //buggy:buggy.par
gives this:The Solution
The solution is to add
imports = [""],
to thepar_binary
rule, which is fine, but in my opinion this should be unnecessary assubpar
should by default behave the same aspy_binary
.Interested to hear your thoughts, and open to submitting a patch for this if you think it appropriate.