From 20c89836a2474cdc056e12799fa41ee215dd05c5 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 21:16:06 +1000 Subject: [PATCH 1/8] . --- python/pip_install/extract_wheels/BUILD | 30 ----------- python/pip_install/extract_wheels/__main__.py | 5 -- .../lib/extract_single_wheel.py} | 12 +++-- .../{__init__.py => lib/extract_wheels.py} | 4 ++ .../lib/parse_requirements_to_bzl.py} | 5 ++ .../lib}/parse_requirements_to_bzl_test.py | 0 .../parse_requirements_to_bzl/BUILD | 54 ------------------- .../parse_requirements_to_bzl/__main__.py | 9 ---- .../extract_single_wheel/BUILD | 17 ------ .../extract_single_wheel/__main__.py | 4 -- python/pip_install/pip_repository.bzl | 6 +-- python/pip_install/private/srcs.bzl | 9 ++-- 12 files changed, 23 insertions(+), 132 deletions(-) delete mode 100644 python/pip_install/extract_wheels/BUILD delete mode 100644 python/pip_install/extract_wheels/__main__.py rename python/pip_install/{parse_requirements_to_bzl/extract_single_wheel/__init__.py => extract_wheels/lib/extract_single_wheel.py} (92%) rename python/pip_install/extract_wheels/{__init__.py => lib/extract_wheels.py} (99%) rename python/pip_install/{parse_requirements_to_bzl/__init__.py => extract_wheels/lib/parse_requirements_to_bzl.py} (98%) rename python/pip_install/{parse_requirements_to_bzl => extract_wheels/lib}/parse_requirements_to_bzl_test.py (100%) delete mode 100644 python/pip_install/parse_requirements_to_bzl/BUILD delete mode 100644 python/pip_install/parse_requirements_to_bzl/__main__.py delete mode 100644 python/pip_install/parse_requirements_to_bzl/extract_single_wheel/BUILD delete mode 100644 python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD deleted file mode 100644 index a92c562292..0000000000 --- a/python/pip_install/extract_wheels/BUILD +++ /dev/null @@ -1,30 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "extract_wheels", - srcs = [ - "__init__.py", - "__main__.py", - ], - main = "__main__.py", - deps = ["//python/pip_install/extract_wheels/lib"], -) - -filegroup( - name = "distribution", - srcs = glob(["*"]) + [ - "//python/pip_install/extract_wheels/lib:distribution", - ], - visibility = ["//python/pip_install:__subpackages__"], -) - -filegroup( - name = "py_srcs", - srcs = glob( - include = ["**/*.py"], - exclude = ["**/*_test.py"], - ) + [ - "//python/pip_install/extract_wheels/lib:py_srcs", - ], - visibility = ["//python/pip_install:__subpackages__"], -) diff --git a/python/pip_install/extract_wheels/__main__.py b/python/pip_install/extract_wheels/__main__.py deleted file mode 100644 index 40b690e2fb..0000000000 --- a/python/pip_install/extract_wheels/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Main entry point.""" -from python.pip_install.extract_wheels import main - -if __name__ == "__main__": - main() diff --git a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py b/python/pip_install/extract_wheels/lib/extract_single_wheel.py similarity index 92% rename from python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py rename to python/pip_install/extract_wheels/lib/extract_single_wheel.py index 198aefae83..e423f51be0 100644 --- a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py +++ b/python/pip_install/extract_wheels/lib/extract_single_wheel.py @@ -34,10 +34,10 @@ def main() -> None: configure_reproducible_wheels() pip_args = ( - [sys.executable, "-m", "pip"] - + (["--isolated"] if args.isolated else []) - + ["wheel", "--no-deps"] - + deserialized_args["extra_pip_args"] + [sys.executable, "-m", "pip"] + + (["--isolated"] if args.isolated else []) + + ["wheel", "--no-deps"] + + deserialized_args["extra_pip_args"] ) requirement_file = NamedTemporaryFile(mode="wb", delete=False) @@ -75,3 +75,7 @@ def main() -> None: repo_prefix=args.repo_prefix, annotation=args.annotation, ) + + +if __name__ == "__main__": + main() diff --git a/python/pip_install/extract_wheels/__init__.py b/python/pip_install/extract_wheels/lib/extract_wheels.py similarity index 99% rename from python/pip_install/extract_wheels/__init__.py rename to python/pip_install/extract_wheels/lib/extract_wheels.py index cda6d541b0..acbfc50c78 100644 --- a/python/pip_install/extract_wheels/__init__.py +++ b/python/pip_install/extract_wheels/lib/extract_wheels.py @@ -126,3 +126,7 @@ def main() -> None: requirement_file.write( bazel.generate_requirements_file_contents(repo_label, targets) ) + + +if __name__ == "__main__": + main() diff --git a/python/pip_install/parse_requirements_to_bzl/__init__.py b/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py similarity index 98% rename from python/pip_install/parse_requirements_to_bzl/__init__.py rename to python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py index 07ee92d9d0..4763a1b554 100644 --- a/python/pip_install/parse_requirements_to_bzl/__init__.py +++ b/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py @@ -270,3 +270,8 @@ def main(output: TextIO) -> None: annotations=annotated_requirements, ) ) + + +if __name__ == "__main__": + with open("requirements.bzl", "w") as requirement_file: + main(requirement_file) diff --git a/python/pip_install/parse_requirements_to_bzl/parse_requirements_to_bzl_test.py b/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl_test.py similarity index 100% rename from python/pip_install/parse_requirements_to_bzl/parse_requirements_to_bzl_test.py rename to python/pip_install/extract_wheels/lib/parse_requirements_to_bzl_test.py diff --git a/python/pip_install/parse_requirements_to_bzl/BUILD b/python/pip_install/parse_requirements_to_bzl/BUILD deleted file mode 100644 index 8a876abfe7..0000000000 --- a/python/pip_install/parse_requirements_to_bzl/BUILD +++ /dev/null @@ -1,54 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") -load("//python/pip_install:repositories.bzl", "requirement") - -py_binary( - name = "parse_requirements_to_bzl", - srcs = [ - "__init__.py", - "__main__.py", - ], - main = "__main__.py", - deps = ["//python/pip_install/extract_wheels/lib"], -) - -py_library( - name = "lib", - srcs = ["__init__.py"], - visibility = ["//python/pip_install/extract_wheels:__subpackages__"], - deps = [requirement("pip")], -) - -py_test( - name = "parse_requirements_to_bzl_test", - size = "small", - srcs = [ - "parse_requirements_to_bzl_test.py", - ], - tags = ["unit"], - deps = [ - ":lib", - "//python/pip_install/extract_wheels/lib", - ], -) - -filegroup( - name = "distribution", - srcs = glob( - ["*"], - exclude = ["*_test.py"], - ) + [ - "//python/pip_install/parse_requirements_to_bzl/extract_single_wheel:distribution", - ], - visibility = ["//python/pip_install:__subpackages__"], -) - -filegroup( - name = "py_srcs", - srcs = glob( - include = ["**/*.py"], - exclude = ["**/*_test.py"], - ) + [ - "//python/pip_install/parse_requirements_to_bzl/extract_single_wheel:py_srcs", - ], - visibility = ["//python/pip_install:__subpackages__"], -) diff --git a/python/pip_install/parse_requirements_to_bzl/__main__.py b/python/pip_install/parse_requirements_to_bzl/__main__.py deleted file mode 100644 index aaa6bf4500..0000000000 --- a/python/pip_install/parse_requirements_to_bzl/__main__.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Main entry point.""" -import os -import sys - -from python.pip_install.parse_requirements_to_bzl import main - -if __name__ == "__main__": - with open("requirements.bzl", "w") as requirement_file: - main(requirement_file) diff --git a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/BUILD b/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/BUILD deleted file mode 100644 index bc0f640f81..0000000000 --- a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/BUILD +++ /dev/null @@ -1,17 +0,0 @@ -filegroup( - name = "distribution", - srcs = glob( - ["*"], - exclude = ["*_test.py"], - ), - visibility = ["//python/pip_install:__subpackages__"], -) - -filegroup( - name = "py_srcs", - srcs = glob( - include = ["**/*.py"], - exclude = ["**/*_test.py"], - ), - visibility = ["//python/pip_install:__subpackages__"], -) diff --git a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py b/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py deleted file mode 100644 index d45f90bbd1..0000000000 --- a/python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__main__.py +++ /dev/null @@ -1,4 +0,0 @@ -from python.pip_install.parse_requirements_to_bzl.extract_single_wheel import main - -if __name__ == "__main__": - main() diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index 743d3e3787..dcc9b3c84e 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -187,7 +187,7 @@ def _pip_repository_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.parse_requirements_to_bzl", + "python.pip_install.extract_wheels.lib.parse_requirements_to_bzl", "--requirements_lock", rctx.path(requirements_txt), "--requirements_lock_label", @@ -209,7 +209,7 @@ def _pip_repository_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.extract_wheels", + "python.pip_install.extract_wheels.lib.extract_wheels", "--requirements", rctx.path(rctx.attr.requirements), "--annotations", @@ -410,7 +410,7 @@ def _whl_library_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.parse_requirements_to_bzl.extract_single_wheel", + "python.pip_install.extract_wheels.lib.extract_single_wheel", "--requirement", rctx.attr.requirement, "--repo", diff --git a/python/pip_install/private/srcs.bzl b/python/pip_install/private/srcs.bzl index a253b66bbb..e5c087e019 100644 --- a/python/pip_install/private/srcs.bzl +++ b/python/pip_install/private/srcs.bzl @@ -7,17 +7,14 @@ This file is auto-generated from the `@rules_python//python/pip_install/private: # Each source file is tracked as a target so `pip_repository` rules will know to automatically rebuild if any of the # sources changed. PIP_INSTALL_PY_SRCS = [ - "@rules_python//python/pip_install/extract_wheels:__init__.py", - "@rules_python//python/pip_install/extract_wheels:__main__.py", "@rules_python//python/pip_install/extract_wheels/lib:__init__.py", "@rules_python//python/pip_install/extract_wheels/lib:annotation.py", "@rules_python//python/pip_install/extract_wheels/lib:arguments.py", "@rules_python//python/pip_install/extract_wheels/lib:bazel.py", + "@rules_python//python/pip_install/extract_wheels/lib:extract_single_wheel.py", + "@rules_python//python/pip_install/extract_wheels/lib:extract_wheels.py", "@rules_python//python/pip_install/extract_wheels/lib:namespace_pkgs.py", + "@rules_python//python/pip_install/extract_wheels/lib:parse_requirements_to_bzl.py", "@rules_python//python/pip_install/extract_wheels/lib:requirements.py", "@rules_python//python/pip_install/extract_wheels/lib:wheel.py", - "@rules_python//python/pip_install/parse_requirements_to_bzl:__init__.py", - "@rules_python//python/pip_install/parse_requirements_to_bzl:__main__.py", - "@rules_python//python/pip_install/parse_requirements_to_bzl/extract_single_wheel:__init__.py", - "@rules_python//python/pip_install/parse_requirements_to_bzl/extract_single_wheel:__main__.py", ] From 9c8f90075d4427823c3704edd06a9209473494e1 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 21:26:54 +1000 Subject: [PATCH 2/8] . --- python/pip_install/BUILD | 2 -- .../extract_wheels/{lib => }/BUILD | 5 ----- .../extract_wheels/{lib => }/__init__.py | 0 .../extract_wheels/{lib => }/annotation.py | 0 .../{lib => }/annotations_test.py | 2 +- .../{lib => }/annotations_test_helpers.bzl | 0 .../extract_wheels/{lib => }/arguments.py | 0 .../{lib => }/arguments_test.py | 2 +- .../extract_wheels/{lib => }/bazel.py | 2 +- .../extract_wheels/{lib => }/bazel_test.py | 2 +- .../{lib => }/extract_single_wheel.py | 4 ++-- .../{lib => }/extract_wheels.py | 2 +- .../{lib => }/namespace_pkgs.py | 0 .../{lib => }/namespace_pkgs_test.py | 2 +- .../{lib => }/parse_requirements_to_bzl.py | 2 +- .../parse_requirements_to_bzl_test.py | 2 +- .../extract_wheels/{lib => }/requirements.py | 0 .../{lib => }/requirements_bzl_test.py | 2 +- .../{lib => }/requirements_test.py | 2 +- .../extract_wheels/{lib => }/wheel.py | 0 .../{lib => }/whl_filegroup_test.py | 2 +- python/pip_install/pip_repository.bzl | 6 +++--- python/pip_install/private/srcs.bzl | 19 +++++++++---------- 23 files changed, 25 insertions(+), 33 deletions(-) rename python/pip_install/extract_wheels/{lib => }/BUILD (93%) rename python/pip_install/extract_wheels/{lib => }/__init__.py (100%) rename python/pip_install/extract_wheels/{lib => }/annotation.py (100%) rename python/pip_install/extract_wheels/{lib => }/annotations_test.py (97%) rename python/pip_install/extract_wheels/{lib => }/annotations_test_helpers.bzl (100%) rename python/pip_install/extract_wheels/{lib => }/arguments.py (100%) rename python/pip_install/extract_wheels/{lib => }/arguments_test.py (96%) rename python/pip_install/extract_wheels/{lib => }/bazel.py (99%) rename python/pip_install/extract_wheels/{lib => }/bazel_test.py (88%) rename python/pip_install/extract_wheels/{lib => }/extract_single_wheel.py (94%) rename python/pip_install/extract_wheels/{lib => }/extract_wheels.py (98%) rename python/pip_install/extract_wheels/{lib => }/namespace_pkgs.py (100%) rename python/pip_install/extract_wheels/{lib => }/namespace_pkgs_test.py (98%) rename python/pip_install/extract_wheels/{lib => }/parse_requirements_to_bzl.py (99%) rename python/pip_install/extract_wheels/{lib => }/parse_requirements_to_bzl_test.py (98%) rename python/pip_install/extract_wheels/{lib => }/requirements.py (100%) rename python/pip_install/extract_wheels/{lib => }/requirements_bzl_test.py (90%) rename python/pip_install/extract_wheels/{lib => }/requirements_test.py (95%) rename python/pip_install/extract_wheels/{lib => }/wheel.py (100%) rename python/pip_install/extract_wheels/{lib => }/whl_filegroup_test.py (96%) diff --git a/python/pip_install/BUILD b/python/pip_install/BUILD index 7727b29089..9ff51375da 100644 --- a/python/pip_install/BUILD +++ b/python/pip_install/BUILD @@ -6,7 +6,6 @@ filegroup( "BUILD", "pip_compile.py", "//python/pip_install/extract_wheels:distribution", - "//python/pip_install/parse_requirements_to_bzl:distribution", "//python/pip_install/private:distribution", ], visibility = ["//:__pkg__"], @@ -24,7 +23,6 @@ filegroup( name = "py_srcs", srcs = [ "//python/pip_install/extract_wheels:py_srcs", - "//python/pip_install/parse_requirements_to_bzl:py_srcs", ], visibility = ["//python/pip_install/private:__pkg__"], ) diff --git a/python/pip_install/extract_wheels/lib/BUILD b/python/pip_install/extract_wheels/BUILD similarity index 93% rename from python/pip_install/extract_wheels/lib/BUILD rename to python/pip_install/extract_wheels/BUILD index 31d6bb8918..dd4a2e0a3e 100644 --- a/python/pip_install/extract_wheels/lib/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -12,10 +12,6 @@ py_library( "requirements.py", "wheel.py", ], - visibility = [ - "//python/pip_install/extract_wheels:__subpackages__", - "//python/pip_install/parse_requirements_to_bzl:__subpackages__", - ], deps = [ requirement("installer"), requirement("setuptools"), @@ -109,7 +105,6 @@ py_test( tags = ["unit"], deps = [ ":lib", - "//python/pip_install/parse_requirements_to_bzl:lib", ], ) diff --git a/python/pip_install/extract_wheels/lib/__init__.py b/python/pip_install/extract_wheels/__init__.py similarity index 100% rename from python/pip_install/extract_wheels/lib/__init__.py rename to python/pip_install/extract_wheels/__init__.py diff --git a/python/pip_install/extract_wheels/lib/annotation.py b/python/pip_install/extract_wheels/annotation.py similarity index 100% rename from python/pip_install/extract_wheels/lib/annotation.py rename to python/pip_install/extract_wheels/annotation.py diff --git a/python/pip_install/extract_wheels/lib/annotations_test.py b/python/pip_install/extract_wheels/annotations_test.py similarity index 97% rename from python/pip_install/extract_wheels/lib/annotations_test.py rename to python/pip_install/extract_wheels/annotations_test.py index 94b92a1ed1..0c41bf70a4 100644 --- a/python/pip_install/extract_wheels/lib/annotations_test.py +++ b/python/pip_install/extract_wheels/annotations_test.py @@ -5,7 +5,7 @@ import unittest from pathlib import Path -from python.pip_install.extract_wheels.lib.annotation import Annotation, AnnotationsMap +from python.pip_install.extract_wheels.annotation import Annotation, AnnotationsMap from python.runfiles import runfiles diff --git a/python/pip_install/extract_wheels/lib/annotations_test_helpers.bzl b/python/pip_install/extract_wheels/annotations_test_helpers.bzl similarity index 100% rename from python/pip_install/extract_wheels/lib/annotations_test_helpers.bzl rename to python/pip_install/extract_wheels/annotations_test_helpers.bzl diff --git a/python/pip_install/extract_wheels/lib/arguments.py b/python/pip_install/extract_wheels/arguments.py similarity index 100% rename from python/pip_install/extract_wheels/lib/arguments.py rename to python/pip_install/extract_wheels/arguments.py diff --git a/python/pip_install/extract_wheels/lib/arguments_test.py b/python/pip_install/extract_wheels/arguments_test.py similarity index 96% rename from python/pip_install/extract_wheels/lib/arguments_test.py rename to python/pip_install/extract_wheels/arguments_test.py index 6a714beeef..8a3aec7a37 100644 --- a/python/pip_install/extract_wheels/lib/arguments_test.py +++ b/python/pip_install/extract_wheels/arguments_test.py @@ -2,7 +2,7 @@ import json import unittest -from python.pip_install.extract_wheels.lib import arguments +from python.pip_install.extract_wheels import arguments class ArgumentsTestCase(unittest.TestCase): diff --git a/python/pip_install/extract_wheels/lib/bazel.py b/python/pip_install/extract_wheels/bazel.py similarity index 99% rename from python/pip_install/extract_wheels/lib/bazel.py rename to python/pip_install/extract_wheels/bazel.py index da1e52c4d5..d7aa706433 100644 --- a/python/pip_install/extract_wheels/lib/bazel.py +++ b/python/pip_install/extract_wheels/bazel.py @@ -6,7 +6,7 @@ from pathlib import Path from typing import Dict, Iterable, List, Optional, Set -from python.pip_install.extract_wheels.lib import ( +from python.pip_install.extract_wheels import ( annotation, namespace_pkgs, wheel, diff --git a/python/pip_install/extract_wheels/lib/bazel_test.py b/python/pip_install/extract_wheels/bazel_test.py similarity index 88% rename from python/pip_install/extract_wheels/lib/bazel_test.py rename to python/pip_install/extract_wheels/bazel_test.py index c6c11dc197..7ecf422227 100644 --- a/python/pip_install/extract_wheels/lib/bazel_test.py +++ b/python/pip_install/extract_wheels/bazel_test.py @@ -1,6 +1,6 @@ import unittest -from python.pip_install.extract_wheels.lib.bazel import generate_entry_point_contents +from python.pip_install.extract_wheels.bazel import generate_entry_point_contents class BazelTestCase(unittest.TestCase): diff --git a/python/pip_install/extract_wheels/lib/extract_single_wheel.py b/python/pip_install/extract_wheels/extract_single_wheel.py similarity index 94% rename from python/pip_install/extract_wheels/lib/extract_single_wheel.py rename to python/pip_install/extract_wheels/extract_single_wheel.py index e423f51be0..83b1ece198 100644 --- a/python/pip_install/extract_wheels/lib/extract_single_wheel.py +++ b/python/pip_install/extract_wheels/extract_single_wheel.py @@ -7,8 +7,8 @@ from tempfile import NamedTemporaryFile from python.pip_install.extract_wheels import configure_reproducible_wheels -from python.pip_install.extract_wheels.lib import arguments, bazel, requirements -from python.pip_install.extract_wheels.lib.annotation import annotation_from_str_path +from python.pip_install.extract_wheels import arguments, bazel, requirements +from python.pip_install.extract_wheels.annotation import annotation_from_str_path def main() -> None: diff --git a/python/pip_install/extract_wheels/lib/extract_wheels.py b/python/pip_install/extract_wheels/extract_wheels.py similarity index 98% rename from python/pip_install/extract_wheels/lib/extract_wheels.py rename to python/pip_install/extract_wheels/extract_wheels.py index acbfc50c78..7e583eb442 100644 --- a/python/pip_install/extract_wheels/lib/extract_wheels.py +++ b/python/pip_install/extract_wheels/extract_wheels.py @@ -12,7 +12,7 @@ import subprocess import sys -from python.pip_install.extract_wheels.lib import ( +from python.pip_install.extract_wheels import ( annotation, arguments, bazel, diff --git a/python/pip_install/extract_wheels/lib/namespace_pkgs.py b/python/pip_install/extract_wheels/namespace_pkgs.py similarity index 100% rename from python/pip_install/extract_wheels/lib/namespace_pkgs.py rename to python/pip_install/extract_wheels/namespace_pkgs.py diff --git a/python/pip_install/extract_wheels/lib/namespace_pkgs_test.py b/python/pip_install/extract_wheels/namespace_pkgs_test.py similarity index 98% rename from python/pip_install/extract_wheels/lib/namespace_pkgs_test.py rename to python/pip_install/extract_wheels/namespace_pkgs_test.py index 815fe62b7e..8a9d97ca39 100644 --- a/python/pip_install/extract_wheels/lib/namespace_pkgs_test.py +++ b/python/pip_install/extract_wheels/namespace_pkgs_test.py @@ -5,7 +5,7 @@ import unittest from typing import Optional, Set -from python.pip_install.extract_wheels.lib import namespace_pkgs +from python.pip_install.extract_wheels import namespace_pkgs class TempDir: diff --git a/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py b/python/pip_install/extract_wheels/parse_requirements_to_bzl.py similarity index 99% rename from python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py rename to python/pip_install/extract_wheels/parse_requirements_to_bzl.py index 4763a1b554..1a756e55d4 100644 --- a/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl.py +++ b/python/pip_install/extract_wheels/parse_requirements_to_bzl.py @@ -16,7 +16,7 @@ ) from pip._internal.req.req_install import InstallRequirement -from python.pip_install.extract_wheels.lib import annotation, arguments, bazel +from python.pip_install.extract_wheels import annotation, arguments, bazel def parse_install_requirements( diff --git a/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl_test.py b/python/pip_install/extract_wheels/parse_requirements_to_bzl_test.py similarity index 98% rename from python/pip_install/extract_wheels/lib/parse_requirements_to_bzl_test.py rename to python/pip_install/extract_wheels/parse_requirements_to_bzl_test.py index fb22d63c07..74158a6855 100644 --- a/python/pip_install/extract_wheels/lib/parse_requirements_to_bzl_test.py +++ b/python/pip_install/extract_wheels/parse_requirements_to_bzl_test.py @@ -7,7 +7,7 @@ from pip._internal.req.req_install import InstallRequirement -from python.pip_install.parse_requirements_to_bzl import ( +from python.pip_install.extract_wheels.parse_requirements_to_bzl import ( generate_parsed_requirements_contents, parse_install_requirements, parse_whl_library_args, diff --git a/python/pip_install/extract_wheels/lib/requirements.py b/python/pip_install/extract_wheels/requirements.py similarity index 100% rename from python/pip_install/extract_wheels/lib/requirements.py rename to python/pip_install/extract_wheels/requirements.py diff --git a/python/pip_install/extract_wheels/lib/requirements_bzl_test.py b/python/pip_install/extract_wheels/requirements_bzl_test.py similarity index 90% rename from python/pip_install/extract_wheels/lib/requirements_bzl_test.py rename to python/pip_install/extract_wheels/requirements_bzl_test.py index d753f6f0aa..ae28e1fc38 100644 --- a/python/pip_install/extract_wheels/lib/requirements_bzl_test.py +++ b/python/pip_install/extract_wheels/requirements_bzl_test.py @@ -1,6 +1,6 @@ import unittest -from python.pip_install.extract_wheels.lib import bazel +from python.pip_install.extract_wheels import bazel class TestGenerateRequirementsFileContents(unittest.TestCase): diff --git a/python/pip_install/extract_wheels/lib/requirements_test.py b/python/pip_install/extract_wheels/requirements_test.py similarity index 95% rename from python/pip_install/extract_wheels/lib/requirements_test.py rename to python/pip_install/extract_wheels/requirements_test.py index 4fe4d92e32..297cd91c38 100644 --- a/python/pip_install/extract_wheels/lib/requirements_test.py +++ b/python/pip_install/extract_wheels/requirements_test.py @@ -1,6 +1,6 @@ import unittest -from python.pip_install.extract_wheels.lib import requirements +from python.pip_install.extract_wheels import requirements class TestRequirementExtrasParsing(unittest.TestCase): diff --git a/python/pip_install/extract_wheels/lib/wheel.py b/python/pip_install/extract_wheels/wheel.py similarity index 100% rename from python/pip_install/extract_wheels/lib/wheel.py rename to python/pip_install/extract_wheels/wheel.py diff --git a/python/pip_install/extract_wheels/lib/whl_filegroup_test.py b/python/pip_install/extract_wheels/whl_filegroup_test.py similarity index 96% rename from python/pip_install/extract_wheels/lib/whl_filegroup_test.py rename to python/pip_install/extract_wheels/whl_filegroup_test.py index f5577136ff..2a7ade3b27 100644 --- a/python/pip_install/extract_wheels/lib/whl_filegroup_test.py +++ b/python/pip_install/extract_wheels/whl_filegroup_test.py @@ -4,7 +4,7 @@ import unittest from pathlib import Path -from python.pip_install.extract_wheels.lib import bazel +from python.pip_install.extract_wheels import bazel class TestWhlFilegroup(unittest.TestCase): diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index dcc9b3c84e..8b7479ad9f 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -187,7 +187,7 @@ def _pip_repository_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.extract_wheels.lib.parse_requirements_to_bzl", + "python.pip_install.extract_wheels.parse_requirements_to_bzl", "--requirements_lock", rctx.path(requirements_txt), "--requirements_lock_label", @@ -209,7 +209,7 @@ def _pip_repository_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.extract_wheels.lib.extract_wheels", + "python.pip_install.extract_wheels.extract_wheels", "--requirements", rctx.path(rctx.attr.requirements), "--annotations", @@ -410,7 +410,7 @@ def _whl_library_impl(rctx): args = [ python_interpreter, "-m", - "python.pip_install.extract_wheels.lib.extract_single_wheel", + "python.pip_install.extract_wheels.extract_single_wheel", "--requirement", rctx.attr.requirement, "--repo", diff --git a/python/pip_install/private/srcs.bzl b/python/pip_install/private/srcs.bzl index e5c087e019..b75d165ddf 100644 --- a/python/pip_install/private/srcs.bzl +++ b/python/pip_install/private/srcs.bzl @@ -7,14 +7,13 @@ This file is auto-generated from the `@rules_python//python/pip_install/private: # Each source file is tracked as a target so `pip_repository` rules will know to automatically rebuild if any of the # sources changed. PIP_INSTALL_PY_SRCS = [ - "@rules_python//python/pip_install/extract_wheels/lib:__init__.py", - "@rules_python//python/pip_install/extract_wheels/lib:annotation.py", - "@rules_python//python/pip_install/extract_wheels/lib:arguments.py", - "@rules_python//python/pip_install/extract_wheels/lib:bazel.py", - "@rules_python//python/pip_install/extract_wheels/lib:extract_single_wheel.py", - "@rules_python//python/pip_install/extract_wheels/lib:extract_wheels.py", - "@rules_python//python/pip_install/extract_wheels/lib:namespace_pkgs.py", - "@rules_python//python/pip_install/extract_wheels/lib:parse_requirements_to_bzl.py", - "@rules_python//python/pip_install/extract_wheels/lib:requirements.py", - "@rules_python//python/pip_install/extract_wheels/lib:wheel.py", + "@rules_python//python/pip_install/extract_wheels:annotation.py", + "@rules_python//python/pip_install/extract_wheels:arguments.py", + "@rules_python//python/pip_install/extract_wheels:bazel.py", + "@rules_python//python/pip_install/extract_wheels:extract_single_wheel.py", + "@rules_python//python/pip_install/extract_wheels:extract_wheels.py", + "@rules_python//python/pip_install/extract_wheels:namespace_pkgs.py", + "@rules_python//python/pip_install/extract_wheels:parse_requirements_to_bzl.py", + "@rules_python//python/pip_install/extract_wheels:requirements.py", + "@rules_python//python/pip_install/extract_wheels:wheel.py", ] From 1913cde07a88b5ae0280df2f68aeaf6bcc747a75 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 21:34:37 +1000 Subject: [PATCH 3/8] . --- python/pip_install/extract_wheels/BUILD | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD index dd4a2e0a3e..6fa717b5ca 100644 --- a/python/pip_install/extract_wheels/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -9,6 +9,7 @@ py_library( "arguments.py", "bazel.py", "namespace_pkgs.py", + "parse_requirements_to_bzl.py", "requirements.py", "wheel.py", ], @@ -118,6 +119,18 @@ py_test( deps = [":lib"], ) +py_test( + name = "parse_requirements_to_bzl_test", + size = "small", + srcs = [ + "parse_requirements_to_bzl_test.py", + ], + tags = ["unit"], + deps = [ + ":lib", + ], +) + py_test( name = "requirements_bzl_test", size = "small", From fbe99fbd16d450c91036c8720c6d8331f492e028 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 21:39:17 +1000 Subject: [PATCH 4/8] . --- python/pip_install/private/srcs.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pip_install/private/srcs.bzl b/python/pip_install/private/srcs.bzl index b75d165ddf..bdd76b17d4 100644 --- a/python/pip_install/private/srcs.bzl +++ b/python/pip_install/private/srcs.bzl @@ -7,6 +7,7 @@ This file is auto-generated from the `@rules_python//python/pip_install/private: # Each source file is tracked as a target so `pip_repository` rules will know to automatically rebuild if any of the # sources changed. PIP_INSTALL_PY_SRCS = [ + "@rules_python//python/pip_install/extract_wheels:__init__.py", "@rules_python//python/pip_install/extract_wheels:annotation.py", "@rules_python//python/pip_install/extract_wheels:arguments.py", "@rules_python//python/pip_install/extract_wheels:bazel.py", From fe182bb409eb41ab0147979d933d429400f13863 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 21:56:53 +1000 Subject: [PATCH 5/8] . --- python/pip_install/extract_wheels/BUILD | 29 +++++++++++++++++++ .../extract_wheels/extract_single_wheel.py | 12 ++++---- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD index 6fa717b5ca..0014755262 100644 --- a/python/pip_install/extract_wheels/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -8,6 +8,8 @@ py_library( "annotation.py", "arguments.py", "bazel.py", + "extract_wheels.py", + "extract_single_wheel.py", "namespace_pkgs.py", "parse_requirements_to_bzl.py", "requirements.py", @@ -19,6 +21,33 @@ py_library( ], ) +py_binary( + name = "extract_wheels", + srcs = [ + "extract_wheels.py", + ], + main = "extract_wheels.py", + deps = [":lib"], +) + +py_binary( + name = "extract_single_wheel", + srcs = [ + "extract_single_wheel.py", + ], + main = "extract_single_wheel.py", + deps = [":lib"], +) + +py_binary( + name = "parse_requirements_to_bzl", + srcs = [ + "parse_requirements_to_bzl.py", + ], + main = "parse_requirements_to_bzl.py", + deps = [":lib"], +) + package_annotations_file( name = "mock_annotations", annotations = { diff --git a/python/pip_install/extract_wheels/extract_single_wheel.py b/python/pip_install/extract_wheels/extract_single_wheel.py index 83b1ece198..85226e4b0b 100644 --- a/python/pip_install/extract_wheels/extract_single_wheel.py +++ b/python/pip_install/extract_wheels/extract_single_wheel.py @@ -6,8 +6,8 @@ import sys from tempfile import NamedTemporaryFile -from python.pip_install.extract_wheels import configure_reproducible_wheels -from python.pip_install.extract_wheels import arguments, bazel, requirements +from python.pip_install.extract_wheels.extract_wheels import configure_reproducible_wheels +from python.pip_install.extract_wheels.extract_wheels import arguments, bazel, requirements from python.pip_install.extract_wheels.annotation import annotation_from_str_path @@ -34,10 +34,10 @@ def main() -> None: configure_reproducible_wheels() pip_args = ( - [sys.executable, "-m", "pip"] - + (["--isolated"] if args.isolated else []) - + ["wheel", "--no-deps"] - + deserialized_args["extra_pip_args"] + [sys.executable, "-m", "pip"] + + (["--isolated"] if args.isolated else []) + + ["wheel", "--no-deps"] + + deserialized_args["extra_pip_args"] ) requirement_file = NamedTemporaryFile(mode="wb", delete=False) From f744ff5850d2993256cfe95808c7b1baec508ecf Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 22:01:51 +1000 Subject: [PATCH 6/8] . --- python/pip_install/extract_wheels/BUILD | 2 +- python/pip_install/extract_wheels/extract_single_wheel.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD index 0014755262..fa7850bfdb 100644 --- a/python/pip_install/extract_wheels/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -1,4 +1,4 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") load("//python/pip_install:repositories.bzl", "requirement") load(":annotations_test_helpers.bzl", "package_annotation", "package_annotations_file") diff --git a/python/pip_install/extract_wheels/extract_single_wheel.py b/python/pip_install/extract_wheels/extract_single_wheel.py index 85226e4b0b..c69fbd5958 100644 --- a/python/pip_install/extract_wheels/extract_single_wheel.py +++ b/python/pip_install/extract_wheels/extract_single_wheel.py @@ -7,7 +7,7 @@ from tempfile import NamedTemporaryFile from python.pip_install.extract_wheels.extract_wheels import configure_reproducible_wheels -from python.pip_install.extract_wheels.extract_wheels import arguments, bazel, requirements +from python.pip_install.extract_wheels import arguments, bazel, requirements from python.pip_install.extract_wheels.annotation import annotation_from_str_path From 1a8ba4ac59d144f661fde09eb2743ce434d5d930 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 22:09:42 +1000 Subject: [PATCH 7/8] . --- python/pip_install/extract_wheels/BUILD | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD index fa7850bfdb..377cec1682 100644 --- a/python/pip_install/extract_wheels/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -26,7 +26,6 @@ py_binary( srcs = [ "extract_wheels.py", ], - main = "extract_wheels.py", deps = [":lib"], ) @@ -35,7 +34,6 @@ py_binary( srcs = [ "extract_single_wheel.py", ], - main = "extract_single_wheel.py", deps = [":lib"], ) @@ -44,7 +42,6 @@ py_binary( srcs = [ "parse_requirements_to_bzl.py", ], - main = "parse_requirements_to_bzl.py", deps = [":lib"], ) From 47bb2ac5b587b14a51d3dba3847e3f5a968389f5 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Mon, 4 Jul 2022 22:38:34 +1000 Subject: [PATCH 8/8] . --- python/pip_install/extract_wheels/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pip_install/extract_wheels/BUILD b/python/pip_install/extract_wheels/BUILD index 377cec1682..158d34ba27 100644 --- a/python/pip_install/extract_wheels/BUILD +++ b/python/pip_install/extract_wheels/BUILD @@ -8,8 +8,8 @@ py_library( "annotation.py", "arguments.py", "bazel.py", - "extract_wheels.py", "extract_single_wheel.py", + "extract_wheels.py", "namespace_pkgs.py", "parse_requirements_to_bzl.py", "requirements.py",