From c725901d1b79f3c56a880b88d29f3eaecf126374 Mon Sep 17 00:00:00 2001 From: Dan Moldovan Date: Thu, 20 Aug 2020 09:08:05 -0700 Subject: [PATCH] Add typing_extensions dependency. This is a very light dependency (roughly two Python files) that is useful to unlock typing features present only in the latest Python versions. PiperOrigin-RevId: 327637134 Change-Id: Ifb4cd1314a6f8feee4f452a8256cff27c1acd590 --- tensorflow/opensource_only.files | 1 + tensorflow/tools/ci_build/release/common.sh | 2 ++ tensorflow/tools/pip_package/setup.py | 1 + tensorflow/workspace.bzl | 12 ++++++++++++ third_party/typing_extensions.BUILD | 14 ++++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 third_party/typing_extensions.BUILD diff --git a/tensorflow/opensource_only.files b/tensorflow/opensource_only.files index b61cebd65e4d6c..f51780564280f6 100644 --- a/tensorflow/opensource_only.files +++ b/tensorflow/opensource_only.files @@ -265,6 +265,7 @@ tensorflow/third_party/toolchains/remote_config/BUILD tensorflow/third_party/toolchains/remote_config/configs.bzl tensorflow/third_party/toolchains/remote_config/containers.bzl tensorflow/third_party/toolchains/remote_config/rbe_config.bzl +tensorflow/third_party/typing_extensions.BUILD tensorflow/third_party/wrapt.BUILD tensorflow/third_party/zlib.BUILD tensorflow/tools/build_info/BUILD diff --git a/tensorflow/tools/ci_build/release/common.sh b/tensorflow/tools/ci_build/release/common.sh index c3b5bd9a867a20..a22556a7d864c7 100644 --- a/tensorflow/tools/ci_build/release/common.sh +++ b/tensorflow/tools/ci_build/release/common.sh @@ -142,6 +142,7 @@ function install_pip_deps { ${SUDO_CMD} ${PIP_CMD} install portpicker ${SUDO_CMD} ${PIP_CMD} install scipy ${SUDO_CMD} ${PIP_CMD} install scikit-learn + ${SUDO_CMD} ${PIP_CMD} install typing_extensions ${SUDO_CMD} ${PIP_CMD} install --upgrade tb-nightly ${PIP_CMD} install --user --upgrade flatbuffers ${PIP_CMD} install --user --upgrade attrs @@ -178,6 +179,7 @@ function install_ubuntu_16_pip_deps { "${PIP_CMD}" install portpicker --user "${PIP_CMD}" install scipy --user "${PIP_CMD}" install scikit-learn --user + "${PIP_CMD}" install typing_extensions --user "${PIP_CMD}" install PyYAML==3.13 --user # b/156523241 "${PIP_CMD}" install --force-reinstall --user --upgrade tf-estimator-nightly diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py index 54021af9975013..5917b0fca7f8ad 100644 --- a/tensorflow/tools/pip_package/setup.py +++ b/tensorflow/tools/pip_package/setup.py @@ -67,6 +67,7 @@ 'tensorboard >= 2.3.0, < 3', 'tensorflow_estimator >= 2.3.0, < 2.4.0', 'termcolor >= 1.1.0', + 'typing_extensions >= 3.7.4.2', 'wrapt >= 1.11.1', 'wheel >= 0.26', 'six >= 1.12.0', diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index aabecba43f83c6..de2ed9993670dc 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -514,6 +514,18 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): ], ) + tf_http_archive( + name = "typing_extensions_archive", + build_file = clean_dep("//third_party:typing_extensions.BUILD"), + sha256 = "79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae", + strip_prefix = "typing_extensions-3.7.4.2", + system_build_file = clean_dep("//third_party/systemlibs:six.BUILD"), + urls = [ + "http://mirror.tensorflow.org/files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz", + "https://files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz", + ], + ) + tf_http_archive( name = "opt_einsum_archive", build_file = clean_dep("//third_party:opt_einsum.BUILD"), diff --git a/third_party/typing_extensions.BUILD b/third_party/typing_extensions.BUILD new file mode 100644 index 00000000000000..efd526cd49116b --- /dev/null +++ b/third_party/typing_extensions.BUILD @@ -0,0 +1,14 @@ +# Description: +# Backports for the typing module to older Python versions. See +# https://github.com/python/typing/blob/master/typing_extensions/README.rst + +licenses(["notice"]) # PSF + +exports_files(["LICENSE"]) + +py_library( + name = "typing_extensions", + srcs = ["src_py3/typing_extensions.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +)