1616
1717import os
1818import platform
19+ import shutil
1920import subprocess
2021import sys
21-
2222import setuptools
23- from setuptools import find_namespace_packages
24- from setuptools import setup
25- from setuptools .command .install import install
26- from setuptools .dist import Distribution
27- # pylint:disable=g-bad-import-order
28- # setuptools must be imported prior to distutils.
29- # TODO(b/317036825): Stop using distutils, Python 3.12 doesn't have it.
30- from distutils import spawn
31- from distutils .command import build
32- # pylint:enable=g-bad-import-order
23+ from setuptools import dist
24+ from setuptools .command import build
25+ from setuptools .command import install
3326
3427
3528class _BuildCommand (build .build ):
@@ -57,7 +50,8 @@ def _build_cc_extensions(self):
5750 # sequentially when running a "build" command, if the second item in the tuple
5851 # (predicate method) is evaluated to true.
5952 sub_commands = [
60- ('bazel_build' , _build_cc_extensions )] + build .build .sub_commands
53+ ('bazel_build' , _build_cc_extensions )
54+ ] + build .build .sub_commands
6155
6256
6357class _BazelBuildCommand (setuptools .Command ):
@@ -71,7 +65,7 @@ def initialize_options(self):
7165 pass
7266
7367 def finalize_options (self ):
74- self ._bazel_cmd = spawn . find_executable ('bazel' )
68+ self ._bazel_cmd = shutil . which ('bazel' )
7569 if not self ._bazel_cmd :
7670 raise RuntimeError (
7771 'Could not find "bazel" binary. Please visit '
@@ -98,14 +92,14 @@ def run(self):
9892# TFDV is not a purelib. However because of the extension module is not built
9993# by setuptools, it will be incorrectly treated as a purelib. The following
10094# works around that bug.
101- class _InstallPlatlibCommand (install ):
95+ class _InstallPlatlibCommand (install . install ):
10296
10397 def finalize_options (self ):
104- install .finalize_options (self )
98+ install .install . finalize_options (self )
10599 self .install_lib = self .install_platlib
106100
107101
108- class _SourceDistributionWithProtos (Distribution ):
102+ class _SourceDistributionWithProtos (dist . Distribution ):
109103 """Proto-only deps don't require OS specific wheels."""
110104
111105 def is_pure (self ):
@@ -115,95 +109,11 @@ def has_ext_modules(self):
115109 return False
116110
117111
118- def get_version ():
119- """Get version from version module."""
120- version_path = os .path .join (os .path .dirname (__file__ ), 'tensorflow_gnn' )
121- sys .path .insert (0 , version_path )
122- # pytype: disable=import-error # pylint: disable=g-import-not-at-top
123- from version import __version__ as v
124- return v
125-
126-
127- # Get the long description from the README file.
128- # TODO(b/316329189): The relative links from README.md don't work on PyPI.
129- with open ('README.md' ) as fp :
130- _LONG_DESCRIPTION = fp .read ()
131-
132-
133- console_scripts = [
134- 'tensorflow_gnn.converters.ogb.convert_ogb_dataset' ,
135- 'tensorflow_gnn.experimental.sampler.beam.sampler' ,
136- # copybara:uncomment_begin(NetworkX utils)
137- # 'tensorflow_gnn.sampler.nx_converter',
138- # 'tensorflow_gnn.sampler.nx_generator',
139- # copybara:uncomment_end
140- 'tensorflow_gnn.tools.generate_training_data' ,
141- 'tensorflow_gnn.tools.print_training_data' ,
142- 'tensorflow_gnn.tools.sampled_stats' ,
143- 'tensorflow_gnn.tools.validate_graph_schema' ,
144- ]
145-
146-
147- setup (
148- name = 'tensorflow-gnn' ,
149- version = get_version (),
150- author = 'Google LLC' ,
151- author_email = 'tensorflow-gnn@googlegroups.com' ,
152- license = 'Apache 2.0' ,
153- classifiers = [
154- 'Development Status :: 5 - Production/Stable' ,
155- 'Intended Audience :: Developers' ,
156- 'Intended Audience :: Science/Research' ,
157- 'License :: OSI Approved :: Apache Software License' ,
158- 'Operating System :: MacOS :: MacOS X' ,
159- 'Operating System :: POSIX :: Linux' ,
160- 'Operating System :: Microsoft :: Windows' ,
161- 'Programming Language :: Python' ,
162- 'Programming Language :: Python :: 3' ,
163- 'Programming Language :: Python :: 3 :: Only' ,
164- 'Topic :: Scientific/Engineering' ,
165- 'Topic :: Scientific/Engineering :: Artificial Intelligence' ,
166- 'Topic :: Scientific/Engineering :: Mathematics' ,
167- 'Topic :: Software Development' ,
168- 'Topic :: Software Development :: Libraries' ,
169- 'Topic :: Software Development :: Libraries :: Python Modules' ,
170- ],
171- namespace_packages = [],
172- install_requires = [
173- 'google-vizier>=0.0.13,!=0.1.23,!=0.1.24' , # b/394062744
174- 'ml-collections' ,
175- 'networkx' ,
176- 'pyarrow' ,
177- # pylint:disable=g-line-too-long
178- 'tensorflow>=2.12.0,<3; platform_machine != "arm64" or platform_system != "Darwin"' ,
179- 'tensorflow-macos>=2.12.0,<3; platform_machine == "arm64" and platform_system == "Darwin"' ,
180- # pylint:enable=g-line-too-long
181- 'apache-beam' ,
182- ],
183- python_requires = '>=3.9,<4' ,
184- packages = find_namespace_packages (
185- exclude = ['examples*' , 'package*' , 'testdata*' ],
186- ),
187- include_package_data = True ,
188- package_data = {'' : ['*.proto' ]},
189- zip_safe = False ,
112+ setuptools .setup (
190113 distclass = _SourceDistributionWithProtos ,
191- description = 'A library for building scalable graph neural networks in TensorFlow.' ,
192- long_description = _LONG_DESCRIPTION ,
193- long_description_content_type = 'text/markdown' ,
194- keywords = 'tensorflow gnn graph' ,
195- url = 'https://github.com/tensorflow/gnn' ,
196- download_url = 'https://github.com/tensorflow/gnn.git' ,
197- requires = [],
198114 cmdclass = {
199115 'install' : _InstallPlatlibCommand ,
200116 'build' : _BuildCommand ,
201117 'bazel_build' : _BazelBuildCommand ,
202118 },
203- entry_points = {
204- 'console_scripts' : [
205- 'tfgnn_{}={}:main' .format (libname .split ('.' )[- 1 ], libname )
206- for libname in console_scripts
207- ],
208- }
209119)
0 commit comments