diff options
Diffstat (limited to 'sci-libs/tensorflow/files/tensorflow-2.14.1-0012-build-use-non-hermetic-python.patch')
-rw-r--r-- | sci-libs/tensorflow/files/tensorflow-2.14.1-0012-build-use-non-hermetic-python.patch | 2745 |
1 files changed, 2745 insertions, 0 deletions
diff --git a/sci-libs/tensorflow/files/tensorflow-2.14.1-0012-build-use-non-hermetic-python.patch b/sci-libs/tensorflow/files/tensorflow-2.14.1-0012-build-use-non-hermetic-python.patch new file mode 100644 index 000000000000..67108a290e13 --- /dev/null +++ b/sci-libs/tensorflow/files/tensorflow-2.14.1-0012-build-use-non-hermetic-python.patch @@ -0,0 +1,2745 @@ +From 3f0e4685b47f71c80b18bc5b6cba1afd56070604 Mon Sep 17 00:00:00 2001 +From: wangjiezhe <wangjiezhe@gmail.com> +Date: Thu, 21 Dec 2023 22:25:46 +0800 +Subject: [PATCH 12/13] build: use non-hermetic python + +--- + WORKSPACE | 65 -- + tensorflow/BUILD | 2 - + tensorflow/compiler/mlir/glob_lit_test.bzl | 1 - + tensorflow/compiler/xla/glob_lit_test.bzl | 5 - + tensorflow/compiler/xla/mlir_hlo/tests/BUILD | 1 - + tensorflow/dtensor/python/tests/BUILD | 1 - + tensorflow/lite/python/BUILD | 1 - + tensorflow/python/BUILD | 1 - + tensorflow/python/compiler/tensorrt/BUILD | 1 - + .../experimental/kernel_tests/service/BUILD | 1 - + tensorflow/python/debug/lib/BUILD | 1 - + .../python/distribute/experimental/rpc/BUILD | 1 - + .../python/distribute/failure_handling/BUILD | 1 - + tensorflow/python/eager/BUILD | 1 - + tensorflow/python/estimator/BUILD | 5 +- + tensorflow/python/framework/BUILD | 2 - + tensorflow/python/keras/BUILD | 1 - + tensorflow/python/keras/engine/BUILD | 1 - + tensorflow/python/keras/saving/BUILD | 1 - + tensorflow/python/profiler/BUILD | 1 - + .../python/profiler/integration_test/BUILD | 1 - + tensorflow/python/summary/BUILD | 1 - + third_party/py/BUILD.tpl | 39 +- + third_party/py/{non_hermetic => }/README | 0 + third_party/py/non_hermetic/BUILD | 0 + third_party/py/non_hermetic/BUILD.tpl | 80 -- + third_party/py/non_hermetic/ml_dtypes/BUILD | 0 + third_party/py/non_hermetic/ml_dtypes/LICENSE | 202 ---- + .../py/non_hermetic/ml_dtypes/ml_dtypes.BUILD | 50 - + .../ml_dtypes/ml_dtypes.tests.BUILD | 60 -- + .../py/non_hermetic/ml_dtypes/workspace.bzl | 22 - + third_party/py/non_hermetic/numpy/BUILD | 21 - + third_party/py/non_hermetic/numpy/README.md | 4 - + .../py/non_hermetic/numpy/tf_numpy_api/BUILD | 12 - + ...ensorflow.experimental.numpy.ndarray.pbtxt | 51 - + .../tensorflow.experimental.numpy.pbtxt | 919 ------------------ + ...tensorflow.experimental.numpy.random.pbtxt | 35 - + .../py/non_hermetic/python_configure.bzl | 315 ------ + third_party/py/numpy/BUILD | 7 +- + third_party/py/numpy/LICENSE | 60 -- + .../tensorflow.experimental.numpy.pbtxt | 2 +- + third_party/py/python_configure.bzl | 252 ++++- + 42 files changed, 291 insertions(+), 1936 deletions(-) + rename third_party/py/{non_hermetic => }/README (100%) + delete mode 100644 third_party/py/non_hermetic/BUILD + delete mode 100644 third_party/py/non_hermetic/BUILD.tpl + delete mode 100644 third_party/py/non_hermetic/ml_dtypes/BUILD + delete mode 100644 third_party/py/non_hermetic/ml_dtypes/LICENSE + delete mode 100644 third_party/py/non_hermetic/ml_dtypes/ml_dtypes.BUILD + delete mode 100644 third_party/py/non_hermetic/ml_dtypes/ml_dtypes.tests.BUILD + delete mode 100644 third_party/py/non_hermetic/ml_dtypes/workspace.bzl + delete mode 100644 third_party/py/non_hermetic/numpy/BUILD + delete mode 100644 third_party/py/non_hermetic/numpy/README.md + delete mode 100644 third_party/py/non_hermetic/numpy/tf_numpy_api/BUILD + delete mode 100644 third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.ndarray.pbtxt + delete mode 100644 third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt + delete mode 100644 third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.random.pbtxt + delete mode 100644 third_party/py/non_hermetic/python_configure.bzl + delete mode 100644 third_party/py/numpy/LICENSE + +diff --git a/WORKSPACE b/WORKSPACE +index 644b731b1dc..3626ae4e805 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -11,71 +11,6 @@ http_archive( + ], + ) + +-# We must initialize hermetic python first. +-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +- +-http_archive( +- name = "bazel_skylib", +- sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", +- urls = [ +- "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", +- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", +- ], +-) +- +-http_archive( +- name = "rules_python", +- sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841", +- strip_prefix = "rules_python-0.23.1", +- url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz", +-) +- +-load("@rules_python//python:repositories.bzl", "python_register_toolchains") +-load( +- "//tensorflow/tools/toolchains/python:python_repo.bzl", +- "python_repository", +-) +- +-python_repository(name = "python_version_repo") +- +-load("@python_version_repo//:py_version.bzl", "HERMETIC_PYTHON_VERSION") +- +-python_register_toolchains( +- name = "python", +- ignore_root_user_error = True, +- python_version = HERMETIC_PYTHON_VERSION, +-) +- +-load("@python//:defs.bzl", "interpreter") +-load("@rules_python//python:pip.bzl", "package_annotation", "pip_parse") +- +-NUMPY_ANNOTATIONS = { +- "numpy": package_annotation( +- additive_build_content = """\ +-filegroup( +- name = "includes", +- srcs = glob(["site-packages/numpy/core/include/**/*.h"]), +-) +-cc_library( +- name = "numpy_headers", +- hdrs = [":includes"], +- strip_include_prefix="site-packages/numpy/core/include/", +-) +-""", +- ), +-} +- +-pip_parse( +- name = "pypi", +- annotations = NUMPY_ANNOTATIONS, +- python_interpreter_target = interpreter, +- requirements = "//:requirements_lock_" + HERMETIC_PYTHON_VERSION.replace(".", "_") + ".txt", +-) +- +-load("@pypi//:requirements.bzl", "install_deps") +- +-install_deps() +- + # Initialize the TensorFlow repository and all dependencies. + # + # The cascade of load() statements and tf_workspace?() calls works around the +diff --git a/tensorflow/BUILD b/tensorflow/BUILD +index 63ce1e7b385..9573a982298 100644 +--- a/tensorflow/BUILD ++++ b/tensorflow/BUILD +@@ -1718,8 +1718,6 @@ py_library( + "//tensorflow/lite/python:lite", + "//tensorflow/lite/python/authoring", + "//tensorflow/python:no_contrib", +- "@pypi_keras//:pkg", +- "@pypi_tensorboard//:pkg", + ], + ) + # copybara:comment_end +diff --git a/tensorflow/compiler/mlir/glob_lit_test.bzl b/tensorflow/compiler/mlir/glob_lit_test.bzl +index e689b4c0b31..f65c86b727b 100644 +--- a/tensorflow/compiler/mlir/glob_lit_test.bzl ++++ b/tensorflow/compiler/mlir/glob_lit_test.bzl +@@ -58,7 +58,6 @@ def _run_lit_test(name, data, size, tags, driver, features, exec_properties): + "@llvm-project//llvm:count", + "@llvm-project//llvm:not", + ], +- deps = ["@pypi_lit//:pkg"], + size = size, + main = "lit.py", + exec_properties = exec_properties, +diff --git a/tensorflow/compiler/xla/glob_lit_test.bzl b/tensorflow/compiler/xla/glob_lit_test.bzl +index 44b838ccb0a..86200b24da1 100644 +--- a/tensorflow/compiler/xla/glob_lit_test.bzl ++++ b/tensorflow/compiler/xla/glob_lit_test.bzl +@@ -52,10 +52,6 @@ def _run_lit_test(name, data, size, tags, driver, features, exec_properties): + # can remove this logic. This is necessary to have these tests run on builds + # using Python 3.11, but also to not include `@pypi_lit` in standalone xla + # builds where it won't be found. +- deps = [] +- if xla_root_dir == "tensorflow/compiler/xla/": +- deps.append("@pypi_lit//:pkg") +- + native.py_test( + name = name, + srcs = ["@llvm-project//llvm:lit"], +@@ -69,7 +65,6 @@ def _run_lit_test(name, data, size, tags, driver, features, exec_properties): + "@llvm-project//llvm:count", + "@llvm-project//llvm:not", + ], +- deps = deps, + size = size, + main = "lit.py", + exec_properties = exec_properties, +diff --git a/tensorflow/compiler/xla/mlir_hlo/tests/BUILD b/tensorflow/compiler/xla/mlir_hlo/tests/BUILD +index 3b67c8fdbec..30a3c562f75 100644 +--- a/tensorflow/compiler/xla/mlir_hlo/tests/BUILD ++++ b/tensorflow/compiler/xla/mlir_hlo/tests/BUILD +@@ -26,7 +26,6 @@ package( + tags = [ + "nomsan", # The execution engine doesn't work with msan, see b/248097619. + ], +- deps = ["@pypi_lit//:pkg"], + ) + for src in glob(["**/*.mlir"]) + ] +diff --git a/tensorflow/dtensor/python/tests/BUILD b/tensorflow/dtensor/python/tests/BUILD +index 615baad3085..9b6c5839b03 100644 +--- a/tensorflow/dtensor/python/tests/BUILD ++++ b/tensorflow/dtensor/python/tests/BUILD +@@ -303,7 +303,6 @@ pytype_strict_library( + ":test_util", + "//tensorflow/python/platform:client_testlib", + "@absl_py//absl/flags", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/lite/python/BUILD b/tensorflow/lite/python/BUILD +index cf03dad0ee0..8b771ac20ae 100644 +--- a/tensorflow/lite/python/BUILD ++++ b/tensorflow/lite/python/BUILD +@@ -266,7 +266,6 @@ py_test( + "//tensorflow/python/framework:test_lib", + "//tensorflow/python/platform:client_testlib", + "//tensorflow/python/platform:resource_loader", +- "@pypi_jax//:pkg", + ], + ) + +diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD +index c1b7eb7c0ea..4093f4c5c09 100644 +--- a/tensorflow/python/BUILD ++++ b/tensorflow/python/BUILD +@@ -550,7 +550,6 @@ py_strict_library( + deps = [ + ":keras_lib", + "//third_party/py/numpy", +- "@pypi_scipy//:pkg", + "@six_archive//:six", + ], + ) +diff --git a/tensorflow/python/compiler/tensorrt/BUILD b/tensorflow/python/compiler/tensorrt/BUILD +index f3fd845ff53..78a45f4ed25 100644 +--- a/tensorflow/python/compiler/tensorrt/BUILD ++++ b/tensorflow/python/compiler/tensorrt/BUILD +@@ -69,7 +69,6 @@ py_strict_library( + "//tensorflow/python/util:nest", + "//tensorflow/python/util:tf_export", + "//third_party/py/numpy", +- "@pypi_packaging//:pkg", + "@six_archive//:six", + ], + ) +diff --git a/tensorflow/python/data/experimental/kernel_tests/service/BUILD b/tensorflow/python/data/experimental/kernel_tests/service/BUILD +index 8d36d2e3637..2b8a8fd3654 100644 +--- a/tensorflow/python/data/experimental/kernel_tests/service/BUILD ++++ b/tensorflow/python/data/experimental/kernel_tests/service/BUILD +@@ -143,7 +143,6 @@ tf_py_strict_test( + "//tensorflow/python/ops:array_ops", + "//tensorflow/python/platform:client_testlib", + "@absl_py//absl/testing:parameterized", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/python/debug/lib/BUILD b/tensorflow/python/debug/lib/BUILD +index 37c99b30dd2..012e349dffc 100644 +--- a/tensorflow/python/debug/lib/BUILD ++++ b/tensorflow/python/debug/lib/BUILD +@@ -596,7 +596,6 @@ py_strict_library( + "//tensorflow/python/lib/io:lib", + "//tensorflow/python/ops:variables", + "//tensorflow/python/util:compat", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/python/distribute/experimental/rpc/BUILD b/tensorflow/python/distribute/experimental/rpc/BUILD +index 94855205c70..3b3e3f9aee3 100644 +--- a/tensorflow/python/distribute/experimental/rpc/BUILD ++++ b/tensorflow/python/distribute/experimental/rpc/BUILD +@@ -60,6 +60,5 @@ tf_py_strict_test( + "//tensorflow/python/ops:variables", + "//tensorflow/python/platform:client_testlib", + "//tensorflow/python/util:nest", +- "@pypi_portpicker//:pkg", + ], + ) +diff --git a/tensorflow/python/distribute/failure_handling/BUILD b/tensorflow/python/distribute/failure_handling/BUILD +index 77317019fee..df52d80552e 100644 +--- a/tensorflow/python/distribute/failure_handling/BUILD ++++ b/tensorflow/python/distribute/failure_handling/BUILD +@@ -47,7 +47,6 @@ py_strict_library( + deps = [ + "//tensorflow/python/eager:context", + "//tensorflow/python/platform:tf_logging", +- "@pypi_requests//:pkg", + "@six_archive//:six", + ], + ) +diff --git a/tensorflow/python/eager/BUILD b/tensorflow/python/eager/BUILD +index b7bc8350e13..dc5e0ae232f 100644 +--- a/tensorflow/python/eager/BUILD ++++ b/tensorflow/python/eager/BUILD +@@ -1167,7 +1167,6 @@ cuda_py_strict_test( + "//tensorflow/python/training:server_lib", + "//tensorflow/python/util:compat", + "@absl_py//absl/testing:parameterized", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/python/estimator/BUILD b/tensorflow/python/estimator/BUILD +index 73a7c2626bb..0952ccb3154 100644 +--- a/tensorflow/python/estimator/BUILD ++++ b/tensorflow/python/estimator/BUILD +@@ -380,7 +380,8 @@ py_library( + ], + ) + +-alias( ++py_library( + name = "expect_tensorflow_estimator_installed", +- actual = "@pypi_tensorflow_estimator//:pkg", ++ srcs_version = "PY3", ++ visibility = ["//visibility:public"], + ) +diff --git a/tensorflow/python/framework/BUILD b/tensorflow/python/framework/BUILD +index d8ce1f5c0bf..1100c23b562 100644 +--- a/tensorflow/python/framework/BUILD ++++ b/tensorflow/python/framework/BUILD +@@ -359,7 +359,6 @@ py_strict_library( + "//tensorflow/python/util:deprecation", + "//tensorflow/python/util:tf_export", + "//third_party/py/numpy", +- "@pypi_packaging//:pkg", + ] + if_xla_available([ + "//tensorflow/python:_pywrap_tfcompile", + ]), +@@ -2036,7 +2035,6 @@ py_strict_library( + "//tensorflow/python/util/protobuf", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/python/keras/BUILD b/tensorflow/python/keras/BUILD +index c271a5ef77a..d516853a13e 100755 +--- a/tensorflow/python/keras/BUILD ++++ b/tensorflow/python/keras/BUILD +@@ -42,7 +42,6 @@ py_library( + "//tensorflow/python/saved_model", + "//tensorflow/python/training", + "//tensorflow/python/util:nest", +- "@pypi_h5py//:pkg", + ], + ) + +diff --git a/tensorflow/python/keras/engine/BUILD b/tensorflow/python/keras/engine/BUILD +index 2098b1650bc..287b1a4aa91 100644 +--- a/tensorflow/python/keras/engine/BUILD ++++ b/tensorflow/python/keras/engine/BUILD +@@ -93,7 +93,6 @@ py_library( + "//tensorflow/python/util:tf_decorator", + "//tensorflow/python/util:tf_export", + "//tensorflow/tools/docs:doc_controls", +- "@pypi_h5py//:pkg", + ], + ) + +diff --git a/tensorflow/python/keras/saving/BUILD b/tensorflow/python/keras/saving/BUILD +index d7cb2ccb2fc..b40d979c82d 100644 +--- a/tensorflow/python/keras/saving/BUILD ++++ b/tensorflow/python/keras/saving/BUILD +@@ -53,6 +53,5 @@ py_library( + "//tensorflow/python/platform:tf_logging", + "//tensorflow/python/saved_model", + "//tensorflow/python/training:saver", +- "@pypi_h5py//:pkg", + ], + ) +diff --git a/tensorflow/python/profiler/BUILD b/tensorflow/python/profiler/BUILD +index b1cfd6ea10c..9413aeeab8b 100644 +--- a/tensorflow/python/profiler/BUILD ++++ b/tensorflow/python/profiler/BUILD +@@ -43,7 +43,6 @@ cuda_py_strict_test( + "//tensorflow/python/eager:test", + "//tensorflow/python/framework:errors", + "//tensorflow/python/framework:test_lib", +- "@pypi_portpicker//:pkg", + ], + ) + +diff --git a/tensorflow/python/profiler/integration_test/BUILD b/tensorflow/python/profiler/integration_test/BUILD +index b20698ea6ea..e7060e5a315 100644 +--- a/tensorflow/python/profiler/integration_test/BUILD ++++ b/tensorflow/python/profiler/integration_test/BUILD +@@ -35,6 +35,5 @@ cuda_py_strict_test( + "//tensorflow/python/platform:tf_logging", + "//tensorflow/python/profiler:profiler_client", + "//tensorflow/python/profiler:profiler_v2", +- "@pypi_portpicker//:pkg", + ], + ) +diff --git a/tensorflow/python/summary/BUILD b/tensorflow/python/summary/BUILD +index 126fb6d31f7..b292e39356f 100644 +--- a/tensorflow/python/summary/BUILD ++++ b/tensorflow/python/summary/BUILD +@@ -121,6 +121,5 @@ tf_py_strict_test( + "//tensorflow/python/ops:summary_ops_v2", + "//tensorflow/python/platform:client_testlib", + "//tensorflow/python/training:training_util", +- "@pypi_tensorboard//:pkg", + ], + ) +diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl +index 7cc1e085684..45480bd4a31 100644 +--- a/third_party/py/BUILD.tpl ++++ b/third_party/py/BUILD.tpl +@@ -5,17 +5,16 @@ package(default_visibility = ["//visibility:public"]) + # Point both runtimes to the same python binary to ensure we always + # use the python binary specified by ./configure.py script. + load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") +-load("@python//:defs.bzl", "interpreter") + + py_runtime( + name = "py2_runtime", +- interpreter_path = interpreter, ++ interpreter_path = "%{PYTHON_BIN_PATH}", + python_version = "PY2", + ) + + py_runtime( + name = "py3_runtime", +- interpreter_path = interpreter, ++ interpreter_path = "%{PYTHON_BIN_PATH}", + python_version = "PY3", + ) + +@@ -33,8 +32,27 @@ toolchain( + exec_compatible_with = [%{PLATFORM_CONSTRAINT}], + ) + +-alias(name = "python_headers", +- actual = "@python//:python_headers") ++# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib ++# See https://docs.python.org/3/extending/windows.html ++cc_import( ++ name = "python_lib", ++ interface_library = select({ ++ ":windows": ":python_import_lib", ++ # A placeholder for Unix platforms which makes --no_build happy. ++ "//conditions:default": "not-existing.lib", ++ }), ++ system_provided = 1, ++) ++ ++cc_library( ++ name = "python_headers", ++ hdrs = [":python_include"], ++ deps = select({ ++ ":windows": [":python_lib"], ++ "//conditions:default": [], ++ }), ++ includes = ["python_include"], ++) + + # This alias is exists for the use of targets in the @llvm-project dependency, + # which expect a python_headers target called @python_runtime//:headers. We use +@@ -45,9 +63,18 @@ alias( + actual = ":python_headers", + ) + ++cc_library( ++ name = "numpy_headers", ++ hdrs = [":numpy_include"], ++ includes = ["numpy_include"], ++) + + config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, + visibility = ["//visibility:public"], +-) +\ No newline at end of file ++) ++ ++%{PYTHON_INCLUDE_GENRULE} ++%{NUMPY_INCLUDE_GENRULE} ++%{PYTHON_IMPORT_LIB_GENRULE} +\ No newline at end of file +diff --git a/third_party/py/non_hermetic/README b/third_party/py/README +similarity index 100% +rename from third_party/py/non_hermetic/README +rename to third_party/py/README +diff --git a/third_party/py/non_hermetic/BUILD b/third_party/py/non_hermetic/BUILD +deleted file mode 100644 +index e69de29bb2d..00000000000 +diff --git a/third_party/py/non_hermetic/BUILD.tpl b/third_party/py/non_hermetic/BUILD.tpl +deleted file mode 100644 +index 45480bd4a31..00000000000 +--- a/third_party/py/non_hermetic/BUILD.tpl ++++ /dev/null +@@ -1,80 +0,0 @@ +-licenses(["restricted"]) +- +-package(default_visibility = ["//visibility:public"]) +- +-# Point both runtimes to the same python binary to ensure we always +-# use the python binary specified by ./configure.py script. +-load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") +- +-py_runtime( +- name = "py2_runtime", +- interpreter_path = "%{PYTHON_BIN_PATH}", +- python_version = "PY2", +-) +- +-py_runtime( +- name = "py3_runtime", +- interpreter_path = "%{PYTHON_BIN_PATH}", +- python_version = "PY3", +-) +- +-py_runtime_pair( +- name = "py_runtime_pair", +- py2_runtime = ":py2_runtime", +- py3_runtime = ":py3_runtime", +-) +- +-toolchain( +- name = "py_toolchain", +- toolchain = ":py_runtime_pair", +- toolchain_type = "@bazel_tools//tools/python:toolchain_type", +- target_compatible_with = [%{PLATFORM_CONSTRAINT}], +- exec_compatible_with = [%{PLATFORM_CONSTRAINT}], +-) +- +-# To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +-# See https://docs.python.org/3/extending/windows.html +-cc_import( +- name = "python_lib", +- interface_library = select({ +- ":windows": ":python_import_lib", +- # A placeholder for Unix platforms which makes --no_build happy. +- "//conditions:default": "not-existing.lib", +- }), +- system_provided = 1, +-) +- +-cc_library( +- name = "python_headers", +- hdrs = [":python_include"], +- deps = select({ +- ":windows": [":python_lib"], +- "//conditions:default": [], +- }), +- includes = ["python_include"], +-) +- +-# This alias is exists for the use of targets in the @llvm-project dependency, +-# which expect a python_headers target called @python_runtime//:headers. We use +-# a repo_mapping to alias python_runtime to this package, and an alias to create +-# the correct target. +-alias( +- name = "headers", +- actual = ":python_headers", +-) +- +-cc_library( +- name = "numpy_headers", +- hdrs = [":numpy_include"], +- includes = ["numpy_include"], +-) +- +-config_setting( +- name = "windows", +- values = {"cpu": "x64_windows"}, +- visibility = ["//visibility:public"], +-) +- +-%{PYTHON_INCLUDE_GENRULE} +-%{NUMPY_INCLUDE_GENRULE} +-%{PYTHON_IMPORT_LIB_GENRULE} +\ No newline at end of file +diff --git a/third_party/py/non_hermetic/ml_dtypes/BUILD b/third_party/py/non_hermetic/ml_dtypes/BUILD +deleted file mode 100644 +index e69de29bb2d..00000000000 +diff --git a/third_party/py/non_hermetic/ml_dtypes/LICENSE b/third_party/py/non_hermetic/ml_dtypes/LICENSE +deleted file mode 100644 +index d6456956733..00000000000 +--- a/third_party/py/non_hermetic/ml_dtypes/LICENSE ++++ /dev/null +@@ -1,202 +0,0 @@ +- +- Apache License +- Version 2.0, January 2004 +- http://www.apache.org/licenses/ +- +- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +- +- 1. Definitions. +- +- "License" shall mean the terms and conditions for use, reproduction, +- and distribution as defined by Sections 1 through 9 of this document. +- +- "Licensor" shall mean the copyright owner or entity authorized by +- the copyright owner that is granting the License. +- +- "Legal Entity" shall mean the union of the acting entity and all +- other entities that control, are controlled by, or are under common +- control with that entity. For the purposes of this definition, +- "control" means (i) the power, direct or indirect, to cause the +- direction or management of such entity, whether by contract or +- otherwise, or (ii) ownership of fifty percent (50%) or more of the +- outstanding shares, or (iii) beneficial ownership of such entity. +- +- "You" (or "Your") shall mean an individual or Legal Entity +- exercising permissions granted by this License. +- +- "Source" form shall mean the preferred form for making modifications, +- including but not limited to software source code, documentation +- source, and configuration files. +- +- "Object" form shall mean any form resulting from mechanical +- transformation or translation of a Source form, including but +- not limited to compiled object code, generated documentation, +- and conversions to other media types. +- +- "Work" shall mean the work of authorship, whether in Source or +- Object form, made available under the License, as indicated by a +- copyright notice that is included in or attached to the work +- (an example is provided in the Appendix below). +- +- "Derivative Works" shall mean any work, whether in Source or Object +- form, that is based on (or derived from) the Work and for which the +- editorial revisions, annotations, elaborations, or other modifications +- represent, as a whole, an original work of authorship. For the purposes +- of this License, Derivative Works shall not include works that remain +- separable from, or merely link (or bind by name) to the interfaces of, +- the Work and Derivative Works thereof. +- +- "Contribution" shall mean any work of authorship, including +- the original version of the Work and any modifications or additions +- to that Work or Derivative Works thereof, that is intentionally +- submitted to Licensor for inclusion in the Work by the copyright owner +- or by an individual or Legal Entity authorized to submit on behalf of +- the copyright owner. For the purposes of this definition, "submitted" +- means any form of electronic, verbal, or written communication sent +- to the Licensor or its representatives, including but not limited to +- communication on electronic mailing lists, source code control systems, +- and issue tracking systems that are managed by, or on behalf of, the +- Licensor for the purpose of discussing and improving the Work, but +- excluding communication that is conspicuously marked or otherwise +- designated in writing by the copyright owner as "Not a Contribution." +- +- "Contributor" shall mean Licensor and any individual or Legal Entity +- on behalf of whom a Contribution has been received by Licensor and +- subsequently incorporated within the Work. +- +- 2. Grant of Copyright License. Subject to the terms and conditions of +- this License, each Contributor hereby grants to You a perpetual, +- worldwide, non-exclusive, no-charge, royalty-free, irrevocable +- copyright license to reproduce, prepare Derivative Works of, +- publicly display, publicly perform, sublicense, and distribute the +- Work and such Derivative Works in Source or Object form. +- +- 3. Grant of Patent License. Subject to the terms and conditions of +- this License, each Contributor hereby grants to You a perpetual, +- worldwide, non-exclusive, no-charge, royalty-free, irrevocable +- (except as stated in this section) patent license to make, have made, +- use, offer to sell, sell, import, and otherwise transfer the Work, +- where such license applies only to those patent claims licensable +- by such Contributor that are necessarily infringed by their +- Contribution(s) alone or by combination of their Contribution(s) +- with the Work to which such Contribution(s) was submitted. If You +- institute patent litigation against any entity (including a +- cross-claim or counterclaim in a lawsuit) alleging that the Work +- or a Contribution incorporated within the Work constitutes direct +- or contributory patent infringement, then any patent licenses +- granted to You under this License for that Work shall terminate +- as of the date such litigation is filed. +- +- 4. Redistribution. You may reproduce and distribute copies of the +- Work or Derivative Works thereof in any medium, with or without +- modifications, and in Source or Object form, provided that You +- meet the following conditions: +- +- (a) You must give any other recipients of the Work or +- Derivative Works a copy of this License; and +- +- (b) You must cause any modified files to carry prominent notices +- stating that You changed the files; and +- +- (c) You must retain, in the Source form of any Derivative Works +- that You distribute, all copyright, patent, trademark, and +- attribution notices from the Source form of the Work, +- excluding those notices that do not pertain to any part of +- the Derivative Works; and +- +- (d) If the Work includes a "NOTICE" text file as part of its +- distribution, then any Derivative Works that You distribute must +- include a readable copy of the attribution notices contained +- within such NOTICE file, excluding those notices that do not +- pertain to any part of the Derivative Works, in at least one +- of the following places: within a NOTICE text file distributed +- as part of the Derivative Works; within the Source form or +- documentation, if provided along with the Derivative Works; or, +- within a display generated by the Derivative Works, if and +- wherever such third-party notices normally appear. The contents +- of the NOTICE file are for informational purposes only and +- do not modify the License. You may add Your own attribution +- notices within Derivative Works that You distribute, alongside +- or as an addendum to the NOTICE text from the Work, provided +- that such additional attribution notices cannot be construed +- as modifying the License. +- +- You may add Your own copyright statement to Your modifications and +- may provide additional or different license terms and conditions +- for use, reproduction, or distribution of Your modifications, or +- for any such Derivative Works as a whole, provided Your use, +- reproduction, and distribution of the Work otherwise complies with +- the conditions stated in this License. +- +- 5. Submission of Contributions. Unless You explicitly state otherwise, +- any Contribution intentionally submitted for inclusion in the Work +- by You to the Licensor shall be under the terms and conditions of +- this License, without any additional terms or conditions. +- Notwithstanding the above, nothing herein shall supersede or modify +- the terms of any separate license agreement you may have executed +- with Licensor regarding such Contributions. +- +- 6. Trademarks. This License does not grant permission to use the trade +- names, trademarks, service marks, or product names of the Licensor, +- except as required for reasonable and customary use in describing the +- origin of the Work and reproducing the content of the NOTICE file. +- +- 7. Disclaimer of Warranty. Unless required by applicable law or +- agreed to in writing, Licensor provides the Work (and each +- Contributor provides its Contributions) on an "AS IS" BASIS, +- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +- implied, including, without limitation, any warranties or conditions +- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +- PARTICULAR PURPOSE. You are solely responsible for determining the +- appropriateness of using or redistributing the Work and assume any +- risks associated with Your exercise of permissions under this License. +- +- 8. Limitation of Liability. In no event and under no legal theory, +- whether in tort (including negligence), contract, or otherwise, +- unless required by applicable law (such as deliberate and grossly +- negligent acts) or agreed to in writing, shall any Contributor be +- liable to You for damages, including any direct, indirect, special, +- incidental, or consequential damages of any character arising as a +- result of this License or out of the use or inability to use the +- Work (including but not limited to damages for loss of goodwill, +- work stoppage, computer failure or malfunction, or any and all +- other commercial damages or losses), even if such Contributor +- has been advised of the possibility of such damages. +- +- 9. Accepting Warranty or Additional Liability. While redistributing +- the Work or Derivative Works thereof, You may choose to offer, +- and charge a fee for, acceptance of support, warranty, indemnity, +- or other liability obligations and/or rights consistent with this +- License. However, in accepting such obligations, You may act only +- on Your own behalf and on Your sole responsibility, not on behalf +- of any other Contributor, and only if You agree to indemnify, +- defend, and hold each Contributor harmless for any liability +- incurred by, or claims asserted against, such Contributor by reason +- of your accepting any such warranty or additional liability. +- +- END OF TERMS AND CONDITIONS +- +- APPENDIX: How to apply the Apache License to your work. +- +- To apply the Apache License to your work, attach the following +- boilerplate notice, with the fields enclosed by brackets "[]" +- replaced with your own identifying information. (Don't include +- the brackets!) The text should be enclosed in the appropriate +- comment syntax for the file format. We also recommend that a +- file or class name and description of purpose be included on the +- same "printed page" as the copyright notice for easier +- identification within third-party archives. +- +- Copyright [yyyy] [name of copyright owner] +- +- Licensed under the Apache License, Version 2.0 (the "License"); +- you may not use this file except in compliance with the License. +- You may obtain a copy of the License at +- +- http://www.apache.org/licenses/LICENSE-2.0 +- +- Unless required by applicable law or agreed to in writing, software +- distributed under the License is distributed on an "AS IS" BASIS, +- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +- See the License for the specific language governing permissions and +- limitations under the License. +diff --git a/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.BUILD b/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.BUILD +deleted file mode 100644 +index 95f58d3c476..00000000000 +--- a/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.BUILD ++++ /dev/null +@@ -1,50 +0,0 @@ +-load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") +- +-package( +- default_visibility = ["//visibility:public"], +- licenses = ["notice"], +-) +- +-exports_files(["LICENSE"]) +- +-cc_library( +- name = "float8", +- hdrs = ["include/float8.h"], +- # Internal headers are all relative to , but other packages +- # include these headers with the prefix. +- includes = [ +- ".", +- "ml_dtypes", +- ], +- deps = ["@org_tensorflow//third_party/eigen3"], +-) +- +-pybind_extension( +- name = "_custom_floats", +- srcs = [ +- "_src/common.h", +- "_src/custom_float.h", +- "_src/dtypes.cc", +- "_src/int4.h", +- "_src/numpy.cc", +- "_src/numpy.h", +- "_src/ufuncs.h", +- ], +- includes = ["ml_dtypes"], +- visibility = [":__subpackages__"], +- deps = [ +- ":float8", +- "@org_tensorflow//third_party/eigen3", +- "@org_tensorflow//third_party/py/numpy:headers", +- ], +-) +- +-py_library( +- name = "ml_dtypes", +- srcs = [ +- "__init__.py", +- "_finfo.py", +- "_iinfo.py", +- ], +- deps = [":_custom_floats"], +-) +diff --git a/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.tests.BUILD b/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.tests.BUILD +deleted file mode 100644 +index fde5f2eaccf..00000000000 +--- a/third_party/py/non_hermetic/ml_dtypes/ml_dtypes.tests.BUILD ++++ /dev/null +@@ -1,60 +0,0 @@ +-package( +- default_visibility = ["//visibility:public"], +-) +- +-py_library( +- name = "testing_base", +- deps = [ +- "//:ml_dtypes", +- "@absl_py//absl/testing:absltest", +- "@absl_py//absl/testing:parameterized", +- "@org_tensorflow//third_party/py/numpy", +- ], +-) +- +-py_test( +- name = "custom_float_test", +- srcs = ["custom_float_test.py"], +- main = "custom_float_test.py", +- deps = [":testing_base"], +-) +- +-py_test( +- name = "int4_test", +- srcs = ["int4_test.py"], +- main = "int4_test.py", +- deps = [":testing_base"], +-) +- +-py_test( +- name = "iinfo_test", +- srcs = ["iinfo_test.py"], +- main = "iinfo_test.py", +- deps = [":testing_base"], +-) +- +-py_test( +- name = "finfo_test", +- srcs = ["finfo_test.py"], +- main = "finfo_test.py", +- deps = [":testing_base"], +-) +- +-py_test( +- name = "metadata_test", +- srcs = ["metadata_test.py"], +- main = "metadata_test.py", +- deps = [":testing_base"], +-) +- +-cc_test( +- name = "float8_test", +- srcs = ["float8_test.cc"], +- linkstatic = 1, +- deps = [ +- "//:float8", +- "@com_google_absl//absl/strings", +- "@com_google_googletest//:gtest_main", +- "@org_tensorflow//third_party/eigen3", +- ], +-) +diff --git a/third_party/py/non_hermetic/ml_dtypes/workspace.bzl b/third_party/py/non_hermetic/ml_dtypes/workspace.bzl +deleted file mode 100644 +index 2c34f494c34..00000000000 +--- a/third_party/py/non_hermetic/ml_dtypes/workspace.bzl ++++ /dev/null +@@ -1,22 +0,0 @@ +-"""Provides the repo macro to import ml_dtypes. +- +-ml_dtypes provides machine-learning-specific data-types like bfloat16, +-float8 varieties, and int4. +-""" +- +-load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") +- +-def repo(): +- ML_DTYPES_COMMIT = "5b9fc9ad978757654843f4a8d899715dbea30e88" +- ML_DTYPES_SHA256 = "9662811d9ab3823a56f8fa91b5a67fd82062b6dd4f187169b41e82a44e526455" +- tf_http_archive( +- name = "ml_dtypes", +- build_file = "//third_party/py/ml_dtypes:ml_dtypes.BUILD", +- link_files = { +- "//third_party/py/ml_dtypes:ml_dtypes.tests.BUILD": "tests/BUILD.bazel", +- "//third_party/py/ml_dtypes:LICENSE": "LICENSE", +- }, +- sha256 = ML_DTYPES_SHA256, +- strip_prefix = "ml_dtypes-{commit}/ml_dtypes".format(commit = ML_DTYPES_COMMIT), +- urls = tf_mirror_urls("https://github.com/jax-ml/ml_dtypes/archive/{commit}/ml_dtypes-{commit}.tar.gz".format(commit = ML_DTYPES_COMMIT)), +- ) +diff --git a/third_party/py/non_hermetic/numpy/BUILD b/third_party/py/non_hermetic/numpy/BUILD +deleted file mode 100644 +index c80cc5287bc..00000000000 +--- a/third_party/py/non_hermetic/numpy/BUILD ++++ /dev/null +@@ -1,21 +0,0 @@ +-licenses(["restricted"]) +- +-package(default_visibility = ["//visibility:public"]) +- +-py_library( +- name = "numpy", +- srcs = ["tf_numpy_dummy.py"], +- srcs_version = "PY3", +-) +- +-alias( +- name = "headers", +- actual = "@local_config_python//:numpy_headers", +-) +- +-genrule( +- name = "dummy", +- outs = ["tf_numpy_dummy.py"], +- cmd = "touch $@", +- visibility = ["//visibility:private"], +-) +diff --git a/third_party/py/non_hermetic/numpy/README.md b/third_party/py/non_hermetic/numpy/README.md +deleted file mode 100644 +index 4e58b9df87b..00000000000 +--- a/third_party/py/non_hermetic/numpy/README.md ++++ /dev/null +@@ -1,4 +0,0 @@ +-# numpy_ops +- +-The folder tf_numpy_api/ contains lists of NumPy API symbols that the +-`numpy_ops` internal module in TensorFlow implements. +diff --git a/third_party/py/non_hermetic/numpy/tf_numpy_api/BUILD b/third_party/py/non_hermetic/numpy/tf_numpy_api/BUILD +deleted file mode 100644 +index 070f8ab8a65..00000000000 +--- a/third_party/py/non_hermetic/numpy/tf_numpy_api/BUILD ++++ /dev/null +@@ -1,12 +0,0 @@ +-# TensorFlow API backwards compatibility test goldens for tf.experimental.numpy. +- +-package( +- # copybara:uncomment default_applicable_licenses = ["//tensorflow:license"], +- default_visibility = ["//visibility:public"], +- licenses = ["notice"], +-) +- +-filegroup( +- name = "api_golden", +- srcs = glob(["*.pbtxt"]), +-) +diff --git a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.ndarray.pbtxt b/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.ndarray.pbtxt +deleted file mode 100644 +index 9198264c029..00000000000 +--- a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.ndarray.pbtxt ++++ /dev/null +@@ -1,51 +0,0 @@ +-path: "tensorflow.experimental.numpy.ndarray" +-tf_class { +- is_instance: "<class \'tensorflow.python.framework.tensor.Tensor\'>" +- is_instance: "<class \'tensorflow.python.types.internal.NativeObject\'>" +- is_instance: "<class \'tensorflow.python.types.core.Symbol\'>" +- is_instance: "<class \'tensorflow.python.types.core.Tensor\'>" +- is_instance: "<type \'object\'>" +- member { +- name: "OVERLOADABLE_OPERATORS" +- mtype: "<type \'set\'>" +- } +- member { +- name: "dtype" +- mtype: "<type \'property\'>" +- } +- member { +- name: "name" +- mtype: "<type \'property\'>" +- } +- member { +- name: "ndim" +- mtype: "<type \'property\'>" +- } +- member { +- name: "shape" +- mtype: "<type \'property\'>" +- } +- member_method { +- name: "__init__" +- } +- member_method { +- name: "eval" +- argspec: "args=[\'self\', \'feed_dict\', \'session\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "experimental_ref" +- argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "get_shape" +- argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ref" +- argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "set_shape" +- argspec: "args=[\'self\', \'shape\'], varargs=None, keywords=None, defaults=None" +- } +-} +diff --git a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt b/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt +deleted file mode 100644 +index 2f5490ad0c9..00000000000 +--- a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt ++++ /dev/null +@@ -1,919 +0,0 @@ +-path: "tensorflow.experimental.numpy" +-tf_module { +- member { +- name: "bool_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "complex128" +- mtype: "<type \'type\'>" +- } +- member { +- name: "complex64" +- mtype: "<type \'type\'>" +- } +- member { +- name: "complex_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "e" +- mtype: "<class \'float\'>" +- } +- member { +- name: "float16" +- mtype: "<type \'type\'>" +- } +- member { +- name: "float32" +- mtype: "<type \'type\'>" +- } +- member { +- name: "float64" +- mtype: "<type \'type\'>" +- } +- member { +- name: "float_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "iinfo" +- mtype: "<type \'type\'>" +- } +- member { +- name: "inexact" +- mtype: "<type \'type\'>" +- } +- member { +- name: "inf" +- mtype: "<class \'float\'>" +- } +- member { +- name: "int16" +- mtype: "<type \'type\'>" +- } +- member { +- name: "int32" +- mtype: "<type \'type\'>" +- } +- member { +- name: "int64" +- mtype: "<type \'type\'>" +- } +- member { +- name: "int8" +- mtype: "<type \'type\'>" +- } +- member { +- name: "int_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "ndarray" +- mtype: "<type \'type\'>" +- } +- member { +- name: "newaxis" +- mtype: "<type \'NoneType\'>" +- } +- member { +- name: "object_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "pi" +- mtype: "<class \'float\'>" +- } +- member { +- name: "random" +- mtype: "<type \'module\'>" +- } +- member { +- name: "string_" +- mtype: "<type \'type\'>" +- } +- member { +- name: "uint16" +- mtype: "<type \'type\'>" +- } +- member { +- name: "uint32" +- mtype: "<type \'type\'>" +- } +- member { +- name: "uint64" +- mtype: "<type \'type\'>" +- } +- member { +- name: "uint8" +- mtype: "<type \'type\'>" +- } +- member { +- name: "unicode_" +- mtype: "<type \'type\'>" +- } +- member_method { +- name: "abs" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "absolute" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "add" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "all" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "allclose" +- argspec: "args=[\'a\', \'b\', \'rtol\', \'atol\', \'equal_nan\'], varargs=None, keywords=None, defaults=[\'1e-05\', \'1e-08\', \'False\'], " +- } +- member_method { +- name: "amax" +- argspec: "args=[\'a\', \'axis\', \'out\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "amin" +- argspec: "args=[\'a\', \'axis\', \'out\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "angle" +- argspec: "args=[\'z\', \'deg\'], varargs=None, keywords=None, defaults=[\'False\'], " +- } +- member_method { +- name: "any" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "append" +- argspec: "args=[\'arr\', \'values\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "arange" +- argspec: "args=[\'start\', \'stop\', \'step\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\'], " +- } +- member_method { +- name: "arccos" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arccosh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arcsin" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arcsinh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arctan" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arctan2" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "arctanh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "argmax" +- argspec: "args=[\'a\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "argmin" +- argspec: "args=[\'a\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "argsort" +- argspec: "args=[\'a\', \'axis\', \'kind\', \'order\'], varargs=None, keywords=None, defaults=[\'-1\', \'quicksort\', \'None\'], " +- } +- member_method { +- name: "around" +- argspec: "args=[\'a\', \'decimals\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "array" +- argspec: "args=[\'val\', \'dtype\', \'copy\', \'ndmin\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'0\'], " +- } +- member_method { +- name: "array_equal" +- argspec: "args=[\'a1\', \'a2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "asanyarray" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "asarray" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "ascontiguousarray" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "atleast_1d" +- argspec: "args=[], varargs=arys, keywords=None, defaults=None" +- } +- member_method { +- name: "atleast_2d" +- argspec: "args=[], varargs=arys, keywords=None, defaults=None" +- } +- member_method { +- name: "atleast_3d" +- argspec: "args=[], varargs=arys, keywords=None, defaults=None" +- } +- member_method { +- name: "average" +- argspec: "args=[\'a\', \'axis\', \'weights\', \'returned\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\'], " +- } +- member_method { +- name: "bitwise_and" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "bitwise_not" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "bitwise_or" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "bitwise_xor" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "broadcast_arrays" +- argspec: "args=[], varargs=args, keywords=kwargs, defaults=None" +- } +- member_method { +- name: "broadcast_to" +- argspec: "args=[\'array\', \'shape\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "cbrt" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ceil" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "clip" +- argspec: "args=[\'a\', \'a_min\', \'a_max\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "compress" +- argspec: "args=[\'condition\', \'a\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "concatenate" +- argspec: "args=[\'arys\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "conj" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "conjugate" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "copy" +- argspec: "args=[\'a\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "cos" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "cosh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "count_nonzero" +- argspec: "args=[\'a\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "cross" +- argspec: "args=[\'a\', \'b\', \'axisa\', \'axisb\', \'axisc\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\', \'-1\', \'-1\', \'None\'], " +- } +- member_method { +- name: "cumprod" +- argspec: "args=[\'a\', \'axis\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "cumsum" +- argspec: "args=[\'a\', \'axis\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "deg2rad" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "diag" +- argspec: "args=[\'v\', \'k\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "diag_indices" +- argspec: "args=[\'n\', \'ndim\'], varargs=None, keywords=None, defaults=[\'2\'], " +- } +- member_method { +- name: "diagflat" +- argspec: "args=[\'v\', \'k\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "diagonal" +- argspec: "args=[\'a\', \'offset\', \'axis1\', \'axis2\'], varargs=None, keywords=None, defaults=[\'0\', \'0\', \'1\'], " +- } +- member_method { +- name: "diff" +- argspec: "args=[\'a\', \'n\', \'axis\'], varargs=None, keywords=None, defaults=[\'1\', \'-1\'], " +- } +- member_method { +- name: "divide" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "divmod" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "dot" +- argspec: "args=[\'a\', \'b\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "dsplit" +- argspec: "args=[\'ary\', \'indices_or_sections\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "dstack" +- argspec: "args=[\'tup\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "einsum" +- argspec: "args=[\'subscripts\'], varargs=operands, keywords=kwargs, defaults=None" +- } +- member_method { +- name: "empty" +- argspec: "args=[\'shape\', \'dtype\'], varargs=None, keywords=None, defaults=[\"<class \'float\'>\"], " +- } +- member_method { +- name: "empty_like" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "equal" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "exp" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "exp2" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "expand_dims" +- argspec: "args=[\'a\', \'axis\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "experimental_enable_numpy_behavior" +- argspec: "args=[\'prefer_float32\'], varargs=None, keywords=None, defaults=[\'False\'], " +- } +- member_method { +- name: "expm1" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "eye" +- argspec: "args=[\'N\', \'M\', \'k\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \"<class \'float\'>\"], " +- } +- member_method { +- name: "fabs" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "finfo" +- argspec: "args=[\'dtype\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "fix" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "flatten" +- argspec: "args=[\'a\', \'order\'], varargs=None, keywords=None, defaults=[\'C\'], " +- } +- member_method { +- name: "flip" +- argspec: "args=[\'m\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "fliplr" +- argspec: "args=[\'m\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "flipud" +- argspec: "args=[\'m\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "float_power" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "floor" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "floor_divide" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "full" +- argspec: "args=[\'shape\', \'fill_value\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "full_like" +- argspec: "args=[\'a\', \'fill_value\', \'dtype\', \'order\', \'subok\', \'shape\'], varargs=None, keywords=None, defaults=[\'None\', \'K\', \'True\', \'None\'], " +- } +- member_method { +- name: "gcd" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "geomspace" +- argspec: "args=[\'start\', \'stop\', \'num\', \'endpoint\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'50\', \'True\', \'None\', \'0\'], " +- } +- member_method { +- name: "greater" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "greater_equal" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "heaviside" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "hsplit" +- argspec: "args=[\'ary\', \'indices_or_sections\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "hstack" +- argspec: "args=[\'tup\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "hypot" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "identity" +- argspec: "args=[\'n\', \'dtype\'], varargs=None, keywords=None, defaults=[\"<class \'float\'>\"], " +- } +- member_method { +- name: "imag" +- argspec: "args=[\'val\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "inner" +- argspec: "args=[\'a\', \'b\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isclose" +- argspec: "args=[\'a\', \'b\', \'rtol\', \'atol\', \'equal_nan\'], varargs=None, keywords=None, defaults=[\'1e-05\', \'1e-08\', \'False\'], " +- } +- member_method { +- name: "iscomplex" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "iscomplexobj" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isfinite" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isinf" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isnan" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isneginf" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isposinf" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isreal" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isrealobj" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "isscalar" +- argspec: "args=[\'num\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "issubdtype" +- argspec: "args=[\'arg1\', \'arg2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ix_" +- argspec: "args=[], varargs=args, keywords=None, defaults=None" +- } +- member_method { +- name: "kron" +- argspec: "args=[\'a\', \'b\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "lcm" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "less" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "less_equal" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "linspace" +- argspec: "args=[\'start\', \'stop\', \'num\', \'endpoint\', \'retstep\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'50\', \'True\', \'False\', \"<class \'float\'>\", \'0\'], " +- } +- member_method { +- name: "log" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "log10" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "log1p" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "log2" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logaddexp" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logaddexp2" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logical_and" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logical_not" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logical_or" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logical_xor" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "logspace" +- argspec: "args=[\'start\', \'stop\', \'num\', \'endpoint\', \'base\', \'dtype\', \'axis\'], varargs=None, keywords=None, defaults=[\'50\', \'True\', \'10.0\', \'None\', \'0\'], " +- } +- member_method { +- name: "matmul" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "max" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "maximum" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "mean" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'out\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "meshgrid" +- argspec: "args=[], varargs=xi, keywords=kwargs, defaults=None" +- } +- member_method { +- name: "min" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "minimum" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "mod" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "moveaxis" +- argspec: "args=[\'a\', \'source\', \'destination\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "multiply" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "nanmean" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "nanprod" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\'], " +- } +- member_method { +- name: "nansum" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\'], " +- } +- member_method { +- name: "ndim" +- argspec: "args=[\'a\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "negative" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "nextafter" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "nonzero" +- argspec: "args=[\'a\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "not_equal" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ones" +- argspec: "args=[\'shape\', \'dtype\'], varargs=None, keywords=None, defaults=[\"<class \'float\'>\"], " +- } +- member_method { +- name: "ones_like" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "outer" +- argspec: "args=[\'a\', \'b\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "pad" +- argspec: "args=[\'array\', \'pad_width\', \'mode\'], varargs=None, keywords=kwargs, defaults=None" +- } +- member_method { +- name: "polyval" +- argspec: "args=[\'p\', \'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "positive" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "power" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "prod" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "promote_types" +- argspec: "args=[\'type1\', \'type2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ptp" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "rad2deg" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "ravel" +- argspec: "args=[\'a\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "real" +- argspec: "args=[\'val\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "reciprocal" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "remainder" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "repeat" +- argspec: "args=[\'a\', \'repeats\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "reshape" +- argspec: "args=[\'a\', \'newshape\', \'order\'], varargs=None, keywords=None, defaults=[\'C\'], " +- } +- member_method { +- name: "result_type" +- argspec: "args=[], varargs=arrays_and_dtypes, keywords=None, defaults=None" +- } +- member_method { +- name: "roll" +- argspec: "args=[\'a\', \'shift\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "rot90" +- argspec: "args=[\'m\', \'k\', \'axes\'], varargs=None, keywords=None, defaults=[\'1\', \'(0, 1)\'], " +- } +- member_method { +- name: "round" +- argspec: "args=[\'a\', \'decimals\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "select" +- argspec: "args=[\'condlist\', \'choicelist\', \'default\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "shape" +- argspec: "args=[\'a\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "sign" +- argspec: "args=[\'x\', \'out\', \'where\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "signbit" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "sin" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "sinc" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "sinh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "size" +- argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "sort" +- argspec: "args=[\'a\', \'axis\', \'kind\', \'order\'], varargs=None, keywords=None, defaults=[\'-1\', \'quicksort\', \'None\'], " +- } +- member_method { +- name: "split" +- argspec: "args=[\'ary\', \'indices_or_sections\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "sqrt" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "square" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "squeeze" +- argspec: "args=[\'a\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "stack" +- argspec: "args=[\'arrays\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "std" +- argspec: "args=[\'a\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "subtract" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "sum" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " +- } +- member_method { +- name: "swapaxes" +- argspec: "args=[\'a\', \'axis1\', \'axis2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "take" +- argspec: "args=[\'a\', \'indices\', \'axis\', \'out\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'clip\'], " +- } +- member_method { +- name: "take_along_axis" +- argspec: "args=[\'arr\', \'indices\', \'axis\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "tan" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "tanh" +- argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "tensordot" +- argspec: "args=[\'a\', \'b\', \'axes\'], varargs=None, keywords=None, defaults=[\'2\'], " +- } +- member_method { +- name: "tile" +- argspec: "args=[\'a\', \'reps\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "trace" +- argspec: "args=[\'a\', \'offset\', \'axis1\', \'axis2\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'0\', \'1\', \'None\'], " +- } +- member_method { +- name: "transpose" +- argspec: "args=[\'a\', \'axes\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "tri" +- argspec: "args=[\'N\', \'M\', \'k\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " +- } +- member_method { +- name: "tril" +- argspec: "args=[\'m\', \'k\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "triu" +- argspec: "args=[\'m\', \'k\'], varargs=None, keywords=None, defaults=[\'0\'], " +- } +- member_method { +- name: "true_divide" +- argspec: "args=[\'x1\', \'x2\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "vander" +- argspec: "args=[\'x\', \'N\', \'increasing\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " +- } +- member_method { +- name: "var" +- argspec: "args=[\'a\', \'axis\', \'dtype\', \'out\', \'ddof\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'0\', \'None\'], " +- } +- member_method { +- name: "vdot" +- argspec: "args=[\'a\', \'b\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "vsplit" +- argspec: "args=[\'ary\', \'indices_or_sections\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "vstack" +- argspec: "args=[\'tup\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "where" +- argspec: "args=[\'condition\', \'x\', \'y\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " +- } +- member_method { +- name: "zeros" +- argspec: "args=[\'shape\', \'dtype\'], varargs=None, keywords=None, defaults=[\"<class \'float\'>\"], " +- } +- member_method { +- name: "zeros_like" +- argspec: "args=[\'a\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +-} +diff --git a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.random.pbtxt b/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.random.pbtxt +deleted file mode 100644 +index 61a4766f3f8..00000000000 +--- a/third_party/py/non_hermetic/numpy/tf_numpy_api/tensorflow.experimental.numpy.random.pbtxt ++++ /dev/null +@@ -1,35 +0,0 @@ +-path: "tensorflow.experimental.numpy.random" +-tf_module { +- member_method { +- name: "poisson" +- argspec: "args=[\'lam\', \'size\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\'], " +- } +- member_method { +- name: "rand" +- argspec: "args=[], varargs=size, keywords=None, defaults=None" +- } +- member_method { +- name: "randint" +- argspec: "args=[\'low\', \'high\', \'size\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"<class \'numpy.int64\'>\"], " +- } +- member_method { +- name: "randn" +- argspec: "args=[], varargs=args, keywords=None, defaults=None" +- } +- member_method { +- name: "random" +- argspec: "args=[\'size\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "seed" +- argspec: "args=[\'s\'], varargs=None, keywords=None, defaults=None" +- } +- member_method { +- name: "standard_normal" +- argspec: "args=[\'size\'], varargs=None, keywords=None, defaults=[\'None\'], " +- } +- member_method { +- name: "uniform" +- argspec: "args=[\'low\', \'high\', \'size\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\'], " +- } +-} +diff --git a/third_party/py/non_hermetic/python_configure.bzl b/third_party/py/non_hermetic/python_configure.bzl +deleted file mode 100644 +index 300cbfb6c71..00000000000 +--- a/third_party/py/non_hermetic/python_configure.bzl ++++ /dev/null +@@ -1,315 +0,0 @@ +-"""Repository rule for Python autoconfiguration. +- +-`python_configure` depends on the following environment variables: +- +- * `PYTHON_BIN_PATH`: location of python binary. +- * `PYTHON_LIB_PATH`: Location of python libraries. +-""" +- +-load( +- "//third_party/remote_config:common.bzl", +- "BAZEL_SH", +- "PYTHON_BIN_PATH", +- "PYTHON_LIB_PATH", +- "TF_PYTHON_CONFIG_REPO", +- "auto_config_fail", +- "config_repo_label", +- "execute", +- "get_bash_bin", +- "get_host_environ", +- "get_python_bin", +- "is_windows", +- "raw_exec", +- "read_dir", +-) +- +-def _genrule(src_dir, genrule_name, command, outs): +- """Returns a string with a genrule. +- +- Genrule executes the given command and produces the given outputs. +- """ +- return ( +- "genrule(\n" + +- ' name = "' + +- genrule_name + '",\n' + +- " outs = [\n" + +- outs + +- "\n ],\n" + +- ' cmd = """\n' + +- command + +- '\n """,\n' + +- ")\n" +- ) +- +-def _norm_path(path): +- """Returns a path with '/' and remove the trailing slash.""" +- path = path.replace("\\", "/") +- if path[-1] == "/": +- path = path[:-1] +- return path +- +-def _symlink_genrule_for_dir( +- repository_ctx, +- src_dir, +- dest_dir, +- genrule_name, +- src_files = [], +- dest_files = []): +- """Returns a genrule to symlink(or copy if on Windows) a set of files. +- +- If src_dir is passed, files will be read from the given directory; otherwise +- we assume files are in src_files and dest_files +- """ +- if src_dir != None: +- src_dir = _norm_path(src_dir) +- dest_dir = _norm_path(dest_dir) +- files = "\n".join(read_dir(repository_ctx, src_dir)) +- +- # Create a list with the src_dir stripped to use for outputs. +- dest_files = files.replace(src_dir, "").splitlines() +- src_files = files.splitlines() +- command = [] +- outs = [] +- for i in range(len(dest_files)): +- if dest_files[i] != "": +- # If we have only one file to link we do not want to use the dest_dir, as +- # $(@D) will include the full path to the file. +- dest = "$(@D)/" + dest_dir + dest_files[i] if len(dest_files) != 1 else "$(@D)/" + dest_files[i] +- +- # Copy the headers to create a sandboxable setup. +- cmd = "cp -f" +- command.append(cmd + ' "%s" "%s"' % (src_files[i], dest)) +- outs.append(' "' + dest_dir + dest_files[i] + '",') +- genrule = _genrule( +- src_dir, +- genrule_name, +- " && ".join(command), +- "\n".join(outs), +- ) +- return genrule +- +-def _get_python_lib(repository_ctx, python_bin): +- """Gets the python lib path.""" +- python_lib = get_host_environ(repository_ctx, PYTHON_LIB_PATH) +- if python_lib != None: +- return python_lib +- +- # The interesting program to execute. +- print_lib = [ +- "from __future__ import print_function", +- "import site", +- "import os", +- "python_paths = []", +- "if os.getenv('PYTHONPATH') is not None:", +- " python_paths = os.getenv('PYTHONPATH').split(':')", +- "try:", +- " library_paths = site.getsitepackages()", +- "except AttributeError:", +- " from distutils.sysconfig import get_python_lib", +- " library_paths = [get_python_lib()]", +- "all_paths = set(python_paths + library_paths)", +- "paths = []", +- "for path in all_paths:", +- " if os.path.isdir(path):", +- " paths.append(path)", +- "if len(paths) >=1:", +- " print(paths[0])", +- ] +- +- # The below script writes the above program to a file +- # and executes it. This is to work around the limitation +- # of not being able to upload files as part of execute. +- cmd = "from os import linesep;" +- cmd += "f = open('script.py', 'w');" +- for line in print_lib: +- cmd += "f.write(\"%s\" + linesep);" % line +- cmd += "f.close();" +- cmd += "from subprocess import call;" +- cmd += "call([\"%s\", \"script.py\"]);" % python_bin +- +- result = execute(repository_ctx, [python_bin, "-c", cmd]) +- return result.stdout.strip() +- +-def _check_python_lib(repository_ctx, python_lib): +- """Checks the python lib path.""" +- cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib) +- result = raw_exec(repository_ctx, [get_bash_bin(repository_ctx), "-c", cmd]) +- if result.return_code == 1: +- auto_config_fail("Invalid python library path: %s" % python_lib) +- +-def _check_python_bin(repository_ctx, python_bin): +- """Checks the python bin path.""" +- cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) +- result = raw_exec(repository_ctx, [get_bash_bin(repository_ctx), "-c", cmd]) +- if result.return_code == 1: +- auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % ( +- PYTHON_BIN_PATH, +- python_bin, +- )) +- +-def _get_python_include(repository_ctx, python_bin): +- """Gets the python include path.""" +- result = execute( +- repository_ctx, +- [ +- python_bin, +- "-Wignore", +- "-c", +- "import importlib; " + +- "import importlib.util; " + +- "print(importlib.import_module('distutils.sysconfig').get_python_inc() " + +- "if importlib.util.find_spec('distutils.sysconfig') " + +- "else importlib.import_module('sysconfig').get_path('include'))", +- ], +- error_msg = "Problem getting python include path.", +- error_details = ("Is the Python binary path set up right? " + +- "(See ./configure or " + PYTHON_BIN_PATH + ".) " + +- "Is distutils installed?"), +- ) +- return result.stdout.splitlines()[0] +- +-def _get_python_import_lib_name(repository_ctx, python_bin): +- """Get Python import library name (pythonXY.lib) on Windows.""" +- result = execute( +- repository_ctx, +- [ +- python_bin, +- "-c", +- "import sys;" + +- 'print("python" + str(sys.version_info[0]) + ' + +- ' str(sys.version_info[1]) + ".lib")', +- ], +- error_msg = "Problem getting python import library.", +- error_details = ("Is the Python binary path set up right? " + +- "(See ./configure or " + PYTHON_BIN_PATH + ".) "), +- ) +- return result.stdout.splitlines()[0] +- +-def _get_numpy_include(repository_ctx, python_bin): +- """Gets the numpy include path.""" +- return execute( +- repository_ctx, +- [ +- python_bin, +- "-c", +- "from __future__ import print_function;" + +- "import numpy;" + +- " print(numpy.get_include());", +- ], +- error_msg = "Problem getting numpy include path.", +- error_details = "Is numpy installed?", +- ).stdout.splitlines()[0] +- +-def _create_local_python_repository(repository_ctx): +- """Creates the repository containing files set up to build with Python.""" +- +- # Resolve all labels before doing any real work. Resolving causes the +- # function to be restarted with all previous state being lost. This +- # can easily lead to a O(n^2) runtime in the number of labels. +- build_tpl = repository_ctx.path(Label("//third_party/py:BUILD.tpl")) +- +- python_bin = get_python_bin(repository_ctx) +- _check_python_bin(repository_ctx, python_bin) +- python_lib = _get_python_lib(repository_ctx, python_bin) +- _check_python_lib(repository_ctx, python_lib) +- python_include = _get_python_include(repository_ctx, python_bin) +- numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy" +- python_include_rule = _symlink_genrule_for_dir( +- repository_ctx, +- python_include, +- "python_include", +- "python_include", +- ) +- python_import_lib_genrule = "" +- +- # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib +- # See https://docs.python.org/3/extending/windows.html +- if is_windows(repository_ctx): +- python_bin = python_bin.replace("\\", "/") +- python_include = _norm_path(python_include) +- python_import_lib_name = _get_python_import_lib_name(repository_ctx, python_bin) +- python_import_lib_src = python_include.rsplit("/", 1)[0] + "/libs/" + python_import_lib_name +- python_import_lib_genrule = _symlink_genrule_for_dir( +- repository_ctx, +- None, +- "", +- "python_import_lib", +- [python_import_lib_src], +- [python_import_lib_name], +- ) +- numpy_include_rule = _symlink_genrule_for_dir( +- repository_ctx, +- numpy_include, +- "numpy_include/numpy", +- "numpy_include", +- ) +- +- platform_constraint = "" +- if repository_ctx.attr.platform_constraint: +- platform_constraint = "\"%s\"" % repository_ctx.attr.platform_constraint +- repository_ctx.template("BUILD", build_tpl, { +- "%{PYTHON_BIN_PATH}": python_bin, +- "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, +- "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, +- "%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, +- "%{PLATFORM_CONSTRAINT}": platform_constraint, +- }) +- +-def _create_remote_python_repository(repository_ctx, remote_config_repo): +- """Creates pointers to a remotely configured repo set up to build with Python. +- """ +- repository_ctx.template("BUILD", config_repo_label(remote_config_repo, ":BUILD"), {}) +- +-def _python_autoconf_impl(repository_ctx): +- """Implementation of the python_autoconf repository rule.""" +- if get_host_environ(repository_ctx, TF_PYTHON_CONFIG_REPO) != None: +- _create_remote_python_repository( +- repository_ctx, +- get_host_environ(repository_ctx, TF_PYTHON_CONFIG_REPO), +- ) +- else: +- _create_local_python_repository(repository_ctx) +- +-_ENVIRONS = [ +- BAZEL_SH, +- PYTHON_BIN_PATH, +- PYTHON_LIB_PATH, +-] +- +-local_python_configure = repository_rule( +- implementation = _create_local_python_repository, +- environ = _ENVIRONS, +- attrs = { +- "environ": attr.string_dict(), +- "platform_constraint": attr.string(), +- }, +-) +- +-remote_python_configure = repository_rule( +- implementation = _create_local_python_repository, +- environ = _ENVIRONS, +- remotable = True, +- attrs = { +- "environ": attr.string_dict(), +- "platform_constraint": attr.string(), +- }, +-) +- +-python_configure = repository_rule( +- implementation = _python_autoconf_impl, +- environ = _ENVIRONS + [TF_PYTHON_CONFIG_REPO], +- attrs = { +- "platform_constraint": attr.string(), +- }, +-) +-"""Detects and configures the local Python. +- +-Add the following to your WORKSPACE FILE: +- +-```python +-python_configure(name = "local_config_python") +-``` +- +-Args: +- name: A unique name for this workspace rule. +-""" +diff --git a/third_party/py/numpy/BUILD b/third_party/py/numpy/BUILD +index 97c7907fc38..c80cc5287bc 100644 +--- a/third_party/py/numpy/BUILD ++++ b/third_party/py/numpy/BUILD +@@ -2,14 +2,15 @@ licenses(["restricted"]) + + package(default_visibility = ["//visibility:public"]) + +-alias( ++py_library( + name = "numpy", +- actual = "@pypi_numpy//:pkg", ++ srcs = ["tf_numpy_dummy.py"], ++ srcs_version = "PY3", + ) + + alias( + name = "headers", +- actual = "@pypi_numpy//:numpy_headers", ++ actual = "@local_config_python//:numpy_headers", + ) + + genrule( +diff --git a/third_party/py/numpy/LICENSE b/third_party/py/numpy/LICENSE +deleted file mode 100644 +index b9731f734f5..00000000000 +--- a/third_party/py/numpy/LICENSE ++++ /dev/null +@@ -1,60 +0,0 @@ +-Copyright (c) 2005-2019, NumPy Developers. +-All rights reserved. +- +-Redistribution and use in source and binary forms, with or without +-modification, are permitted provided that the following conditions are +-met: +- +- * Redistributions of source code must retain the above copyright +- notice, this list of conditions and the following disclaimer. +- +- * Redistributions in binary form must reproduce the above +- copyright notice, this list of conditions and the following +- disclaimer in the documentation and/or other materials provided +- with the distribution. +- +- * Neither the name of the NumPy Developers nor the names of any +- contributors may be used to endorse or promote products derived +- from this software without specific prior written permission. +- +-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +- +- +-The NumPy repository and source distributions bundle several libraries that are +-compatibly licensed. We list these here. +- +-Name: Numpydoc +-Files: doc/sphinxext/numpydoc/* +-License: 2-clause BSD +- For details, see doc/sphinxext/LICENSE.txt +- +-Name: scipy-sphinx-theme +-Files: doc/scipy-sphinx-theme/* +-License: 3-clause BSD, PSF and Apache 2.0 +- For details, see doc/scipy-sphinx-theme/LICENSE.txt +- +-Name: lapack-lite +-Files: numpy/linalg/lapack_lite/* +-License: 3-clause BSD +- For details, see numpy/linalg/lapack_lite/LICENSE.txt +- +-Name: tempita +-Files: tools/npy_tempita/* +-License: BSD derived +- For details, see tools/npy_tempita/license.txt +- +-Name: dragon4 +-Files: numpy/core/src/multiarray/dragon4.c +-License: One of a kind +- For license text, see numpy/core/src/multiarray/dragon4.c +diff --git a/third_party/py/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt b/third_party/py/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt +index 05939b53b5f..2f5490ad0c9 100644 +--- a/third_party/py/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt ++++ b/third_party/py/numpy/tf_numpy_api/tensorflow.experimental.numpy.pbtxt +@@ -390,7 +390,7 @@ tf_module { + } + member_method { + name: "experimental_enable_numpy_behavior" +- argspec: "args=[\'prefer_float32\', \'dtype_conversion_mode\'], varargs=None, keywords=None, defaults=[\'False\', \'legacy\'], " ++ argspec: "args=[\'prefer_float32\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "expm1" +diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl +index 3728a91b931..300cbfb6c71 100644 +--- a/third_party/py/python_configure.bzl ++++ b/third_party/py/python_configure.bzl +@@ -1,4 +1,9 @@ + """Repository rule for Python autoconfiguration. ++ ++`python_configure` depends on the following environment variables: ++ ++ * `PYTHON_BIN_PATH`: location of python binary. ++ * `PYTHON_LIB_PATH`: Location of python libraries. + """ + + load( +@@ -6,8 +11,195 @@ load( + "BAZEL_SH", + "PYTHON_BIN_PATH", + "PYTHON_LIB_PATH", ++ "TF_PYTHON_CONFIG_REPO", ++ "auto_config_fail", ++ "config_repo_label", ++ "execute", ++ "get_bash_bin", ++ "get_host_environ", ++ "get_python_bin", ++ "is_windows", ++ "raw_exec", ++ "read_dir", + ) + ++def _genrule(src_dir, genrule_name, command, outs): ++ """Returns a string with a genrule. ++ ++ Genrule executes the given command and produces the given outputs. ++ """ ++ return ( ++ "genrule(\n" + ++ ' name = "' + ++ genrule_name + '",\n' + ++ " outs = [\n" + ++ outs + ++ "\n ],\n" + ++ ' cmd = """\n' + ++ command + ++ '\n """,\n' + ++ ")\n" ++ ) ++ ++def _norm_path(path): ++ """Returns a path with '/' and remove the trailing slash.""" ++ path = path.replace("\\", "/") ++ if path[-1] == "/": ++ path = path[:-1] ++ return path ++ ++def _symlink_genrule_for_dir( ++ repository_ctx, ++ src_dir, ++ dest_dir, ++ genrule_name, ++ src_files = [], ++ dest_files = []): ++ """Returns a genrule to symlink(or copy if on Windows) a set of files. ++ ++ If src_dir is passed, files will be read from the given directory; otherwise ++ we assume files are in src_files and dest_files ++ """ ++ if src_dir != None: ++ src_dir = _norm_path(src_dir) ++ dest_dir = _norm_path(dest_dir) ++ files = "\n".join(read_dir(repository_ctx, src_dir)) ++ ++ # Create a list with the src_dir stripped to use for outputs. ++ dest_files = files.replace(src_dir, "").splitlines() ++ src_files = files.splitlines() ++ command = [] ++ outs = [] ++ for i in range(len(dest_files)): ++ if dest_files[i] != "": ++ # If we have only one file to link we do not want to use the dest_dir, as ++ # $(@D) will include the full path to the file. ++ dest = "$(@D)/" + dest_dir + dest_files[i] if len(dest_files) != 1 else "$(@D)/" + dest_files[i] ++ ++ # Copy the headers to create a sandboxable setup. ++ cmd = "cp -f" ++ command.append(cmd + ' "%s" "%s"' % (src_files[i], dest)) ++ outs.append(' "' + dest_dir + dest_files[i] + '",') ++ genrule = _genrule( ++ src_dir, ++ genrule_name, ++ " && ".join(command), ++ "\n".join(outs), ++ ) ++ return genrule ++ ++def _get_python_lib(repository_ctx, python_bin): ++ """Gets the python lib path.""" ++ python_lib = get_host_environ(repository_ctx, PYTHON_LIB_PATH) ++ if python_lib != None: ++ return python_lib ++ ++ # The interesting program to execute. ++ print_lib = [ ++ "from __future__ import print_function", ++ "import site", ++ "import os", ++ "python_paths = []", ++ "if os.getenv('PYTHONPATH') is not None:", ++ " python_paths = os.getenv('PYTHONPATH').split(':')", ++ "try:", ++ " library_paths = site.getsitepackages()", ++ "except AttributeError:", ++ " from distutils.sysconfig import get_python_lib", ++ " library_paths = [get_python_lib()]", ++ "all_paths = set(python_paths + library_paths)", ++ "paths = []", ++ "for path in all_paths:", ++ " if os.path.isdir(path):", ++ " paths.append(path)", ++ "if len(paths) >=1:", ++ " print(paths[0])", ++ ] ++ ++ # The below script writes the above program to a file ++ # and executes it. This is to work around the limitation ++ # of not being able to upload files as part of execute. ++ cmd = "from os import linesep;" ++ cmd += "f = open('script.py', 'w');" ++ for line in print_lib: ++ cmd += "f.write(\"%s\" + linesep);" % line ++ cmd += "f.close();" ++ cmd += "from subprocess import call;" ++ cmd += "call([\"%s\", \"script.py\"]);" % python_bin ++ ++ result = execute(repository_ctx, [python_bin, "-c", cmd]) ++ return result.stdout.strip() ++ ++def _check_python_lib(repository_ctx, python_lib): ++ """Checks the python lib path.""" ++ cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib) ++ result = raw_exec(repository_ctx, [get_bash_bin(repository_ctx), "-c", cmd]) ++ if result.return_code == 1: ++ auto_config_fail("Invalid python library path: %s" % python_lib) ++ ++def _check_python_bin(repository_ctx, python_bin): ++ """Checks the python bin path.""" ++ cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) ++ result = raw_exec(repository_ctx, [get_bash_bin(repository_ctx), "-c", cmd]) ++ if result.return_code == 1: ++ auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % ( ++ PYTHON_BIN_PATH, ++ python_bin, ++ )) ++ ++def _get_python_include(repository_ctx, python_bin): ++ """Gets the python include path.""" ++ result = execute( ++ repository_ctx, ++ [ ++ python_bin, ++ "-Wignore", ++ "-c", ++ "import importlib; " + ++ "import importlib.util; " + ++ "print(importlib.import_module('distutils.sysconfig').get_python_inc() " + ++ "if importlib.util.find_spec('distutils.sysconfig') " + ++ "else importlib.import_module('sysconfig').get_path('include'))", ++ ], ++ error_msg = "Problem getting python include path.", ++ error_details = ("Is the Python binary path set up right? " + ++ "(See ./configure or " + PYTHON_BIN_PATH + ".) " + ++ "Is distutils installed?"), ++ ) ++ return result.stdout.splitlines()[0] ++ ++def _get_python_import_lib_name(repository_ctx, python_bin): ++ """Get Python import library name (pythonXY.lib) on Windows.""" ++ result = execute( ++ repository_ctx, ++ [ ++ python_bin, ++ "-c", ++ "import sys;" + ++ 'print("python" + str(sys.version_info[0]) + ' + ++ ' str(sys.version_info[1]) + ".lib")', ++ ], ++ error_msg = "Problem getting python import library.", ++ error_details = ("Is the Python binary path set up right? " + ++ "(See ./configure or " + PYTHON_BIN_PATH + ".) "), ++ ) ++ return result.stdout.splitlines()[0] ++ ++def _get_numpy_include(repository_ctx, python_bin): ++ """Gets the numpy include path.""" ++ return execute( ++ repository_ctx, ++ [ ++ python_bin, ++ "-c", ++ "from __future__ import print_function;" + ++ "import numpy;" + ++ " print(numpy.get_include());", ++ ], ++ error_msg = "Problem getting numpy include path.", ++ error_details = "Is numpy installed?", ++ ).stdout.splitlines()[0] ++ + def _create_local_python_repository(repository_ctx): + """Creates the repository containing files set up to build with Python.""" + +@@ -15,14 +207,68 @@ def _create_local_python_repository(repository_ctx): + # function to be restarted with all previous state being lost. This + # can easily lead to a O(n^2) runtime in the number of labels. + build_tpl = repository_ctx.path(Label("//third_party/py:BUILD.tpl")) ++ ++ python_bin = get_python_bin(repository_ctx) ++ _check_python_bin(repository_ctx, python_bin) ++ python_lib = _get_python_lib(repository_ctx, python_bin) ++ _check_python_lib(repository_ctx, python_lib) ++ python_include = _get_python_include(repository_ctx, python_bin) ++ numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy" ++ python_include_rule = _symlink_genrule_for_dir( ++ repository_ctx, ++ python_include, ++ "python_include", ++ "python_include", ++ ) ++ python_import_lib_genrule = "" ++ ++ # To build Python C/C++ extension on Windows, we need to link to python import library pythonXY.lib ++ # See https://docs.python.org/3/extending/windows.html ++ if is_windows(repository_ctx): ++ python_bin = python_bin.replace("\\", "/") ++ python_include = _norm_path(python_include) ++ python_import_lib_name = _get_python_import_lib_name(repository_ctx, python_bin) ++ python_import_lib_src = python_include.rsplit("/", 1)[0] + "/libs/" + python_import_lib_name ++ python_import_lib_genrule = _symlink_genrule_for_dir( ++ repository_ctx, ++ None, ++ "", ++ "python_import_lib", ++ [python_import_lib_src], ++ [python_import_lib_name], ++ ) ++ numpy_include_rule = _symlink_genrule_for_dir( ++ repository_ctx, ++ numpy_include, ++ "numpy_include/numpy", ++ "numpy_include", ++ ) ++ + platform_constraint = "" + if repository_ctx.attr.platform_constraint: + platform_constraint = "\"%s\"" % repository_ctx.attr.platform_constraint +- repository_ctx.template("BUILD", build_tpl, {"%{PLATFORM_CONSTRAINT}": platform_constraint}) ++ repository_ctx.template("BUILD", build_tpl, { ++ "%{PYTHON_BIN_PATH}": python_bin, ++ "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, ++ "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, ++ "%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, ++ "%{PLATFORM_CONSTRAINT}": platform_constraint, ++ }) ++ ++def _create_remote_python_repository(repository_ctx, remote_config_repo): ++ """Creates pointers to a remotely configured repo set up to build with Python. ++ """ ++ repository_ctx.template("BUILD", config_repo_label(remote_config_repo, ":BUILD"), {}) + + def _python_autoconf_impl(repository_ctx): + """Implementation of the python_autoconf repository rule.""" +- _create_local_python_repository(repository_ctx) ++ if get_host_environ(repository_ctx, TF_PYTHON_CONFIG_REPO) != None: ++ _create_remote_python_repository( ++ repository_ctx, ++ get_host_environ(repository_ctx, TF_PYTHON_CONFIG_REPO), ++ ) ++ else: ++ _create_local_python_repository(repository_ctx) + + _ENVIRONS = [ + BAZEL_SH, +@@ -32,6 +278,7 @@ _ENVIRONS = [ + + local_python_configure = repository_rule( + implementation = _create_local_python_repository, ++ environ = _ENVIRONS, + attrs = { + "environ": attr.string_dict(), + "platform_constraint": attr.string(), +@@ -50,6 +297,7 @@ remote_python_configure = repository_rule( + + python_configure = repository_rule( + implementation = _python_autoconf_impl, ++ environ = _ENVIRONS + [TF_PYTHON_CONFIG_REPO], + attrs = { + "platform_constraint": attr.string(), + }, +-- +2.41.0 + |