aspect-build / rules_py

More compatible Bazel rules for running Python tools and building Python projects
Apache License 2.0
73 stars 22 forks source link

[Bug]: rules_py imports do not "properly cross repos" #325

Open randomNinja1000 opened 3 months ago

randomNinja1000 commented 3 months ago

What happened?

It seems with rules_py imports do not "properly cross repos". When a source py_library is defined in a source repo1 and used in a target repo2, the sys.path does not get set up properly.

Version

Development (host) and target OS/architectures:

macos sonoma 14.2.1 M3 chip

Output of bazel --version:

bazel 7.1.0

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_rules_py", version = "0.7.1") bazel_dep(name = "rules_python", dev_dependency = True, version = "0.31.0")

Language(s) and/or frameworks involved:

python

How to reproduce

git clone git@github.com:randomNinja1000/repro-rules-py.git

Instructions

(cd repo1 && bazel run //python/test:test)

passes.

(cd repo2 && bazel run //python/test:test)

passes.

Comment / uncomment the load in repo1/python/BUILD.bazel

(cd repo2 && bazel run //python/test:test)

now fails and the sys.path does not contain repo1 anymore.

Unfortunately, it seems with rules_py imports do not "properly cross repos".

Any other information?

No response

laurentlb commented 3 weeks ago

I took at this issue and tried to debug it. It turns out this was already fixed. The fix was 862a4346fa250bbe88876e29101c9d6ac91a922e.

If you update the rules_py in your repro to 0.7.2 or later, it will succeed.