You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(wheel): Add support for add_path_prefix (#3679)
This change is being made to support prepending a prefix to the file
paths in the wheel. This is useful for customizing the import path for
the package. For example, if your code is implemented in `src/module`
you may want to package this code for distribution as `namespace/module`
so that the import is
```python
import namespace.module
```
I think ideally, this should have been implemented as
`remap_path_prefix` which is a map which specifies which prefixes should
be changed and what to change them to. However, seeing as
`strip_path_prefixes` already exists, I thought the simpler thing to do
here was to just add the `add_path_prefix` argument.
Implements #515
## Tests
Tested by building and manually inspecting the wheels generated by
```
$ bazel build //examples/wheel/...
```
More specifically
```
$ bazel build //examples/wheel:custom_prefix_package_root
INFO: Analyzed target //examples/wheel:custom_prefix_package_root (1 packages loaded, 4 targets configured).
INFO: Found 1 target...
Target //examples/wheel:custom_prefix_package_root up-to-date:
bazel-bin/examples/wheel/examples_custom_prefix_package_root-0.0.1-py3-none-any.whl
INFO: Elapsed time: 0.357s, Critical Path: 0.01s
INFO: 2 processes: 3 action cache hit, 1 disk cache hit, 1 internal.
$ uv pip install bazel-bin/examples/wheel/examples_custom_prefix_package_root-0.0.1-py3-none-any.whl
Installed 1 package in 3ms
+ examples-custom-prefix-package-root==0.0.1
$ python -c "import custom_prefix.wheel"
```
---------
Co-authored-by: Antonio Kim <antoniok@antoniojkim.com>
0 commit comments