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

refactor: move PyPI related extension and repository_rule setup to its own dir #2003

Merged
merged 25 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
867f8b0
chore: add aignas to CODEOWNERS
aignas Jun 22, 2024
79fa303
chore: add a new directory for storing PyPI related code
aignas Jun 22, 2024
b5afdad
move pypi_index_sources.bzl to private/pypi
aignas Jun 22, 2024
b0d57b6
chore: move parse_requirements_txt to private/pypi
aignas Jun 22, 2024
b24f3c2
move parse_whl_name to private/pypi
aignas Jun 22, 2024
11fd5ef
move whl_target_platforms to private/pypi
aignas Jun 22, 2024
0e9254d
move parse_requirements to private/pypi
aignas Jun 22, 2024
4504416
move pip_repo_name to private/pypi
aignas Jun 22, 2024
37be3cc
remove unused file
aignas Jun 22, 2024
82c81d2
move pip_config_settings to private/pypi
aignas Jun 22, 2024
70dd0a1
move pypi_index to pypi/private and rename
aignas Jun 22, 2024
e3c660b
move labels.bzl to private/pypi
aignas Jun 22, 2024
df6b857
move generate_build_bazel to private/pypi
aignas Jun 22, 2024
96726d7
move render_pkg_aliases.bzl to private/pypi
aignas Jun 22, 2024
adc1929
move patch_whl.bzl to private/pypi
aignas Jun 22, 2024
589d39f
Move envsubst and render_tests to top level of tests
aignas Jun 22, 2024
8153f10
move pip_install_srcs to private/pypi
aignas Jun 22, 2024
c3525d8
split and move pip_install/pip_repository.bzl to private/pypi
aignas Jun 22, 2024
9032fc2
move the bzlmod extension to private/pypi
aignas Jun 22, 2024
ec09a44
manually sort the bzlmod extension deps
aignas Jun 22, 2024
e801c12
fixup
aignas Jun 22, 2024
0e038da
Revert .bazelrc
aignas Jun 22, 2024
c6f5efc
fixup the cleanup that I thought I could do after #1987
aignas Jun 22, 2024
2517813
fixup! fixup the cleanup that I thought I could do after #1987
aignas Jun 22, 2024
bd60c33
fix: sort the config and annotations to produce a file that is not mo…
aignas Jun 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
/python/private/toolchains_repo.bzl @f0rmiga
/python/tests/toolchains/ @f0rmiga

# pip_parse related code
/python/pip_install/ @hrfuller
# PyPI integration related code
/python/private/pypi/ @aignas
/tests/pypi/ @aignas
52 changes: 45 additions & 7 deletions examples/pip_parse_vendored/requirements.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,54 @@
load("@rules_python//python:pip.bzl", "pip_utils")
load("@rules_python//python/pip_install:pip_repository.bzl", "group_library", "whl_library")

all_requirements = ["@my_project_pip_deps_vendored_certifi//:pkg", "@my_project_pip_deps_vendored_charset_normalizer//:pkg", "@my_project_pip_deps_vendored_idna//:pkg", "@my_project_pip_deps_vendored_requests//:pkg", "@my_project_pip_deps_vendored_urllib3//:pkg"]

all_whl_requirements_by_package = {"certifi": "@my_project_pip_deps_vendored_certifi//:whl", "charset_normalizer": "@my_project_pip_deps_vendored_charset_normalizer//:whl", "idna": "@my_project_pip_deps_vendored_idna//:whl", "requests": "@my_project_pip_deps_vendored_requests//:whl", "urllib3": "@my_project_pip_deps_vendored_urllib3//:whl"}
all_requirements = [
"@my_project_pip_deps_vendored_certifi//:pkg",
"@my_project_pip_deps_vendored_charset_normalizer//:pkg",
"@my_project_pip_deps_vendored_idna//:pkg",
"@my_project_pip_deps_vendored_requests//:pkg",
"@my_project_pip_deps_vendored_urllib3//:pkg",
]

all_whl_requirements_by_package = {
"certifi": "@my_project_pip_deps_vendored_certifi//:whl",
"charset_normalizer": "@my_project_pip_deps_vendored_charset_normalizer//:whl",
"idna": "@my_project_pip_deps_vendored_idna//:whl",
"requests": "@my_project_pip_deps_vendored_requests//:whl",
"urllib3": "@my_project_pip_deps_vendored_urllib3//:whl",
}

all_whl_requirements = all_whl_requirements_by_package.values()

all_data_requirements = ["@my_project_pip_deps_vendored_certifi//:data", "@my_project_pip_deps_vendored_charset_normalizer//:data", "@my_project_pip_deps_vendored_idna//:data", "@my_project_pip_deps_vendored_requests//:data", "@my_project_pip_deps_vendored_urllib3//:data"]

_packages = [("my_project_pip_deps_vendored_certifi", "certifi==2023.7.22 --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"), ("my_project_pip_deps_vendored_charset_normalizer", "charset-normalizer==2.1.1 --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"), ("my_project_pip_deps_vendored_idna", "idna==3.4 --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"), ("my_project_pip_deps_vendored_requests", "requests==2.28.1 --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"), ("my_project_pip_deps_vendored_urllib3", "urllib3==1.26.13 --hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc --hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8")]
_config = {"download_only": False, "enable_implicit_namespace_pkgs": False, "environment": {}, "envsubst": ["PIP_RETRIES"], "extra_pip_args": ["--retries=${PIP_RETRIES:-5}"], "isolated": True, "pip_data_exclude": [], "python_interpreter": "python3", "python_interpreter_target": "@python39_host//:python", "quiet": True, "repo": "my_project_pip_deps_vendored", "repo_prefix": "my_project_pip_deps_vendored_", "timeout": 600}
all_data_requirements = [
"@my_project_pip_deps_vendored_certifi//:data",
"@my_project_pip_deps_vendored_charset_normalizer//:data",
"@my_project_pip_deps_vendored_idna//:data",
"@my_project_pip_deps_vendored_requests//:data",
"@my_project_pip_deps_vendored_urllib3//:data",
]

_packages = [
("my_project_pip_deps_vendored_certifi", "certifi==2023.7.22 --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"),
("my_project_pip_deps_vendored_charset_normalizer", "charset-normalizer==2.1.1 --hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 --hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"),
("my_project_pip_deps_vendored_idna", "idna==3.4 --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"),
("my_project_pip_deps_vendored_requests", "requests==2.28.1 --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"),
("my_project_pip_deps_vendored_urllib3", "urllib3==1.26.13 --hash=sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc --hash=sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"),
]
_config = {
"download_only": False,
"enable_implicit_namespace_pkgs": False,
"environment": {},
"envsubst": ["PIP_RETRIES"],
"extra_pip_args": ["--retries=${PIP_RETRIES:-5}"],
"isolated": True,
"pip_data_exclude": [],
"python_interpreter": "python3",
"python_interpreter_target": "@python39_host//:python",
"quiet": True,
"repo": "my_project_pip_deps_vendored",
"repo_prefix": "my_project_pip_deps_vendored_",
"timeout": 600,
}
_annotations = {}

def requirement(name):
Expand Down
2 changes: 1 addition & 1 deletion python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bzl_library(
"//python/pip_install:requirements_bzl",
"//python/private:bzlmod_enabled_bzl",
"//python/private:full_version_bzl",
"//python/private:render_pkg_aliases_bzl",
"//python/private/pypi:render_pkg_aliases_bzl",
"//python/private/whl_filegroup:whl_filegroup_bzl",
],
)
Expand Down
2 changes: 1 addition & 1 deletion python/config_settings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ load(
"PycCollectionFlag",
)
load(
"//python/private:pip_flags.bzl",
"//python/private/pypi:flags.bzl",
"INTERNAL_FLAGS",
"UniversalWhlFlag",
"UseWhlFlag",
Expand Down
2 changes: 0 additions & 2 deletions python/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ bzl_library(
srcs = ["python.bzl"],
visibility = ["//:__subpackages__"],
deps = [
"//python/private:util_bzl",
"//python/private/bzlmod:bazel_features_bzl",
"//python/private/bzlmod:python_bzl",
],
)
5 changes: 3 additions & 2 deletions python/pip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ symbols should not be used and they are either undocumented here or marked as
for internal use only.
"""

load("//python/pip_install:pip_repository.bzl", "pip_repository", _package_annotation = "package_annotation")
load("//python/pip_install:requirements.bzl", _compile_pip_requirements = "compile_pip_requirements")
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED")
load("//python/private:full_version.bzl", "full_version")
load("//python/private:normalize_name.bzl", "normalize_name")
load("//python/private:render_pkg_aliases.bzl", "NO_MATCH_ERROR_MESSAGE_TEMPLATE")
load("//python/private/pypi:package_annotation.bzl", _package_annotation = "package_annotation")
load("//python/private/pypi:pip_repository.bzl", "pip_repository")
load("//python/private/pypi:render_pkg_aliases.bzl", "NO_MATCH_ERROR_MESSAGE_TEMPLATE")
load("//python/private/whl_filegroup:whl_filegroup.bzl", _whl_filegroup = "whl_filegroup")

compile_pip_requirements = _compile_pip_requirements
Expand Down
42 changes: 5 additions & 37 deletions python/pip_install/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,10 @@ bzl_library(
name = "pip_repository_bzl",
srcs = ["pip_repository.bzl"],
deps = [
":repositories_bzl",
"//python:repositories_bzl",
"//python:versions_bzl",
"//python/pip_install/private:generate_group_library_build_bazel_bzl",
"//python/pip_install/private:generate_whl_library_build_bazel_bzl",
"//python/pip_install/private:srcs_bzl",
"//python/private:bzlmod_enabled_bzl",
"//python/private:envsubst_bzl",
"//python/private:normalize_name_bzl",
"//python/private:parse_requirements_bzl",
"//python/private:parse_whl_name_bzl",
"//python/private:patch_whl_bzl",
"//python/private:render_pkg_aliases_bzl",
"//python/private:repo_utils_bzl",
"//python/private:toolchains_repo_bzl",
"//python/private:whl_target_platforms_bzl",
"@bazel_skylib//lib:sets",
"//python/private/pypi:group_library_bzl",
"//python/private/pypi:package_annotation_bzl",
"//python/private/pypi:pip_repository_bzl",
"//python/private/pypi:whl_library_bzl",
],
)

Expand All @@ -51,11 +38,6 @@ bzl_library(
],
)

bzl_library(
name = "requirements_parser_bzl",
srcs = ["requirements_parser.bzl"],
)

bzl_library(
name = "repositories_bzl",
srcs = ["repositories.bzl"],
Expand All @@ -71,7 +53,6 @@ filegroup(
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"pip_repository_requirements.bzl.tmpl",
"//python/pip_install/private:distribution",
"//python/pip_install/tools/dependency_resolver:distribution",
"//python/pip_install/tools/wheel_installer:distribution",
],
Expand All @@ -92,23 +73,10 @@ filegroup(

filegroup(
name = "bzl",
srcs = glob(["*.bzl"]) + [
"//python/pip_install/private:bzl_srcs",
],
srcs = glob(["*.bzl"]),
visibility = ["//:__subpackages__"],
)

filegroup(
name = "py_srcs",
srcs = [
"//python/pip_install/tools/dependency_resolver:py_srcs",
"//python/pip_install/tools/wheel_installer:py_srcs",
"//python/private:repack_whl.py",
"//tools:wheelmaker.py",
],
visibility = ["//python/pip_install/private:__pkg__"],
)

exports_files(
glob(["*.bzl"]),
visibility = ["//docs:__pkg__"],
Expand Down
Loading