Unverified Commit 234627f8 authored by moto's avatar moto Committed by GitHub
Browse files

Clean up setup.py (#1900)

parent 68318cc1
...@@ -19,26 +19,27 @@ def _run_cmd(cmd): ...@@ -19,26 +19,27 @@ def _run_cmd(cmd):
return None return None
# Creating the version file def _get_version(sha):
version = '0.11.0a0' version = '0.11.0a0'
sha = _run_cmd(['git', 'rev-parse', 'HEAD']) if os.getenv('BUILD_VERSION'):
version = os.getenv('BUILD_VERSION')
elif sha is not None:
version += '+' + sha[:7]
return version
if os.getenv('BUILD_VERSION'):
version = os.getenv('BUILD_VERSION')
elif sha is not None:
version += '+' + sha[:7]
print('-- Building version ' + version)
version_path = ROOT_DIR / 'torchaudio' / 'version.py' def _make_version_file(version, sha):
with open(version_path, 'w') as f: sha = 'Unknown' if sha is None else sha
f.write("__version__ = '{}'\n".format(version)) version_path = ROOT_DIR / 'torchaudio' / 'version.py'
f.write("git_version = {}\n".format(repr(sha or 'Unknown'))) with open(version_path, 'w') as f:
f.write(f"__version__ = '{version}'\n")
f.write(f"git_version = '{sha}'\n")
pytorch_package_version = os.getenv('PYTORCH_VERSION')
pytorch_package_dep = 'torch' def _get_pytorch_version():
if pytorch_package_version is not None: if 'PYTORCH_VERSION' in os.environ:
pytorch_package_dep += "==" + pytorch_package_version return f"torch=={os.environ['PYTORCH_VERSION']}"
return 'torch'
class clean(distutils.command.clean.clean): class clean(distutils.command.clean.clean):
...@@ -60,7 +61,7 @@ class clean(distutils.command.clean.clean): ...@@ -60,7 +61,7 @@ class clean(distutils.command.clean.clean):
shutil.rmtree(str(path), ignore_errors=True) shutil.rmtree(str(path), ignore_errors=True)
def _get_packages(): def _get_packages(branch_name, tag):
exclude = [ exclude = [
"build*", "build*",
"test*", "test*",
...@@ -69,13 +70,9 @@ def _get_packages(): ...@@ -69,13 +70,9 @@ def _get_packages():
"tools*", "tools*",
] ]
exclude_prototype = False exclude_prototype = False
branch_name = _run_cmd(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
is_on_tag = _run_cmd(['git', 'describe', '--tags', '--exact-match', '@'])
print('-- On branch:', branch_name)
print('-- On tag:', is_on_tag)
if branch_name is not None and branch_name.startswith('release/'): if branch_name is not None and branch_name.startswith('release/'):
exclude_prototype = True exclude_prototype = True
if is_on_tag is not None and re.match(r'v[\d.]+(-rc\d+)?', is_on_tag): if tag is not None and re.match(r'v[\d.]+(-rc\d+)?', tag):
exclude_prototype = True exclude_prototype = True
if exclude_prototype: if exclude_prototype:
print('Excluding torchaudio.prototype from the package.') print('Excluding torchaudio.prototype from the package.')
...@@ -83,36 +80,54 @@ def _get_packages(): ...@@ -83,36 +80,54 @@ def _get_packages():
return find_packages(exclude=exclude) return find_packages(exclude=exclude)
setup( def _main():
name="torchaudio", sha = _run_cmd(['git', 'rev-parse', 'HEAD'])
version=version, branch = _run_cmd(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
description="An audio package for PyTorch", tag = _run_cmd(['git', 'describe', '--tags', '--exact-match', '@'])
url="https://github.com/pytorch/audio", print('-- Git branch:', branch)
author="Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough", print('-- Git SHA:', sha)
author_email="soumith@pytorch.org", print('-- Git tag:', tag)
classifiers=[ pytorch_package_dep = _get_pytorch_version()
"Environment :: Plugins", print('-- PyTorch dependency:', pytorch_package_dep)
"Intended Audience :: Developers", version = _get_version(sha)
"Intended Audience :: Science/Research", print('-- Building version', version)
"License :: OSI Approved :: BSD License",
"Operating System :: MacOS :: MacOS X", _make_version_file(version, sha)
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX", setup(
"Programming Language :: C++", name="torchaudio",
"Programming Language :: Python :: 3.6", version=version,
"Programming Language :: Python :: 3.7", description="An audio package for PyTorch",
"Programming Language :: Python :: 3.8", url="https://github.com/pytorch/audio",
"Programming Language :: Python :: 3.9", author="Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough",
"Programming Language :: Python :: Implementation :: CPython", author_email="soumith@pytorch.org",
"Topic :: Multimedia :: Sound/Audio", classifiers=[
"Topic :: Scientific/Engineering :: Artificial Intelligence" "Environment :: Plugins",
], "Intended Audience :: Developers",
packages=_get_packages(), "Intended Audience :: Science/Research",
ext_modules=setup_helpers.get_ext_modules(), "License :: OSI Approved :: BSD License",
cmdclass={ "Operating System :: MacOS :: MacOS X",
'build_ext': setup_helpers.CMakeBuild, "Operating System :: Microsoft :: Windows",
'clean': clean, "Operating System :: POSIX",
}, "Programming Language :: C++",
install_requires=[pytorch_package_dep], "Programming Language :: Python :: 3.6",
zip_safe=False, "Programming Language :: Python :: 3.7",
) "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Scientific/Engineering :: Artificial Intelligence"
],
packages=_get_packages(branch, tag),
ext_modules=setup_helpers.get_ext_modules(),
cmdclass={
'build_ext': setup_helpers.CMakeBuild,
'clean': clean,
},
install_requires=[pytorch_package_dep],
zip_safe=False,
)
if __name__ == '__main__':
_main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment