Skip to content

Commit

Permalink
Merge branch 'v0.2.0' into master (pytorch#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamarshon authored and cpuhrsch committed Jul 26, 2019
1 parent 3f122ae commit e354062
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ ENV/

# Generated Files
test/assets/sinewave.wav
torchaudio/version.py
2 changes: 1 addition & 1 deletion build_tools/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ if [[ "$SKIP_TESTS" != "true" ]]; then
conda install --yes pytorch-nightly-cpu -c pytorch

# TorchAudio CPP Extensions
pip install .
python setup.py install
fi
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
torch>=1.1.0

# Optional for torchaudio.kaldi_io
numpy
kaldi_io
Expand All @@ -8,7 +10,7 @@ kaldi_io
flake8

# Used for comparison of outputs in tests
librosa
librosa>=0.4.3
scipy

# Unit tests with pytest
Expand Down
64 changes: 62 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
import os
import platform
import sys
import subprocess

from setuptools import setup, find_packages
from torch.utils.cpp_extension import BuildExtension, CppExtension
Expand All @@ -10,6 +12,11 @@ def check_env_flag(name, default=''):
return os.getenv(name, default).upper() in set(['ON', '1', 'YES', 'TRUE', 'Y'])

DEBUG = check_env_flag('DEBUG')
IS_WHEEL = check_env_flag('IS_WHEEL')
IS_CONDA = check_env_flag('IS_CONDA')

print('DEBUG:', DEBUG, 'IS_WHEEL:', IS_WHEEL, 'IS_CONDA:', IS_CONDA)

eca = []
ela = []
if DEBUG:
Expand All @@ -19,6 +26,56 @@ def check_env_flag(name, default=''):
eca += ['-O0', '-g']
ela += ['-O0', '-g']


libraries = []
include_dirs = []
extra_objects = []

if IS_WHEEL:
audio_path = os.path.dirname(os.path.abspath(__file__))

include_dirs += [os.path.join(audio_path, 'third_party/flac/include')]
include_dirs += [os.path.join(audio_path, 'third_party/lame/include')]
include_dirs += [os.path.join(audio_path, 'third_party/sox/include')]

# proper link order (sox, flac, lame)
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/libsox.a')]
extra_objects += [os.path.join(audio_path, 'third_party/flac/lib/libFLAC.a')]
extra_objects += [os.path.join(audio_path, 'third_party/lame/lib/libmp3lame.a')]
else:
libraries += ['sox']

if IS_CONDA:
# We want $PREFIX/include for conda (for sox.h)
lib_path = os.path.dirname(sys.executable)
include_dirs += [os.path.join(os.path.dirname(lib_path), 'include')]


# Creating the version file
cwd = os.path.dirname(os.path.abspath(__file__))
version = '0.2.0a0'
sha = 'Unknown'

try:
sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
except Exception:
pass

if os.getenv('TORCHAUDIO_BUILD_VERSION'):
assert os.getenv('TORCHAUDIO_BUILD_NUMBER') is not None
build_number = int(os.getenv('TORCHAUDIO_BUILD_NUMBER'))
version = os.getenv('TORCHAUDIO_BUILD_VERSION')
if build_number > 1:
version += '.post' + str(build_number)
elif sha != 'Unknown':
version += '+' + sha[:7]
print('-- Building version ' + version)

version_path = os.path.join(cwd, 'torchaudio', 'version.py')
with open(version_path, 'w') as f:
f.write("__version__ = '{}'\n".format(version))
f.write("git_version = {}\n".format(repr(sha)))

setup(
name="torchaudio",
version="0.2",
Expand All @@ -35,7 +92,8 @@ def check_env_flag(name, default=''):
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: C++",
"Programming Language :: Python 3",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Scientific/Engineering :: Artificial Intelligence"
Expand All @@ -46,8 +104,10 @@ def check_env_flag(name, default=''):
CppExtension(
'_torch_sox',
['torchaudio/torch_sox.cpp'],
libraries=['sox'],
libraries=libraries,
include_dirs=include_dirs,
extra_compile_args=eca,
extra_objects=extra_objects,
extra_link_args=ela),
],
cmdclass={'build_ext': BuildExtension},
Expand Down
1 change: 1 addition & 0 deletions torchaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import torch
import _torch_sox

from .version import __version__, git_version
from torchaudio import transforms, datasets, kaldi_io, sox_effects, legacy, compliance


Expand Down

0 comments on commit e354062

Please sign in to comment.