Skip to content

Commit 6ab06b2

Browse files
Migrate package metadata to pyproject.toml.
PiperOrigin-RevId: 829082204
1 parent 5926f8e commit 6ab06b2

File tree

7 files changed

+151
-131
lines changed

7 files changed

+151
-131
lines changed

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.7.0

kokoro/github/ubuntu/cpu/build.sh

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,35 @@
1616
set -e
1717
set -x
1818

19-
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
19+
PYENV_ROOT="/home/kbuilder/.pyenv"
20+
PYTHON_VERSION=${PYTHON_VERSION:-"3.9"}
2021

21-
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
22+
echo "Installing pyenv.."
23+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
24+
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
25+
eval "$(pyenv init --path)"
2226

23-
PYTHON_BINARY="/usr/bin/python3.9"
24-
PIP_TEST_PREFIX=bazel_pip
27+
echo "Python setup..."
28+
pyenv install -s "$PYTHON_VERSION"
29+
pyenv global "$PYTHON_VERSION"
2530

26-
"${PYTHON_BINARY}" -m venv venv
27-
source venv/bin/activate
31+
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
32+
33+
PIP_TEST_PREFIX=bazel_pip
2834

2935
# Check the python version
3036
python --version
3137
python3 --version
3238

39+
python -m venv build_venv
40+
source build_venv/bin/activate
41+
42+
# update pip
43+
pip install --upgrade pip
44+
45+
# Install build
46+
pip install build
47+
3348
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
3449
rm -rf "$TEST_ROOT"
3550
mkdir -p "$TEST_ROOT"
@@ -43,14 +58,17 @@ if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}*
4358
fi
4459

4560
bazel clean
46-
pip install -r requirements-dev.txt --progress-bar off
47-
pip install tf-keras-nightly tf-nightly --progress-bar off --upgrade
61+
pip install --group test-nightly --progress-bar off --upgrade
4862
# We need to remove the dependency on tensorflow to test nightly
49-
# The dependencies will be provided by tf-nightly
50-
perl -i -lpe '$k+= s/tensorflow>=2\.[0-9]+\.[0-9]+(,<=?[0-9.]+)?;/tf-nightly;/g; END{exit($k != 1)}' setup.py
51-
python3 setup.py bdist_wheel
52-
pip uninstall -y tensorflow_gnn
63+
python3 -m build --wheel
64+
deactivate
65+
66+
# Start the test environment.
67+
python3 -m venv test_venv
68+
source test_venv/bin/activate
69+
pip install --upgrade pip
5370
pip install dist/tensorflow_gnn-*.whl
71+
pip install --group test --progress-bar off --upgrade
5472

5573
echo "Final packages after all pip commands:"
5674
pip list

kokoro/github/ubuntu/cpu/build_versioned.sh

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,35 @@
1616
set -e
1717
set -x
1818

19-
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
19+
PYENV_ROOT="/home/kbuilder/.pyenv"
20+
PYTHON_VERSION=${PYTHON_VERSION:-"3.9"}
21+
22+
echo "Installing pyenv.."
23+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
24+
export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH"
25+
eval "$(pyenv init --path)"
2026

21-
sudo apt-get install -y "python${PYTHON_VERSION}"
27+
echo "Python setup..."
28+
pyenv install -s "$PYTHON_VERSION"
29+
pyenv global "$PYTHON_VERSION"
2230

23-
# Update alternatives, taken from corresponding Keras OSS test script
24-
sudo update-alternatives --install /usr/bin/python3 python3 "/usr/bin/python$PYTHON_VERSION" 1
25-
sudo apt-get install -y python$PYTHON_VERSION-venv
31+
cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/"
2632

27-
PYTHON_BINARY="/usr/bin/python${PYTHON_VERSION}"
2833
PIP_TEST_PREFIX=bazel_pip
2934

30-
"${PYTHON_BINARY}" -m venv venv
31-
source venv/bin/activate
35+
python -m venv build_venv
36+
source build_venv/bin/activate
3237

3338
# Debug messages to indicate the python version
3439
python --version
3540
python3 --version
3641

42+
# update pip
43+
pip install --upgrade pip
44+
45+
# Install build
46+
pip install build
47+
3748
TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX}
3849
rm -rf "$TEST_ROOT"
3950
mkdir -p "$TEST_ROOT"
@@ -54,16 +65,22 @@ if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}*
5465
fi
5566

5667
bazel clean
57-
pip install -r requirements-dev.txt --progress-bar off
5868
pip install tensorflow=="${TF_VERSION}" --progress-bar off --upgrade
5969
if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then
6070
pip install tf-keras=="${TF_VERSION}" --progress-bar off --upgrade
6171
fi
62-
python3 setup.py bdist_wheel
63-
pip uninstall -y tensorflow_gnn
72+
python3 -m build --wheel
73+
deactivate
74+
75+
# Start the test environment.
76+
python3 -m venv test_venv
77+
source test_venv/bin/activate
78+
pip install --upgrade pip
79+
pip install --group test --progress-bar off --upgrade
80+
6481
pip install dist/tensorflow_gnn-*.whl
6582

6683
echo "Final packages after all pip commands:"
6784
pip list
6885

69-
bazel test --test_env=TF_USE_LEGACY_KERAS --build_tag_filters="${tag_filters}" --test_tag_filters="${tag_filters}" --test_output=errors --verbose_failures=true --build_tests_only --define=no_tfgnn_py_deps=true --keep_going --experimental_repo_remote_exec //bazel_pip/tensorflow_gnn/...
86+
bazel test --test_env="TF_USE_LEGACY_KERAS=1" --build_tag_filters="${tag_filters}" --test_tag_filters="${tag_filters}" --test_output=errors --verbose_failures=true --build_tests_only --define=no_tfgnn_py_deps=true --keep_going --experimental_repo_remote_exec //bazel_pip/tensorflow_gnn/...

pyproject.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[project]
2+
name = "tensorflow_gnn"
3+
description = "A library for building scalable graph neural networks in TensorFlow."
4+
readme = "README.md"
5+
keywords = ["tensorflow", "gnn", "graph"]
6+
dynamic = ["version"]
7+
license = "Apache-2.0"
8+
requires-python = ">=3.9"
9+
dependencies = [
10+
"google-vizier>=0.0.13, !=0.1.23, !=0.1.24", # b/394062744
11+
"ml-collections",
12+
"networkx",
13+
"pyarrow",
14+
"tensorflow>=2.12.0, <3; platform_machine != 'arm64' or platform_system != 'Darwin'",
15+
"tensorflow-macos>=2.12.0, <3; platform_machine == 'arm64' and platform_system == 'Darwin'",
16+
"apache-beam>=2.54",
17+
]
18+
authors = [
19+
{name = "Google LLC", email = "tensorflow-gnn@googlegroups.com"},
20+
]
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Intended Audience :: Developers",
24+
"Intended Audience :: Science/Research",
25+
"Operating System :: MacOS :: MacOS X",
26+
"Operating System :: POSIX :: Linux",
27+
"Operating System :: Microsoft :: Windows",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3 :: Only",
32+
"Topic :: Scientific/Engineering",
33+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
34+
"Topic :: Scientific/Engineering :: Mathematics",
35+
"Topic :: Software Development",
36+
"Topic :: Software Development :: Libraries",
37+
"Topic :: Software Development :: Libraries :: Python Modules",
38+
]
39+
40+
[project.urls]
41+
homepage = "https://github.com/tensorflow/gnn"
42+
source = "https://github.com/tensorflow/gnn.git"
43+
44+
[dependency-groups]
45+
test = [
46+
"mock",
47+
"tf-keras",
48+
]
49+
test-nightly = [
50+
"tf-nightly",
51+
"tf-keras-nightly",
52+
{include-group = "test"},
53+
]
54+
55+
[project.scripts]
56+
tfgnn_convert_ogb_dataset = 'tensorflow_gnn.converters.ogb.convert_ogb_dataset:main'
57+
tfgnn_sampler = 'tensorflow_gnn.experimental.sampler.beam.sampler:main'
58+
# copybara:comment_begin(NetworkX utils)
59+
tfgnn_nx_converter = 'tensorflow_gnn.sampler.nx_converter:main'
60+
tfgnn_nx_generator = 'tensorflow_gnn.sampler.nx_generator:main'
61+
# copybara:comment_end
62+
tfgnn_generate_training_data = 'tensorflow_gnn.tools.generate_training_data:main'
63+
tfgnn_print_training_data = 'tensorflow_gnn.tools.print_training_data:main'
64+
tfgnn_sampled_stats = 'tensorflow_gnn.tools.sampled_stats:main'
65+
tfgnn_validate_graph_schema = 'tensorflow_gnn.tools.validate_graph_schema:main'
66+
67+
[build-system]
68+
requires = ["setuptools", "numpy"]
69+
build-backend = "setuptools.build_meta"
70+
71+
[tool.setuptools.dynamic]
72+
version = {attr = "tensorflow_gnn.version.__version__"}
73+
74+
[tool.setuptools.packages.find]
75+
exclude = ["examples*", "package*", "testdata*", "build*", "bazel*"]
76+
77+
[tool.setuptools.package-data]
78+
tensorflow_gnn = ["*.proto"]
79+

requirements-dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

setup.py

Lines changed: 11 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@
1616

1717
import os
1818
import platform
19+
import shutil
1920
import subprocess
2021
import sys
21-
2222
import 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

3528
class _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

6357
class _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
)

tensorflow_gnn/graph/tag_utils_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ReverseTagTest(parameterized.TestCase):
3030
("Source", const.SOURCE, const.TARGET),
3131
("Target", const.TARGET, const.SOURCE))
3232
def test(self, tag, expected):
33+
assert True
3334
actual = tag_utils.reverse_tag(tag)
3435
self.assertEqual(expected, actual)
3536

0 commit comments

Comments
 (0)