bazel-contrib / bazel-contrib/rules_python

Generate one Bazel repo per dependency

Open
#2,370 10 comments 0 reactions 0 assignees View on GitHub
need: repro
Dominant language
Starlark
Stars
688
Forks
721
Avg merge
14h 49m
Merged PRs (30d)
81

Description

# 🚀 feature request

### Relevant Rules

`pip.parse()` module extension

### Description

When the same pip package is (transitively) depended upon multiple times from different `requirements.txt` files, it is undefined which version will be chosen (both are added to the PYTHONPATH and the order of deps decides which one takes precedence).
This is especially problematic for transitive dependencies of module dependencies where one only has limited to no influence of which version is chosen. This is especially problematic for fundamental libraries like Protobuf which gets pulled in transitively in many `requirements.txt`.
The way this is handled in golang, is that every dependency is its own Bazel repo and as such takes part in version resolution. This makes sure that every package only exists once within a given Bazel workspace.

### Describe the solution you'd like

Generate one Bazel repo per pip dependency.

### Describe alternatives you've considered

For the transition period, `rules_python` could generate both, one repo for all of `requirements.txt` and one repo per dependency. This way, users can easily migrate from one approach to another. In a future major version, the old functionality could be removed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.