|
18 | 18 | import shutil |
19 | 19 | import subprocess |
20 | 20 |
|
21 | | -import setuptools |
22 | | -from setuptools import find_packages |
23 | | -from setuptools import setup |
24 | 21 | # pylint: disable=g-bad-import-order |
25 | 22 | # It is recommended to import setuptools prior to importing distutils to avoid |
26 | 23 | # using legacy behavior from distutils. |
27 | 24 | # https://setuptools.readthedocs.io/en/latest/history.html#v48-0-0 |
28 | 25 | from distutils.command import build |
| 26 | + |
| 27 | +import setuptools |
| 28 | +from setuptools import find_packages, setup |
| 29 | + |
29 | 30 | # pylint: enable=g-bad-import-order |
30 | 31 |
|
31 | 32 |
|
32 | 33 | class _BuildCommand(build.build): |
33 | | - """Build everything that is needed to install. |
| 34 | + """Build everything that is needed to install. |
34 | 35 |
|
35 | | - This overrides the original distutils "build" command to to run bazel_build |
36 | | - command before any sub_commands. |
| 36 | + This overrides the original distutils "build" command to to run bazel_build |
| 37 | + command before any sub_commands. |
37 | 38 |
|
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 | | - """ |
| 39 | + build command is also invoked from bdist_wheel and install command, therefore |
| 40 | + this implementation covers the following commands: |
| 41 | + - pip install . (which invokes bdist_wheel) |
| 42 | + - python setup.py install (which invokes install command) |
| 43 | + - python setup.py bdist_wheel (which invokes bdist_wheel command) |
| 44 | + """ |
44 | 45 |
|
45 | | - def _build_cc_extensions(self): |
46 | | - return True |
| 46 | + def _build_cc_extensions(self): |
| 47 | + return True |
47 | 48 |
|
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 |
| 49 | + # Add "bazel_build" command as the first sub_command of "build". Each |
| 50 | + # sub_command of "build" (e.g. "build_py", "build_ext", etc.) is executed |
| 51 | + # sequentially when running a "build" command, if the second item in the tuple |
| 52 | + # (predicate method) is evaluated to true. |
| 53 | + sub_commands = [ |
| 54 | + ("bazel_build", _build_cc_extensions), |
| 55 | + ] + build.build.sub_commands |
55 | 56 |
|
56 | 57 |
|
57 | 58 | class _BazelBuildCommand(setuptools.Command): |
58 | | - """Build Bazel artifacts and move generated files to the .""" |
59 | | - |
60 | | - def initialize_options(self): |
61 | | - pass |
62 | | - |
63 | | - def finalize_options(self): |
64 | | - self._bazel_cmd = shutil.which('bazel') |
65 | | - if not self._bazel_cmd: |
66 | | - raise RuntimeError( |
67 | | - 'Could not find "bazel" binary. Please visit ' |
68 | | - 'https://docs.bazel.build/versions/master/install.html for ' |
69 | | - 'installation instruction.') |
70 | | - if platform.system() == 'Windows': |
71 | | - self._additional_build_options = ['--copt=-DWIN32_LEAN_AND_MEAN'] |
72 | | - else: |
73 | | - self._additional_build_options = [] |
74 | | - |
75 | | - def run(self): |
76 | | - subprocess.check_call( |
77 | | - [self._bazel_cmd, 'run', |
78 | | - '--compilation_mode', 'opt', |
79 | | - *self._additional_build_options, |
80 | | - '//tensorflow_metadata:move_generated_files'], |
81 | | - # Bazel should be invoked in a directory containing bazel WORKSPACE |
82 | | - # file, which is the root directory. |
83 | | - cwd=os.path.dirname(os.path.realpath(__file__)),) |
84 | | - |
85 | | - |
86 | | -with open('tensorflow_metadata/version.py') as fp: |
87 | | - globals_dict = {} |
88 | | - exec(fp.read(), globals_dict) # pylint: disable=exec-used |
| 59 | + """Build Bazel artifacts and move generated files to the .""" |
| 60 | + |
| 61 | + def initialize_options(self): |
| 62 | + pass |
| 63 | + |
| 64 | + def finalize_options(self): |
| 65 | + self._bazel_cmd = shutil.which("bazel") |
| 66 | + if not self._bazel_cmd: |
| 67 | + raise RuntimeError( |
| 68 | + 'Could not find "bazel" binary. Please visit ' |
| 69 | + "https://docs.bazel.build/versions/master/install.html for " |
| 70 | + "installation instruction." |
| 71 | + ) |
| 72 | + if platform.system() == "Windows": |
| 73 | + self._additional_build_options = ["--copt=-DWIN32_LEAN_AND_MEAN"] |
| 74 | + else: |
| 75 | + self._additional_build_options = [] |
| 76 | + |
| 77 | + def run(self): |
| 78 | + subprocess.check_call( |
| 79 | + [ |
| 80 | + self._bazel_cmd, |
| 81 | + "run", |
| 82 | + "--compilation_mode", |
| 83 | + "opt", |
| 84 | + *self._additional_build_options, |
| 85 | + "//tensorflow_metadata:move_generated_files", |
| 86 | + ], |
| 87 | + # Bazel should be invoked in a directory containing bazel WORKSPACE |
| 88 | + # file, which is the root directory. |
| 89 | + cwd=os.path.dirname(os.path.realpath(__file__)), |
| 90 | + ) |
| 91 | + |
| 92 | + |
| 93 | +with open("tensorflow_metadata/version.py") as fp: |
| 94 | + globals_dict = {} |
| 95 | + exec(fp.read(), globals_dict) # pylint: disable=exec-used |
89 | 96 |
|
90 | 97 | # tf.Metadata version. |
91 | | -__version__ = globals_dict['__version__'] |
| 98 | +__version__ = globals_dict["__version__"] |
92 | 99 |
|
93 | 100 |
|
94 | 101 | # Note: In order for the README to be rendered correctly, make sure to have the |
95 | 102 | # following minimum required versions of the respective packages when building |
96 | 103 | # and uploading the zip/wheel package to PyPI: |
97 | 104 | # setuptools >= 38.6.0, wheel >= 0.31.0, twine >= 1.11.0 |
98 | 105 | # Get the long description from the README file. |
99 | | -with open('README.md') as fp: |
100 | | - _LONG_DESCRIPTION = fp.read() |
| 106 | +with open("README.md") as fp: |
| 107 | + _LONG_DESCRIPTION = fp.read() |
101 | 108 |
|
102 | 109 | setup( |
103 | | - name='tensorflow-metadata', |
| 110 | + name="tensorflow-metadata", |
104 | 111 | version=__version__, |
105 | | - author='Google Inc.', |
106 | | - |
107 | | - license='Apache 2.0', |
| 112 | + author="Google Inc.", |
| 113 | + |
| 114 | + license="Apache 2.0", |
108 | 115 | classifiers=[ |
109 | | - 'Development Status :: 5 - Production/Stable', |
110 | | - 'Intended Audience :: Developers', |
111 | | - 'Intended Audience :: Education', |
112 | | - 'Intended Audience :: Science/Research', |
113 | | - 'License :: OSI Approved :: Apache Software License', |
114 | | - 'Operating System :: OS Independent', |
115 | | - 'Programming Language :: Python', |
116 | | - 'Programming Language :: Python :: 3', |
117 | | - 'Programming Language :: Python :: 3.9', |
118 | | - 'Programming Language :: Python :: 3.10', |
119 | | - 'Programming Language :: Python :: 3.11', |
120 | | - 'Programming Language :: Python :: 3 :: Only', |
121 | | - 'Topic :: Scientific/Engineering :: Artificial Intelligence', |
122 | | - 'Topic :: Scientific/Engineering :: Mathematics', |
123 | | - 'Topic :: Software Development', |
124 | | - 'Topic :: Software Development :: Libraries', |
125 | | - 'Topic :: Software Development :: Libraries :: Python Modules', |
| 116 | + "Development Status :: 5 - Production/Stable", |
| 117 | + "Intended Audience :: Developers", |
| 118 | + "Intended Audience :: Education", |
| 119 | + "Intended Audience :: Science/Research", |
| 120 | + "License :: OSI Approved :: Apache Software License", |
| 121 | + "Operating System :: OS Independent", |
| 122 | + "Programming Language :: Python", |
| 123 | + "Programming Language :: Python :: 3", |
| 124 | + "Programming Language :: Python :: 3.9", |
| 125 | + "Programming Language :: Python :: 3.10", |
| 126 | + "Programming Language :: Python :: 3.11", |
| 127 | + "Programming Language :: Python :: 3 :: Only", |
| 128 | + "Topic :: Scientific/Engineering :: Artificial Intelligence", |
| 129 | + "Topic :: Scientific/Engineering :: Mathematics", |
| 130 | + "Topic :: Software Development", |
| 131 | + "Topic :: Software Development :: Libraries", |
| 132 | + "Topic :: Software Development :: Libraries :: Python Modules", |
126 | 133 | ], |
127 | 134 | namespace_packages=[], |
128 | 135 | install_requires=[ |
129 | | - 'absl-py>=0.9,<3.0.0', |
| 136 | + "absl-py>=0.9,<3.0.0", |
130 | 137 | 'googleapis-common-protos>=1.56.4,<2;python_version>="3.11"', |
131 | 138 | 'protobuf>=4.25.2;python_version>="3.11"', |
132 | 139 | 'protobuf>=4.21.6,<4.22;python_version<"3.11"', |
133 | 140 | ], |
134 | | - python_requires='>=3.9,<4', |
| 141 | + python_requires=">=3.9,<4", |
135 | 142 | packages=find_packages(), |
| 143 | + extra_requires={ |
| 144 | + "dev": ["precommit"], |
| 145 | + }, |
136 | 146 | include_package_data=True, |
137 | | - description='Library and standards for schema and statistics.', |
| 147 | + description="Library and standards for schema and statistics.", |
138 | 148 | long_description=_LONG_DESCRIPTION, |
139 | | - long_description_content_type='text/markdown', |
140 | | - keywords='tensorflow metadata tfx', |
141 | | - download_url='https://github.com/tensorflow/metadata/tags', |
| 149 | + long_description_content_type="text/markdown", |
| 150 | + keywords="tensorflow metadata tfx", |
| 151 | + download_url="https://github.com/tensorflow/metadata/tags", |
142 | 152 | requires=[], |
143 | 153 | cmdclass={ |
144 | | - 'build': _BuildCommand, |
145 | | - 'bazel_build': _BazelBuildCommand, |
| 154 | + "build": _BuildCommand, |
| 155 | + "bazel_build": _BazelBuildCommand, |
146 | 156 | }, |
147 | 157 | ) |
0 commit comments