Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unclear how py_wheel.strip_path_prefixes is supposed to work when multiple values are providedΒ #3017

Closed
@dougthor42

Description

@dougthor42

🐞 bug report

Affected Rule

py_wheel

Is this a regression?

Haven't checked πŸ™ƒ

Description

It's unclear how strip_path_prefixes is supposed to work when multiple values are provided. Are paths applied sequentially or what?

πŸ”¬ Minimal Reproduction

Given a directory structure like so:

rust/rupyle/rupyle.so
rust/rupyle/python/rupyle/__init__.py
rust/rupyle/python/rupyle/__init__.pyi
rust/rupyle/python/rupyle/envelopes.pyi
rust/rupyle/python/rupyle/fpga/__init__.pyi
rust/rupyle/python/rupyle/fpga/adc.pyi

Working Cases

strip_path_prefixes = ["rust"] creates:

rupyle/rupyle.so                        # no 'rust' prefix, yay!
rupyle/python/rupyle/__init__.py        # no 'rust' prefix, yay!
rupyle/python/rupyle/__init__.pyi
rupyle/python/rupyle/envelopes.pyi
rupyle/python/rupyle/fpga/__init__.pyi
rupyle/python/rupyle/fpga/adc.pyi

as expected.

strip_path_prefixes = ["rust/rupyle/python"] creates:

rust/rupyle/rupyle.so       # still has 'rust' prefix, but we didn't remove it so this is expected
rupyle/__init__.py          # no 'rust/rupyle/python' prefix, yay!
rupyle/__init__.pyi
rupyle/envelopes.pyi
rupyle/fpga/__init__.pyi
rupyle/fpga/adc.pyi

as expected.

Strange cases

strip_path_prefixes = ["rust/rupyle/python", "rust"] creates:

rupyle/rupyle.so             # no 'rust' prefix, yay!
rupyle/__init__.py           # no 'rust/rupyle/python' prefix, yay!
rupyle/__init__.pyi
rupyle/envelopes.pyi
rupyle/fpga/__init__.pyi
rupyle/fpga/adc.pyi

but strip_path_prefixes = ["rust", "rust/rupyle/python"] (reversed ordering) creates:

rupyle/rupyle.so                         # no 'rust' prefix, yay!
rupyle/python/rupyle/__init__.py         # wait why is 'rupyle/python' still here?
rupyle/python/rupyle/__init__.pyi
rupyle/python/rupyle/envelopes.pyi
rupyle/python/rupyle/fpga/__init__.pyi
rupyle/python/rupyle/fpga/adc.pyi

so it seems like it's going in order and doing multiple passes.

OK, then strip_path_prefixes = ["rust", "rupyle/python"] should remove those rupyle/python prefixes, yes? Nope! It returns the same as before!

rupyle/rupyle.so                         # no 'rust' prefix, yay!
rupyle/python/rupyle/__init__.py         # wait why is 'rupyle/python' still here?
rupyle/python/rupyle/__init__.pyi
rupyle/python/rupyle/envelopes.pyi
rupyle/python/rupyle/fpga/__init__.pyi
rupyle/python/rupyle/fpga/adc.pyi

πŸ”₯ Exception or Error

N/A

🌍 Your Environment

Operating System:

gLinux

Output of bazel version:

$ bazel version
Bazelisk version: v1.20.0
Build label: 7.6.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Mar 31 17:08:56 2025 (1743440936)
Build timestamp: 1743440936
Build timestamp as int: 1743440936

Rules_python version:

1.4.1

Anything else relevant?

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions