Skip to content

Efficient way to relocate files in runfiles #23728

@groodt

Description

@groodt

Description of the feature request:

There are situations where having more granular control over the layout of files and directories in runfiles is beneficial.

Python context

Specifically, for rules_python, when we import third_party wheels (archives) from indexes like PyPI (Python Package Index), we would ideally like to expand the archives into a directory called site-packages. This is because outside the bazel context, packages are expanded as siblings inside site-packages.

This creates a major impedance mismatch between bazel and archives or foreign packages brought in from other ecosystems. It truly breaks assumptions in breaking ways in Python. One example (there are many others): NVIDIA wheels are expected to be installed as siblings of site-packages and they even have relative RPATH inside their .so. There are no built-in mechanisms to solve this cleanly in Python or bazel at the moment. See bazel-contrib/rules_python#2156

Here is a typical example of the contents of site-packages for pip install requests where you can see the standard layout when not using bazel.

tree -L 1 .venv/lib/python3.9/site-packages/                                                                                                                                                                                   20:49:03
.venv/lib/python3.9/site-packages/
├── _distutils_hack
├── certifi
├── certifi-2024.8.30.dist-info
├── charset_normalizer
├── charset_normalizer-3.3.2.dist-info
├── distutils-precedence.pth
├── idna
├── idna-3.10.dist-info
├── pip
├── pip-22.0.4.dist-info
├── pkg_resources
├── requests
├── requests-2.32.3.dist-info
├── setuptools
├── setuptools-58.1.0.dist-info
├── urllib3
└── urllib3-2.2.3.dist-info

Other contexts

This is more than just a Python problem. Node has similar challenges with node_modules.

cc @rickeylev @fmeum

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

No response

Which operating system are you running Bazel on?

All

What is the output of bazel info release?

N/A

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

N/A

What's the output of git remote get-url origin; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions