|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | """Package Setup script for TensorFlow Data Validation.""" |
| 15 | + |
15 | 16 | import os |
16 | 17 | import platform |
17 | 18 | import shutil |
18 | 19 | import subprocess |
19 | 20 | import sys |
20 | 21 |
|
21 | | -import setuptools |
22 | | -from setuptools import find_packages |
23 | | -from setuptools import setup |
24 | | -from setuptools.command.install import install |
25 | | -from setuptools.dist import Distribution |
26 | 22 | # pylint:disable=g-bad-import-order |
27 | 23 | # setuptools must be imported prior to distutils. |
28 | 24 | from distutils.command import build |
| 25 | + |
| 26 | +import setuptools |
| 27 | +from setuptools import find_packages, setup |
| 28 | +from setuptools.command.install import install |
| 29 | +from setuptools.dist import Distribution |
| 30 | + |
29 | 31 | # pylint:enable=g-bad-import-order |
30 | 32 |
|
31 | 33 |
|
32 | 34 | class _BuildCommand(build.build): |
33 | | - """Build everything that is needed to install. |
| 35 | + """Build everything that is needed to install. |
34 | 36 |
|
35 | | - This overrides the original distutils "build" command to to run bazel_build |
36 | | - command before any sub_commands. |
| 37 | + This overrides the original distutils "build" command to to run bazel_build |
| 38 | + command before any sub_commands. |
37 | 39 |
|
38 | | - build command is also invoked from bdist_wheel and install command, therefore |
39 | | - this implementation covers the following commands: |
40 | | - - pip install . (which invokes bdist_wheel) |
41 | | - - python setup.py install (which invokes install command) |
42 | | - - python setup.py bdist_wheel (which invokes bdist_wheel command) |
43 | | - """ |
| 40 | + build command is also invoked from bdist_wheel and install command, therefore |
| 41 | + this implementation covers the following commands: |
| 42 | + - pip install . (which invokes bdist_wheel) |
| 43 | + - python setup.py install (which invokes install command) |
| 44 | + - python setup.py bdist_wheel (which invokes bdist_wheel command) |
| 45 | + """ |
44 | 46 |
|
45 | | - def _build_cc_extensions(self): |
46 | | - return True |
| 47 | + def _build_cc_extensions(self): |
| 48 | + return True |
47 | 49 |
|
48 | | - # Add "bazel_build" command as the first sub_command of "build". Each |
49 | | - # sub_command of "build" (e.g. "build_py", "build_ext", etc.) is executed |
50 | | - # sequentially when running a "build" command, if the second item in the tuple |
51 | | - # (predicate method) is evaluated to true. |
52 | | - sub_commands = [ |
53 | | - ('bazel_build', _build_cc_extensions), |
54 | | - ] + build.build.sub_commands |
| 50 | + # Add "bazel_build" command as the first sub_command of "build". Each |
| 51 | + # sub_command of "build" (e.g. "build_py", "build_ext", etc.) is executed |
| 52 | + # sequentially when running a "build" command, if the second item in the tuple |
| 53 | + # (predicate method) is evaluated to true. |
| 54 | + sub_commands = [ |
| 55 | + ("bazel_build", _build_cc_extensions), |
| 56 | + ] + build.build.sub_commands |
55 | 57 |
|
56 | 58 |
|
57 | 59 | class _BazelBuildCommand(setuptools.Command): |
58 | | - """Build TFDV C++ extensions and public protos with Bazel. |
59 | | -
|
60 | | - Running this command will populate foo_pb2.py file next to your foo.proto |
61 | | - file. |
62 | | - """ |
63 | | - |
64 | | - def initialize_options(self): |
65 | | - pass |
66 | | - |
67 | | - def finalize_options(self): |
68 | | - self._bazel_cmd = shutil.which('bazel') |
69 | | - if not self._bazel_cmd: |
70 | | - raise RuntimeError( |
71 | | - 'Could not find "bazel" binary. Please visit ' |
72 | | - 'https://docs.bazel.build/versions/master/install.html for ' |
73 | | - 'installation instruction.') |
74 | | - self._additional_build_options = [] |
75 | | - if platform.system() == 'Darwin': |
76 | | - self._additional_build_options = ['--macos_minimum_os=10.14'] |
77 | | - |
78 | | - def run(self): |
79 | | - subprocess.check_call( |
80 | | - [self._bazel_cmd, 'run', '-c', 'opt'] + self._additional_build_options + |
81 | | - ['//tensorflow_data_validation:move_generated_files'], |
82 | | - # Bazel should be invoked in a directory containing bazel WORKSPACE |
83 | | - # file, which is the root directory. |
84 | | - cwd=os.path.dirname(os.path.realpath(__file__)), |
85 | | - env=dict(os.environ, PYTHON_BIN_PATH=sys.executable)) |
| 60 | + """Build TFDV C++ extensions and public protos with Bazel. |
| 61 | +
|
| 62 | + Running this command will populate foo_pb2.py file next to your foo.proto |
| 63 | + file. |
| 64 | + """ |
| 65 | + |
| 66 | + def initialize_options(self): |
| 67 | + pass |
| 68 | + |
| 69 | + def finalize_options(self): |
| 70 | + self._bazel_cmd = shutil.which("bazel") |
| 71 | + if not self._bazel_cmd: |
| 72 | + raise RuntimeError( |
| 73 | + 'Could not find "bazel" binary. Please visit ' |
| 74 | + "https://docs.bazel.build/versions/master/install.html for " |
| 75 | + "installation instruction." |
| 76 | + ) |
| 77 | + self._additional_build_options = [] |
| 78 | + if platform.system() == "Darwin": |
| 79 | + self._additional_build_options = ["--macos_minimum_os=10.14"] |
| 80 | + |
| 81 | + def run(self): |
| 82 | + subprocess.check_call( |
| 83 | + [self._bazel_cmd, "run", "-c", "opt"] |
| 84 | + + self._additional_build_options |
| 85 | + + ["//tensorflow_data_validation:move_generated_files"], |
| 86 | + # Bazel should be invoked in a directory containing bazel WORKSPACE |
| 87 | + # file, which is the root directory. |
| 88 | + cwd=os.path.dirname(os.path.realpath(__file__)), |
| 89 | + env=dict(os.environ, PYTHON_BIN_PATH=sys.executable), |
| 90 | + ) |
86 | 91 |
|
87 | 92 |
|
88 | 93 | # TFDV is not a purelib. However because of the extension module is not built |
89 | 94 | # by setuptools, it will be incorrectly treated as a purelib. The following |
90 | 95 | # works around that bug. |
91 | 96 | class _InstallPlatlibCommand(install): |
92 | | - |
93 | | - def finalize_options(self): |
94 | | - install.finalize_options(self) |
95 | | - self.install_lib = self.install_platlib |
| 97 | + def finalize_options(self): |
| 98 | + install.finalize_options(self) |
| 99 | + self.install_lib = self.install_platlib |
96 | 100 |
|
97 | 101 |
|
98 | 102 | class _BinaryDistribution(Distribution): |
99 | | - """This class is needed in order to create OS specific wheels.""" |
| 103 | + """This class is needed in order to create OS specific wheels.""" |
100 | 104 |
|
101 | | - def is_pure(self): |
102 | | - return False |
| 105 | + def is_pure(self): |
| 106 | + return False |
103 | 107 |
|
104 | | - def has_ext_modules(self): |
105 | | - return True |
| 108 | + def has_ext_modules(self): |
| 109 | + return True |
106 | 110 |
|
107 | 111 |
|
108 | 112 | def _make_mutual_information_requirements(): |
109 | | - return ['scikit-learn>=1.0,<2', 'scipy>=1.5,<2'] |
| 113 | + return ["scikit-learn>=1.0,<2", "scipy>=1.5,<2"] |
110 | 114 |
|
111 | 115 |
|
112 | 116 | def _make_visualization_requirements(): |
113 | | - return [ |
114 | | - 'ipython>=7,<8', |
115 | | - ] |
| 117 | + return [ |
| 118 | + "ipython>=7,<8", |
| 119 | + ] |
116 | 120 |
|
117 | 121 |
|
118 | 122 | def _make_all_extra_requirements(): |
119 | | - return (_make_mutual_information_requirements() + |
120 | | - _make_visualization_requirements()) |
| 123 | + return _make_mutual_information_requirements() + _make_visualization_requirements() |
121 | 124 |
|
122 | 125 |
|
123 | 126 | def select_constraint(default, nightly=None, git_master=None): |
124 | | - """Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var.""" |
125 | | - selector = os.environ.get('TFX_DEPENDENCY_SELECTOR') |
126 | | - if selector == 'UNCONSTRAINED': |
127 | | - return '' |
128 | | - elif selector == 'NIGHTLY' and nightly is not None: |
129 | | - return nightly |
130 | | - elif selector == 'GIT_MASTER' and git_master is not None: |
131 | | - return git_master |
132 | | - else: |
133 | | - return default |
| 127 | + """Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var.""" |
| 128 | + selector = os.environ.get("TFX_DEPENDENCY_SELECTOR") |
| 129 | + if selector == "UNCONSTRAINED": |
| 130 | + return "" |
| 131 | + elif selector == "NIGHTLY" and nightly is not None: |
| 132 | + return nightly |
| 133 | + elif selector == "GIT_MASTER" and git_master is not None: |
| 134 | + return git_master |
| 135 | + else: |
| 136 | + return default |
134 | 137 |
|
135 | 138 |
|
136 | 139 | # Get version from version module. |
137 | | -with open('tensorflow_data_validation/version.py') as fp: |
138 | | - globals_dict = {} |
139 | | - exec(fp.read(), globals_dict) # pylint: disable=exec-used |
140 | | -__version__ = globals_dict['__version__'] |
| 140 | +with open("tensorflow_data_validation/version.py") as fp: |
| 141 | + globals_dict = {} |
| 142 | + exec(fp.read(), globals_dict) # pylint: disable=exec-used |
| 143 | +__version__ = globals_dict["__version__"] |
141 | 144 |
|
142 | 145 | # Get the long description from the README file. |
143 | | -with open('README.md') as fp: |
144 | | - _LONG_DESCRIPTION = fp.read() |
| 146 | +with open("README.md") as fp: |
| 147 | + _LONG_DESCRIPTION = fp.read() |
145 | 148 |
|
146 | 149 | setup( |
147 | | - name='tensorflow-data-validation', |
| 150 | + name="tensorflow-data-validation", |
148 | 151 | version=__version__, |
149 | | - author='Google LLC', |
150 | | - author_email='tensorflow-extended-dev@googlegroups.com', |
151 | | - license='Apache 2.0', |
| 152 | + author="Google LLC", |
| 153 | + author_email="tensorflow-extended-dev@googlegroups.com", |
| 154 | + license="Apache 2.0", |
152 | 155 | classifiers=[ |
153 | | - 'Development Status :: 5 - Production/Stable', |
154 | | - 'Intended Audience :: Developers', |
155 | | - 'Intended Audience :: Education', |
156 | | - 'Intended Audience :: Science/Research', |
157 | | - 'License :: OSI Approved :: Apache Software License', |
158 | | - 'Operating System :: MacOS :: MacOS X', |
159 | | - 'Operating System :: POSIX :: Linux', |
160 | | - 'Programming Language :: Python', |
161 | | - 'Programming Language :: Python :: 3', |
162 | | - 'Programming Language :: Python :: 3.9', |
163 | | - 'Programming Language :: Python :: 3.10', |
164 | | - 'Programming Language :: Python :: 3.11', |
165 | | - 'Programming Language :: Python :: 3 :: Only', |
166 | | - 'Topic :: Scientific/Engineering', |
167 | | - 'Topic :: Scientific/Engineering :: Artificial Intelligence', |
168 | | - 'Topic :: Scientific/Engineering :: Mathematics', |
169 | | - 'Topic :: Software Development', |
170 | | - 'Topic :: Software Development :: Libraries', |
171 | | - 'Topic :: Software Development :: Libraries :: Python Modules', |
| 156 | + "Development Status :: 5 - Production/Stable", |
| 157 | + "Intended Audience :: Developers", |
| 158 | + "Intended Audience :: Education", |
| 159 | + "Intended Audience :: Science/Research", |
| 160 | + "License :: OSI Approved :: Apache Software License", |
| 161 | + "Operating System :: MacOS :: MacOS X", |
| 162 | + "Operating System :: POSIX :: Linux", |
| 163 | + "Programming Language :: Python", |
| 164 | + "Programming Language :: Python :: 3", |
| 165 | + "Programming Language :: Python :: 3.9", |
| 166 | + "Programming Language :: Python :: 3.10", |
| 167 | + "Programming Language :: Python :: 3.11", |
| 168 | + "Programming Language :: Python :: 3 :: Only", |
| 169 | + "Topic :: Scientific/Engineering", |
| 170 | + "Topic :: Scientific/Engineering :: Artificial Intelligence", |
| 171 | + "Topic :: Scientific/Engineering :: Mathematics", |
| 172 | + "Topic :: Software Development", |
| 173 | + "Topic :: Software Development :: Libraries", |
| 174 | + "Topic :: Software Development :: Libraries :: Python Modules", |
172 | 175 | ], |
173 | 176 | namespace_packages=[], |
174 | 177 | # Make sure to sync the versions of common dependencies (absl-py, numpy, |
175 | 178 | # six, and protobuf) with TF. |
176 | 179 | install_requires=[ |
177 | | - 'absl-py>=0.9,<2.0.0', |
| 180 | + "absl-py>=0.9,<2.0.0", |
178 | 181 | 'apache-beam[gcp]>=2.53,<3;python_version>="3.11"', |
179 | 182 | 'apache-beam[gcp]>=2.50,<2.51;python_version<"3.11"', |
180 | 183 | # TODO(b/139941423): Consider using multi-processing provided by |
181 | 184 | # Beam's DirectRunner. |
182 | | - 'joblib>=1.2.0', # Dependency for multi-processing. |
183 | | - 'numpy>=1.22.0', |
184 | | - 'pandas>=1.0,<2', |
| 185 | + "joblib>=1.2.0", # Dependency for multi-processing. |
| 186 | + "numpy>=1.22.0", |
| 187 | + "pandas>=1.0,<2", |
185 | 188 | 'protobuf>=4.25.2,<6.0.0;python_version>="3.11"', |
186 | 189 | 'protobuf>=4.21.6,<6.0.0;python_version<"3.11"', |
187 | | - 'pyarrow>=10,<11', |
188 | | - 'pyfarmhash>=0.2.2,<0.4', |
189 | | - 'six>=1.12,<2', |
190 | | - 'tensorflow>=2.17,<2.18', |
191 | | - 'tensorflow-metadata' |
| 190 | + "pyarrow>=10,<11", |
| 191 | + "pyfarmhash>=0.2.2,<0.4", |
| 192 | + "six>=1.12,<2", |
| 193 | + "tensorflow>=2.17,<2.18", |
| 194 | + "tensorflow-metadata" |
192 | 195 | + select_constraint( |
193 | | - default='>=1.17.1,<1.18', |
194 | | - nightly='>=1.18.0.dev', |
195 | | - git_master='@git+https://github.com/tensorflow/metadata@master', |
| 196 | + default=">=1.17.1,<1.18", |
| 197 | + nightly=">=1.18.0.dev", |
| 198 | + git_master="@git+https://github.com/tensorflow/metadata@master", |
196 | 199 | ), |
197 | | - 'tfx-bsl' |
| 200 | + "tfx-bsl" |
198 | 201 | + select_constraint( |
199 | | - default='>=1.17.1,<1.18', |
200 | | - nightly='>=1.18.0.dev', |
201 | | - git_master='@git+https://github.com/tensorflow/tfx-bsl@master', |
| 202 | + default=">=1.17.1,<1.18", |
| 203 | + nightly=">=1.18.0.dev", |
| 204 | + git_master="@git+https://github.com/tensorflow/tfx-bsl@master", |
202 | 205 | ), |
203 | 206 | ], |
204 | 207 | extras_require={ |
205 | | - 'mutual-information': _make_mutual_information_requirements(), |
206 | | - 'visualization': _make_visualization_requirements(), |
207 | | - 'dev': ["precommit"], |
208 | | - 'test': [ |
209 | | - "pytest", |
210 | | - "scikit-learn", |
211 | | - "scipy", |
| 208 | + "mutual-information": _make_mutual_information_requirements(), |
| 209 | + "visualization": _make_visualization_requirements(), |
| 210 | + "dev": ["precommit"], |
| 211 | + "test": [ |
| 212 | + "pytest", |
| 213 | + "scikit-learn", |
| 214 | + "scipy", |
212 | 215 | ], |
213 | | - 'all': _make_all_extra_requirements(), |
| 216 | + "all": _make_all_extra_requirements(), |
214 | 217 | }, |
215 | | - python_requires='>=3.9,<4', |
| 218 | + python_requires=">=3.9,<4", |
216 | 219 | packages=find_packages(), |
217 | 220 | include_package_data=True, |
218 | | - package_data={'': ['*.lib', '*.pyd', '*.so']}, |
| 221 | + package_data={"": ["*.lib", "*.pyd", "*.so"]}, |
219 | 222 | zip_safe=False, |
220 | 223 | distclass=_BinaryDistribution, |
221 | | - description='A library for exploring and validating machine learning data.', |
| 224 | + description="A library for exploring and validating machine learning data.", |
222 | 225 | long_description=_LONG_DESCRIPTION, |
223 | | - long_description_content_type='text/markdown', |
224 | | - keywords='tensorflow data validation tfx', |
225 | | - url='https://www.tensorflow.org/tfx/data_validation/get_started', |
226 | | - download_url='https://github.com/tensorflow/data-validation/tags', |
| 226 | + long_description_content_type="text/markdown", |
| 227 | + keywords="tensorflow data validation tfx", |
| 228 | + url="https://www.tensorflow.org/tfx/data_validation/get_started", |
| 229 | + download_url="https://github.com/tensorflow/data-validation/tags", |
227 | 230 | requires=[], |
228 | 231 | cmdclass={ |
229 | | - 'install': _InstallPlatlibCommand, |
230 | | - 'build': _BuildCommand, |
231 | | - 'bazel_build': _BazelBuildCommand, |
| 232 | + "install": _InstallPlatlibCommand, |
| 233 | + "build": _BuildCommand, |
| 234 | + "bazel_build": _BazelBuildCommand, |
232 | 235 | }, |
233 | 236 | ) |
0 commit comments