Skip to content

Commit 08bdedf

Browse files
ssjhvcopybara-github
authored andcommitted
build_pip_pkg.py now accepts and requires the wheel file destination directory
as main script argument, instead of hardcoded /tmp/tensorflow_compression. The wheel version may be passed to an additional main script argument. An empty string for version is the same as not providing the version and defaults to "custom_build_from_source". PiperOrigin-RevId: 467276210 Change-Id: I4e4ef505dc1469f400e0dda5c09c70fedc98c613
1 parent ef79706 commit 08bdedf

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

build_pip_pkg.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
import setuptools
2424

2525
# Version string is intentionally set to non-numeric value, so that non-release
26-
# built packages are different from release packages. During builds for formal
27-
# releases, we should temporarily change this value to pip release version.
28-
__version__ = "custom-build-from-source"
26+
# built packages are different from release packages.
27+
DEFAULT_VERSION = "custom-build-from-source"
2928

3029

3130
class BinaryDistribution(setuptools.Distribution):
@@ -35,7 +34,7 @@ def has_ext_modules(self):
3534
return True
3635

3736

38-
def main(srcdir):
37+
def main(srcdir: str, destdir: str, version: str = ""):
3938
tempdir = tempfile.mkdtemp()
4039
atexit.register(shutil.rmtree, tempdir)
4140

@@ -58,7 +57,7 @@ def main(srcdir):
5857
os.chdir(tempdir)
5958
setuptools.setup(
6059
name="tensorflow_compression",
61-
version=__version__,
60+
version=version or DEFAULT_VERSION,
6261
description="Data compression in TensorFlow",
6362
url="https://tensorflow.github.io/compression/",
6463
author="Google LLC",
@@ -95,13 +94,12 @@ def main(srcdir):
9594
"python deep-learning deep-neural-networks neural-network ml")
9695
)
9796

98-
destdir = "/tmp/tensorflow_compression"
99-
print("=== Copying wheel to " + destdir)
100-
if not os.path.exists(destdir): os.mkdir(destdir)
97+
print("=== Copying wheel to:", destdir)
98+
os.makedirs(destdir, exist_ok=True)
10199
for path in glob.glob(os.path.join(tempdir, "dist", "*.whl")):
102-
print("Copying into " + os.path.join(destdir, os.path.basename(path)))
103-
shutil.copy(path, destdir)
100+
print("Copied into:", shutil.copy(path, destdir))
104101

105102

106103
if __name__ == "__main__":
107-
main(sys.argv[1] if len(sys.argv) > 1 else "")
104+
main(*sys.argv[1:]) # pylint: disable=no-value-for-parameter
105+

0 commit comments

Comments
 (0)