Change setup.py to use the new pip resolver.

Also cleans up `setup.py`, upgrading dependencies, adding comments.

Fixes #41902 by changing constraint on `numpy` dependency to require `numpy` above the C++ API breaking change (https://github.com/numpy/numpy/pull/15355, 79518facb4)

Fixes duplicate #43679 (duplicate of #41902)

Tested:
```console
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ bazel build //tensorflow/tools/pip_package:build_pip_package
...
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
...
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ pip install --upgrade pip
...
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ pip install --upgrade pip
Collecting pip
  Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-20.2.3
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ pip --version
pip 20.2.3 from /tmp/tf/venv/lib/python3.8/site-packages/pip (python 3.8)
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ pip list
Package             Version
------------------- -------
Keras-Preprocessing 1.1.2
numpy               1.19.2
pip                 20.2.3
pkg-resources       0.0.0
setuptools          44.0.0
six                 1.15.0
wheel               0.35.1
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ python -m pip install --upgrade --use-feature=2020-resolver /tmp/tensorflow_pkg/tensorflow-2.4.0-cp38-cp38-linux_x86_64.whl
...
Successfully installed absl-py-0.10.0 astunparse-1.6.3 cachetools-4.1.1 certifi-2020.6.20 chardet-3.0.4 flatbuffers-1.12 gast-0.4.0 google-auth-1.22.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.32.0 h5py-2.10.0 idna-2.10 markdown-3.3.1 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.13.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.24.0 requests-oauthlib-1.3.0 rsa-4.6 tensorboard-2.3.0 tensorboard-plugin-wit-1.7.0 tensorflow-2.4.0 tensorflow-estimator-2.3.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.25.10 werkzeug-1.0.1 wrapt-1.12.1
(venv) mihaimaruseac@ankh:/tmp/tf/cp/tf$ pip list
Package                Version
---------------------- ---------
absl-py                0.10.0
astunparse             1.6.3
cachetools             4.1.1
certifi                2020.6.20
chardet                3.0.4
flatbuffers            1.12
gast                   0.4.0
google-auth            1.22.1
google-auth-oauthlib   0.4.1
google-pasta           0.2.0
grpcio                 1.32.0
h5py                   2.10.0
idna                   2.10
Keras-Preprocessing    1.1.2
Markdown               3.3.1
numpy                  1.19.2
oauthlib               3.1.0
opt-einsum             3.3.0
pip                    20.2.3
pkg-resources          0.0.0
protobuf               3.13.0
pyasn1                 0.4.8
pyasn1-modules         0.2.8
requests               2.24.0
requests-oauthlib      1.3.0
rsa                    4.6
setuptools             44.0.0
six                    1.15.0
tensorboard            2.3.0
tensorboard-plugin-wit 1.7.0
tensorflow             2.4.0
tensorflow-estimator   2.3.0
termcolor              1.1.0
typing-extensions      3.7.4.3
urllib3                1.25.10
Werkzeug               1.0.1
wheel                  0.35.1
wrapt                  1.12.1
```
PiperOrigin-RevId: 337563781
Change-Id: I2aa111b21a43e333d6891c0392051d765aade964
This commit is contained in:
Mihai Maruseac 2020-10-16 13:08:04 -07:00 committed by TensorFlower Gardener
parent a45e38dcb1
commit aafe25d3f9

View File

@ -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',