setup.py 2.82 KB
Newer Older
Soumith Chintala's avatar
Soumith Chintala committed
1
#!/usr/bin/env python
2
import os
moto's avatar
moto committed
3
import shutil
4
import subprocess
moto's avatar
moto committed
5
6
from pathlib import Path
import distutils.command.clean
Soumith Chintala's avatar
Soumith Chintala committed
7
from setuptools import setup, find_packages
8

moto's avatar
moto committed
9
from build_tools import setup_helpers
10

moto's avatar
moto committed
11
ROOT_DIR = Path(__file__).parent.resolve()
12
13
14


# Creating the version file
moto's avatar
moto committed
15
version = '0.6.0a0'
16
17
18
sha = 'Unknown'

try:
moto's avatar
moto committed
19
    sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT_DIR).decode('ascii').strip()
20
21
22
except Exception:
    pass

23
24
if os.getenv('BUILD_VERSION'):
    version = os.getenv('BUILD_VERSION')
25
26
27
28
elif sha != 'Unknown':
    version += '+' + sha[:7]
print('-- Building version ' + version)

moto's avatar
moto committed
29
version_path = ROOT_DIR / 'torchaudio' / 'version.py'
30
31
32
33
with open(version_path, 'w') as f:
    f.write("__version__ = '{}'\n".format(version))
    f.write("git_version = {}\n".format(repr(sha)))

34
pytorch_package_version = os.getenv('PYTORCH_VERSION')
35

36
pytorch_package_dep = 'torch'
37
38
if pytorch_package_version is not None:
    pytorch_package_dep += "==" + pytorch_package_version
39

moto's avatar
moto committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

class clean(distutils.command.clean.clean):
    def run(self):
        # Run default behavior first
        distutils.command.clean.clean.run(self)

        # Remove torchaudio extension
        for path in (ROOT_DIR / 'torchaudio').glob('**/*.so'):
            print(f'removing \'{path}\'')
            path.unlink()
        # Remove build directory
        build_dirs = [
            ROOT_DIR / 'build',
            ROOT_DIR / 'third_party' / 'build',
        ]
        for path in build_dirs:
            if path.exists():
                print(f'removing \'{path}\' (and everything under it)')
                shutil.rmtree(str(path), ignore_errors=True)
peterjc123's avatar
peterjc123 committed
59

60

Soumith Chintala's avatar
Soumith Chintala committed
61
setup(
62
    name="torchaudio",
63
    version=version,
Soumith Chintala's avatar
Soumith Chintala committed
64
65
    description="An audio package for PyTorch",
    url="https://github.com/pytorch/audio",
66
    author="Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough",
Soumith Chintala's avatar
Soumith Chintala committed
67
    author_email="soumith@pytorch.org",
Hong Xu's avatar
Hong Xu committed
68
69
70
71
72
73
74
75
76
    classifiers=[
        "Environment :: Plugins",
        "Intended Audience :: Developers",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: BSD License",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: POSIX",
        "Programming Language :: C++",
77
78
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3",
Hong Xu's avatar
Hong Xu committed
79
80
81
82
        "Programming Language :: Python :: Implementation :: CPython",
        "Topic :: Multimedia :: Sound/Audio",
        "Topic :: Scientific/Engineering :: Artificial Intelligence"
    ],
moto's avatar
moto committed
83
84
85
86
87
    packages=find_packages(exclude=["build*", "test*", "torchaudio.csrc*", "third_party*", "build_tools*"]),
    ext_modules=setup_helpers.get_ext_modules(),
    cmdclass={
        'build_ext': setup_helpers.BuildExtension.with_options(no_python_abi_suffix=True)
    },
88
    install_requires=[pytorch_package_dep]
89
)