diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py index e4a69d22a6f..0dc0391d5a1 100644 --- a/tensorflow/tools/pip_package/setup.py +++ b/tensorflow/tools/pip_package/setup.py @@ -44,6 +44,7 @@ from setuptools import setup from setuptools.command.install import install as InstallCommandBase from setuptools.dist import Distribution + # This version string is semver compatible, but incompatible with pip. # For pip, we will remove all '-' characters from this string, and use the # result for pip. @@ -51,35 +52,10 @@ from setuptools.dist import Distribution # tensorflow/core/public/version.h _VERSION = '2.4.0' -REQUIRED_PACKAGES = [ - 'absl-py >= 0.9.0', - 'astunparse == 1.6.3', - 'flatbuffers >= 1.12', - 'gast == 0.3.3', - 'google_pasta >= 0.1.8', - 'h5py >= 2.10.0, < 2.11.0', - 'keras_preprocessing >= 1.1.1, < 1.2', - # TODO(mihaimaruseac): numpy 1.19.0 has ABI breakage - # https://github.com/numpy/numpy/pull/15355 - 'numpy >= 1.16.0, < 1.19.0', - 'opt_einsum >= 2.3.2', - 'portpicker >= 1.3.0', # Needed by tf.__internal__.distribute.combinations. - 'protobuf >= 3.9.2', - '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', -] - -if sys.byteorder == 'little': - # grpcio does not build correctly on big-endian machines due to lack of - # BoringSSL support. - # See https://github.com/tensorflow/tensorflow/issues/17882. - REQUIRED_PACKAGES.append('grpcio >= 1.8.6') +# We use the same setup.py for all tensorflow_* packages and for the nightly +# equivalents (tf_nightly_*). The package is controlled from the argument line +# when building the pip package. project_name = 'tensorflow' if '--project_name' in sys.argv: project_name_idx = sys.argv.index('--project_name') @@ -87,13 +63,69 @@ if '--project_name' in sys.argv: sys.argv.remove('--project_name') sys.argv.pop(project_name_idx) -# tf-nightly should depend on tb-nightly + +# All versions of TF need these packages. We use the `~=` syntax to pin packages +# to the latest major.minor release accepting all other patches on top of that. +# If we already know of a patched version, we pin to that. +# For packages that don't have yet a stable release, we pin using `~= 0.x` which +# means we accept any `0.y` version (y >= x) but not the first major release. We +# will need additional testing for that. +# NOTE: This assumes that all packages follow SemVer. If a packages follows a +# different versioning scheme (e.g., PVP), we use different bound specifier and +# comment the versioning scheme. +# NOTE: Please add test only packages to `TEST_PACKAGES` below. +REQUIRED_PACKAGES = [ + 'absl-py ~= 0.10', + 'astunparse ~= 1.6.3', + 'flatbuffers ~= 1.12.0', + 'gast ~= 0.4', + 'google_pasta ~= 0.2', + 'h5py ~= 2.10.0', + 'keras_preprocessing ~= 1.1.2', + 'numpy ~= 1.19.2', + 'opt_einsum ~= 3.3.0', + 'protobuf ~= 3.13.0', + 'six ~= 1.15.0', + 'termcolor ~= 1.1.0', + 'typing_extensions ~= 3.7.4', + 'wheel ~= 0.35', + 'wrapt ~= 1.12.1', + # TensorFlow ecosystem packages that TF exposes API for + # These need to be in sync with the existing TF version + # They are updated during the release process + # When updating these, please also update the nightly versions below + 'tensorboard ~= 2.3', + 'tensorflow_estimator ~= 2.3.0', +] + + +# For nightly packages, instead of dependening on tensorboard and +# tensorflow_estimator, we depend on their nightly equivalent. +# When updating these, make sure to also update the release versions above. +# NOTE: the nightly versions are one version ahead of the release ones! if 'tf_nightly' in project_name: for i, pkg in enumerate(REQUIRED_PACKAGES): if 'tensorboard' in pkg: - REQUIRED_PACKAGES[i] = 'tb-nightly >= 2.4.0a0, < 3.0.0a0' + REQUIRED_PACKAGES[i] = 'tb-nightly ~= 2.4' elif 'tensorflow_estimator' in pkg: - REQUIRED_PACKAGES[i] = 'tf-estimator-nightly' + REQUIRED_PACKAGES[i] = 'tf-estimator-nightly ~= 2.4.0' + + +# grpcio does not build correctly on big-endian machines due to lack of +# BoringSSL support. +# See https://github.com/tensorflow/tensorflow/issues/17882. +if sys.byteorder == 'little': + REQUIRED_PACKAGES.append('grpcio ~= 1.32.0') + + +# Packages which are only needed for testing code. +# Please don't add test-only packages to `REQUIRED_PACKAGES`! +# Follows the same conventions as `REQUIRED_PACKAGES` +TEST_PACKAGES = [ + 'portpicker ~= 1.3.1', + 'scipy ~= 1.5.2', +] + DOCLINES = __doc__.split('\n') if project_name.endswith('-gpu'): @@ -126,10 +158,6 @@ CONSOLE_SCRIPTS = [ if 'tf_nightly' in project_name: CONSOLE_SCRIPTS.remove('tensorboard = tensorboard.main:run_main') -TEST_PACKAGES = [ - 'scipy >= 0.15.1', -] - class BinaryDistribution(Distribution): @@ -297,7 +325,6 @@ setup( 'Intended Audience :: Science/Research', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8',