From 604e45b3d98a3622a296faef453ce3f902c4a552 Mon Sep 17 00:00:00 2001 From: Viraj Shah <42321347+virajbshah@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:28:46 +0530 Subject: [PATCH] Change the source of `rules_python.python.runfiles` to PyPI. (#205) * `runfiles` is provided both as part of the Bazel `rules_python` repository as `@rules_python//python:runfiles` and on PyPI as the `bazel-runfiles` pip package. * It could be imported from the Bazel repository as `rules_python.python.runfiles` when using WORKSPACE, but needed to be imported as `python.runfiles` when using Bzlmod. * However, the pip package is independent of whether WORKSPACE or Bzlmod is being used. * See https://github.com/bazelbuild/rules_python/issues/1679 for details. --- gematria/datasets/pipelines/BUILD.bazel | 1 - .../datasets/pipelines/compile_modules_lib.py | 2 +- gematria/datasets/python/BUILD.bazel | 1 - .../python/annotated_tfrecord_writer.py | 0 .../python/extract_bbs_from_obj_test.py | 2 +- gematria/testing/python/BUILD.bazel | 4 --- .../python/basic_blocks_with_throughput.py | 2 +- gematria/testing/python/ir_utils.py | 2 +- requirements.in | 1 + requirements.txt | 33 +++++++------------ 10 files changed, 17 insertions(+), 31 deletions(-) create mode 100644 gematria/datasets/python/annotated_tfrecord_writer.py diff --git a/gematria/datasets/pipelines/BUILD.bazel b/gematria/datasets/pipelines/BUILD.bazel index 06b2d3d3..e3985e40 100644 --- a/gematria/datasets/pipelines/BUILD.bazel +++ b/gematria/datasets/pipelines/BUILD.bazel @@ -10,7 +10,6 @@ gematria_py_library( deps = [ "//gematria/datasets/python:extract_bbs_from_obj", "//gematria/datasets/python:process_and_filter_bbs", - "@rules_python//python/runfiles", ], ) diff --git a/gematria/datasets/pipelines/compile_modules_lib.py b/gematria/datasets/pipelines/compile_modules_lib.py index da357b59..9e3795af 100644 --- a/gematria/datasets/pipelines/compile_modules_lib.py +++ b/gematria/datasets/pipelines/compile_modules_lib.py @@ -18,7 +18,7 @@ from absl import logging import apache_beam as beam -from rules_python.python.runfiles import runfiles +from runfiles import runfiles from gematria.datasets.python import extract_bbs_from_obj from gematria.datasets.python import process_and_filter_bbs diff --git a/gematria/datasets/python/BUILD.bazel b/gematria/datasets/python/BUILD.bazel index 33a6aac0..0d0bc780 100644 --- a/gematria/datasets/python/BUILD.bazel +++ b/gematria/datasets/python/BUILD.bazel @@ -98,7 +98,6 @@ gematria_py_test( ], deps = [ ":extract_bbs_from_obj", - "@rules_python//python/runfiles", ], ) diff --git a/gematria/datasets/python/annotated_tfrecord_writer.py b/gematria/datasets/python/annotated_tfrecord_writer.py new file mode 100644 index 00000000..e69de29b diff --git a/gematria/datasets/python/extract_bbs_from_obj_test.py b/gematria/datasets/python/extract_bbs_from_obj_test.py index c424f4db..9543d20b 100644 --- a/gematria/datasets/python/extract_bbs_from_obj_test.py +++ b/gematria/datasets/python/extract_bbs_from_obj_test.py @@ -13,7 +13,7 @@ # limitations under the License. from absl.testing import absltest -from rules_python.python.runfiles import runfiles +from runfiles import runfiles import os from gematria.datasets.python import extract_bbs_from_obj diff --git a/gematria/testing/python/BUILD.bazel b/gematria/testing/python/BUILD.bazel index cbffdd64..1fc74766 100644 --- a/gematria/testing/python/BUILD.bazel +++ b/gematria/testing/python/BUILD.bazel @@ -16,7 +16,6 @@ gematria_py_library( "//gematria/basic_block/python:throughput_protos", "//gematria/basic_block/python:tokens", "//gematria/proto:throughput_py_pb2", - "@rules_python//python/runfiles", ], ) @@ -66,9 +65,6 @@ gematria_py_library( "@llvm-project//llvm:llvm-dis", ], visibility = ["//:internal_users"], - deps = [ - "@rules_python//python/runfiles", - ], ) gematria_py_test( diff --git a/gematria/testing/python/basic_blocks_with_throughput.py b/gematria/testing/python/basic_blocks_with_throughput.py index 5d4534d4..04cf90a9 100644 --- a/gematria/testing/python/basic_blocks_with_throughput.py +++ b/gematria/testing/python/basic_blocks_with_throughput.py @@ -25,7 +25,7 @@ from gematria.basic_block.python import tokens from gematria.proto import throughput_pb2 from google.protobuf import text_format -from rules_python.python.runfiles import runfiles +from runfiles import runfiles # The path to the basic blocks in text format in the resources of the test. _ROOT_PATH = 'com_google_gematria' diff --git a/gematria/testing/python/ir_utils.py b/gematria/testing/python/ir_utils.py index 8bcc30e6..2c8c8980 100644 --- a/gematria/testing/python/ir_utils.py +++ b/gematria/testing/python/ir_utils.py @@ -26,7 +26,7 @@ import pandas import pyarrow from pyarrow import parquet -from rules_python.python.runfiles import runfiles +from runfiles import runfiles def _get_llvm_binary_path(tool_name: str) -> str: diff --git a/requirements.in b/requirements.in index d87d8b7f..471569b6 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,5 @@ absl-py>=1.4.0 +bazel-runfiles>=0.35.0 contextlib2>=21.6.0 networkx>=2.8.8 numpy>=1.23.2 diff --git a/requirements.txt b/requirements.txt index 5c6900a0..ae6db4bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in @@ -16,13 +16,13 @@ apache-beam==2.58.1 # via -r requirements.in astunparse==1.6.3 # via tensorflow -async-timeout==4.0.3 - # via redis -attrs==23.2.0 +attrs==24.2.0 # via # jsonschema # referencing -certifi==2024.7.4 +bazel-runfiles==0.35.0 + # via -r requirements.in +certifi==2024.8.30 # via requests charset-normalizer==3.3.2 # via requests @@ -44,7 +44,7 @@ dnspython==2.6.1 # via pymongo docopt==0.6.2 # via hdfs -fastavro==1.9.5 +fastavro==1.9.7 # via apache-beam fasteners==0.19 # via apache-beam @@ -56,7 +56,7 @@ gast==0.6.0 # tensorflow-probability google-pasta==0.2.0 # via tensorflow -grpcio==1.66.0 +grpcio==1.66.1 # via # apache-beam # tensorboard @@ -71,8 +71,6 @@ httplib2==0.22.0 # via apache-beam idna==3.8 # via requests -js2py==0.74 - # via apache-beam jsonpickle==3.3.0 # via apache-beam jsonschema==4.23.0 @@ -121,7 +119,7 @@ opt-einsum==3.3.0 # via tensorflow optree==0.12.1 # via keras -orjson==3.10.6 +orjson==3.10.7 # via apache-beam packaging==24.1 # via @@ -149,11 +147,9 @@ pydot==1.4.2 # via apache-beam pygments==2.18.0 # via rich -pyjsparser==2.7.1 - # via js2py pymongo==4.8.0 # via apache-beam -pyparsing==3.1.2 +pyparsing==3.1.4 # via # httplib2 # pydot @@ -161,7 +157,7 @@ python-dateutil==2.9.0.post0 # via # apache-beam # pandas -pytz==2024.1 +pytz==2024.2 # via # apache-beam # pandas @@ -171,14 +167,14 @@ referencing==0.35.1 # via # jsonschema # jsonschema-specifications -regex==2024.7.24 +regex==2024.9.11 # via apache-beam requests==2.31.0 # via # apache-beam # hdfs # tensorflow -rich==13.8.0 +rich==13.8.1 # via keras rpds-py==0.20.0 # via @@ -193,7 +189,6 @@ six==1.16.0 # astunparse # google-pasta # hdfs - # js2py # python-dateutil # tensorboard # tensorflow @@ -206,8 +201,6 @@ tensorflow==2.17.0 ; sys_platform == "linux" # via # -r requirements.in # tf-keras -tensorflow-io-gcs-filesystem==0.37.1 - # via tensorflow tensorflow-probability==0.24.0 # via -r requirements.in termcolor==2.4.0 @@ -223,8 +216,6 @@ typing-extensions==4.12.2 # tensorflow tzdata==2024.1 # via pandas -tzlocal==5.2 - # via js2py urllib3==2.2.2 # via requests werkzeug==3.0.4