Skip to content

Commit 256ca91

Browse files
committed
Use select_constraint() in setup.py for branched dependency selection.
PiperOrigin-RevId: 330868123
1 parent d299093 commit 256ca91

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

setup.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""Package Setup script for TensorFlow Data Validation."""
15-
16-
# pylint:disable=g-bad-import-order
17-
# setuptools must be imported prior to distutils.
18-
import setuptools
19-
from distutils import spawn
20-
from distutils.command import build
21-
# pylint:enable=g-bad-import-order
2215
import os
2316
import platform
2417
import subprocess
2518
import sys
2619

20+
import setuptools
2721
from setuptools import find_packages
2822
from setuptools import setup
2923
from setuptools.command.install import install
3024
from setuptools.dist import Distribution
25+
# pylint:disable=g-bad-import-order
26+
# setuptools must be imported prior to distutils.
27+
from distutils import spawn
28+
from distutils.command import build
29+
# pylint:enable=g-bad-import-order
3130

3231

3332
class _BuildCommand(build.build):
@@ -123,6 +122,19 @@ def _make_all_extra_requirements():
123122
_make_visualization_requirements())
124123

125124

125+
def select_constraint(default, nightly=None, git_master=None):
126+
"""Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var."""
127+
selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')
128+
if selector == 'UNCONSTRAINED':
129+
return ''
130+
elif selector == 'NIGHTLY' and nightly is not None:
131+
return nightly
132+
elif selector == 'GIT_MASTER' and git_master is not None:
133+
return git_master
134+
else:
135+
return default
136+
137+
126138
# Get version from version module.
127139
with open('tensorflow_data_validation/version.py') as fp:
128140
globals_dict = {}
@@ -176,9 +188,18 @@ def _make_all_extra_requirements():
176188
'pyarrow>=0.17,<0.18',
177189
'six>=1.12,<2',
178190
'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,<3',
179-
'tensorflow-metadata>=0.23,<0.24',
180-
'tensorflow-transform>=0.23,<0.24',
181-
'tfx-bsl>=0.23,<0.24',
191+
'tensorflow-metadata' + select_constraint(
192+
default='>=0.23,<0.24',
193+
nightly='>=0.24.0.dev',
194+
git_master='@git+https://github.com/tensorflow/metadata@master'),
195+
'tensorflow-transform' + select_constraint(
196+
default='>=0.23,<0.24',
197+
nightly='>=0.24.0.dev',
198+
git_master='@git+https://github.com/tensorflow/transform@master'),
199+
'tfx-bsl' + select_constraint(
200+
default='>=0.23,<0.24',
201+
nightly='>=0.24.0.dev',
202+
git_master='@git+https://github.com/tensorflow/tfx-bsl@master'),
182203
],
183204
extras_require={
184205
'mutual-information': _make_mutual_information_requirements(),

0 commit comments

Comments
 (0)