Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bzlmod): introduce pypi_index for using bazel's downloader #1792

Closed
wants to merge 15 commits into from

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Mar 10, 2024

This is a variant of #1625 and was inspired by #1788. In #1625, we
attempt to parse the simple API HTML files in the same pip.parse
extension and it brings the follownig challenges:

  • The pip.parse cannot be easily use in isolated mode and it may
    be difficult to implement the isolation if Figure out a plan to stabilize isolated extension usages bazel#20186
    moves forward.
  • Splitting the pypi_index out of the pip.parse allows us to accept
    the location of the parsed simple API artifacts encoded as a bazel
    label.
  • Separation of the logic allows us to very easily implement usage of
    the downloader for cross-platform wheels.
  • The whl METADATA might not be exposed through older versions of
    Artifactory, so having the complexity hidden in this single extension
    allows us to not increase the complexity and scope of pip.parse too
    much.
  • The repository structure can be reused for pypi_install extension
    from feat: (WIP) Add pypi_install() rule #1728.

TODO:

  • Add unit tests for functions in pypi_index.bzl bzlmod extension if
    the design looks good.
  • Changelog.

Work towards #1357, #1643.

This is a variant of bazelbuild#1625 and was inspired by bazelbuild#1788. In bazelbuild#1625, we
attempt to parse the simple API HTML files in the same `pip.parse`
extension and it brings the follownig challenges:

* The `pip.parse` cannot be easily use in `isolated` mode and it may
  be difficult to implement the isolation if bazelbuild/bazel#20186
  moves forward.
* Splitting the `pypi_index` out of the `pip.parse` allows us to accept
  the location of the parsed simple API artifacts encoded as a bazel
  label.
* Separation of the logic allows us to very easily implement usage of
  the downloader for cross-platform wheels.
* The `whl` `METADATA` might not be exposed through older versions of
  Artifactory, so having the complexity hidden in this single extension
  allows us to not increase the complexity and scope of `pip.parse` too
  much.
* The repository structure can be reused for `pypi_install` extension
  from bazelbuild#1728.

TODO:
- [ ] Add unit tests for functions in `pypi_index.bzl` bzlmod extension if
  the design looks good.
- [ ] Changelog.

Out of scope of this PR:
- Further usage of the downloaded artifacts to implement something
  similar to bazelbuild#1625 or bazelbuild#1744. This needs bazelbuild#1750 and bazelbuild#1764.
- Making the lock file the same on all platforms - We would need
  to fully parse the requirements file.
- Support for different dependency versions in the `pip.parse` hub repos
  based on each platform - we would need to be able to interpret
  platform markers in some way, but `pypi_index` should be good already.
- Implementing the parsing of METADATA to detect dependency cycles.
- Support for `requirements` files that are not created via
  `pip-compile`.
- Support for other lock formats, though that would be reasonably
  trivial to add.

Open questions:
- Support for VCS dependencies in requirements files - We should
  probably handle them as `overrides` in the `pypi_index` extension and
  treat them in `pip.parse` just as an `sdist`, but I am not sure it
  would work without any issues.
@aignas aignas requested a review from rickeylev as a code owner March 10, 2024 04:27
@aignas
Copy link
Collaborator Author

aignas commented Mar 10, 2024

Out of scope of this PR:

Open questions:

  • Support for VCS dependencies in requirements files - We should
    probably handle them as overrides in the pypi_index extension and
    treat them in pip.parse just as an sdist, but I am not sure it
    would work without any issues.

@aignas aignas marked this pull request as draft March 15, 2024 08:44
@aignas aignas changed the title feat(bzlmod): introduce pypi_index for using bazel's downloader feat(bzlmod): use pypi simple api to get URLS for whls for host platform Mar 26, 2024
@aignas aignas changed the title feat(bzlmod): use pypi simple api to get URLS for whls for host platform feat(bzlmod): introduce pypi_index for using bazel's downloader Mar 26, 2024
@aignas
Copy link
Collaborator Author

aignas commented Mar 26, 2024

This POC has served well, but I'll close it to focus on more targeted PRs that implement ideas outlined in this design doc. Since the doc uses this PR as reference material I'll close this and start fresh.

@aignas aignas closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant