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(bzlmod): support bazel downloader when downloading wheels (bazel-contrib#1827)
This introduces 3 attributes and the minimal code to be able to download
wheels
using the bazel downloader for the host platform. This is not yet adding
support for targeting a different platform but just allows us to get the
wheels
for the host platform instead of using `pip`.
All of this is achieved by calling the PyPI's SimpleAPI (Artifactory
should work
as well) and getting the all URLs for packages from there. Then we use
the `sha256`
information within the requirements files to match the entries found on
SimpleAPI
and then pass the `url`, `sha256` and the `filename` to `whl_library`,
which uses
`repository_ctx.download`.
If we cannot find any suitable artifact to use, we fallback to legacy
`pip` behaviour.
Testing notes:
* Most of the code has unit tests, but the `pypi_index.bzl` extension
could have more.
* You can see the lock file for what the output of all of this code
would be on your
platform.
* Thanks to @dougthor42 for testing this using the credentials helper
against a private
registry that needs authentication to be accessed.
Work towards bazel-contrib#1357
# NOTE @aignas 2024-03-21: The usage of dict({}, **common) ensures that all args to `dict` are unique
936
+
whl_library_attrs=dict({
894
937
"annotation": attr.label(
895
938
doc= (
896
939
"Optional json encoded file containing annotation to apply to the extracted wheel. "+
897
940
"See `package_annotation`"
898
941
),
899
942
allow_files=True,
900
943
),
944
+
"filename": attr.string(
945
+
doc="Download the whl file to this filename. Only used when the `urls` is passed. If not specified, will be auto-detected from the `urls`.",
946
+
),
901
947
"group_deps": attr.string_list(
902
948
doc="List of dependencies to skip in order to break the cycles within a dependency group.",
903
949
default= [],
@@ -911,7 +957,18 @@ whl_library_attrs = {
911
957
),
912
958
"requirement": attr.string(
913
959
mandatory=True,
914
-
doc="Python requirement string describing the package to make available",
960
+
doc="Python requirement string describing the package to make available, if 'urls' or 'whl_file' is given, then this only needs to include foo[any_extras] as a bare minimum.",
961
+
),
962
+
"sha256": attr.string(
963
+
doc="The sha256 of the downloaded whl. Only used when the `urls` is passed.",
964
+
),
965
+
"urls": attr.string_list(
966
+
doc="""\
967
+
The list of urls of the whl to be downloaded using bazel downloader. Using this
968
+
attr makes `extra_pip_args` and `download_only` ignored.""",
969
+
),
970
+
"whl_file": attr.label(
971
+
doc="The whl file that should be used instead of downloading or building the whl.",
0 commit comments