-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test building with Sox on Windows #648
Changes from all commits
e39a006
74058c2
05d81aa
8908916
103f83c
37b2fed
561d167
6af3196
108e6c5
3f94833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,5 @@ dependencies: | |
- pip: | ||
- scipy | ||
- kaldi-io | ||
- PySoundFile | ||
- librosa | ||
- future |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@echo on | ||
|
||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [15^,17^) -property installationPath`) do ( | ||
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( | ||
set "VS15INSTALLDIR=%%i" | ||
set "VS15VCVARSALL=%%i\VC\Auxiliary\Build\vcvarsall.bat" | ||
goto vswhere | ||
) | ||
) | ||
|
||
:vswhere | ||
if "%VSDEVCMD_ARGS%" == "" ( | ||
call "%VS15VCVARSALL%" x64 || exit /b 1 | ||
) else ( | ||
call "%VS15VCVARSALL%" x64 %VSDEVCMD_ARGS% || exit /b 1 | ||
) | ||
|
||
@echo on | ||
|
||
python setup.py develop || exit /b 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# Arguments: PREFIX, specifying where to install dependencies into | ||
|
||
PREFIX="$(cygpath $1)" | ||
|
||
curl --retry 3 https://s3.amazonaws.com/ossci-windows/torchaudio_deps.7z --output /tmp/torchaudio_deps.7z | ||
7z x /tmp/torchaudio_deps.7z -o"$PREFIX/third_party" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
@echo off | ||
|
||
sh packaging/download_deps.sh '%CD%' | ||
if errorlevel 1 exit /b 1 | ||
|
||
set IS_CONDA=1 | ||
|
||
python setup.py install --single-version-externally-managed --record=record.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
:: Set env vars that tell distutils to use the compiler that we put on path | ||
SET DISTUTILS_USE_SDK=1 | ||
SET MSSdk=1 | ||
|
||
SET "VS_VERSION=16.0" | ||
SET "VS_MAJOR=16" | ||
SET "VS_YEAR=2019" | ||
|
||
set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out" | ||
set "MSYS2_ENV_CONV_EXCL=CL" | ||
|
||
:: For Python 3.5+, ensure that we link with the dynamic runtime. See | ||
:: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ for more info | ||
set "PY_VCRUNTIME_REDIST=%PREFIX%\\bin\\vcruntime140.dll" | ||
|
||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [16^,17^) -property installationPath`) do ( | ||
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( | ||
set "VSINSTALLDIR=%%i\" | ||
goto :vswhere | ||
) | ||
) | ||
|
||
:vswhere | ||
|
||
:: Shorten PATH to avoid the `input line too long` error. | ||
SET MyPath=%PATH% | ||
|
||
setlocal EnableDelayedExpansion | ||
|
||
SET TempPath="%MyPath:;=";"%" | ||
SET var= | ||
FOR %%a IN (%TempPath%) DO ( | ||
IF EXIST %%~sa ( | ||
SET "var=!var!;%%~sa" | ||
) | ||
) | ||
|
||
set "TempPath=!var:~1!" | ||
endlocal & set "PATH=%TempPath%" | ||
|
||
:: Shorten current directory too | ||
FOR %%A IN (.) DO CD "%%~sA" | ||
|
||
:: other things added by install_activate.bat at package build time |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
blas_impl: | ||
- mkl # [x86_64] | ||
c_compiler: | ||
- vs2019 # [win] | ||
cxx_compiler: | ||
- vs2019 # [win] | ||
python: | ||
- 3.5 | ||
- 3.6 | ||
# This differs from target_platform in that it determines what subdir the compiler | ||
# will target, not what subdir the compiler package will be itself. | ||
# For example, we need a win-64 vs2008_win-32 package, so that we compile win-32 | ||
# code on win-64 miniconda. | ||
cross_compiler_target_platform: | ||
- win-64 # [win] | ||
target_platform: | ||
- win-64 # [win] | ||
vc: | ||
- 14 | ||
zip_keys: | ||
- # [win] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this purposefully blank? Looks a bit confusing here without a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, and it should be a typo. |
||
- vc # [win] | ||
- c_compiler # [win] | ||
- cxx_compiler # [win] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
set YEAR=2019 | ||
set VER=16 | ||
|
||
mkdir "%PREFIX%\etc\conda\activate.d" | ||
COPY "%RECIPE_DIR%\activate.bat" "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
|
||
IF "%cross_compiler_target_platform%" == "win-64" ( | ||
set "target_platform=amd64" | ||
echo SET "CMAKE_GENERATOR=Visual Studio %VER% %YEAR% Win64" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo pushd "%%VSINSTALLDIR%%" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
IF "%VSDEVCMD_ARGS%" == "" ( | ||
echo CALL "VC\Auxiliary\Build\vcvarsall.bat" x64 >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo popd >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo pushd "%%VSINSTALLDIR%%" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo CALL "VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
) ELSE ( | ||
echo CALL "VC\Auxiliary\Build\vcvarsall.bat" x64 %VSDEVCMD_ARGS% >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo popd >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo pushd "%%VSINSTALLDIR%%" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo CALL "VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 %VSDEVCMD_ARGS% >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
) | ||
echo popd >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
) else ( | ||
set "target_platform=x86" | ||
echo SET "CMAKE_GENERATOR=Visual Studio %VER% %YEAR%" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo pushd "%%VSINSTALLDIR%%" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo CALL "VC\Auxiliary\Build\vcvars32.bat" >> "%PREFIX%\etc\conda\activate.d\vs%YEAR%_compiler_vars.bat" | ||
echo popd | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
set VC_PATH=x86 | ||
if "%ARCH%"=="64" ( | ||
set VC_PATH=x64 | ||
) | ||
|
||
set MSC_VER=2019 | ||
|
||
rem :: This should always be present for VC installed with VS. Not sure about VC installed with Visual C++ Build Tools 2015 | ||
rem FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\Software\Microsoft\DevDiv\VC\Servicing\14.0\IDE.x64" /v UpdateVersion`) DO ( | ||
rem set SP=%%A | ||
rem ) | ||
|
||
rem if not "%SP%" == "%PKG_VERSION%" ( | ||
rem echo "Version detected from registry: %SP%" | ||
rem echo "does not match version of package being built (%PKG_VERSION%)" | ||
rem echo "Do you have current updates for VS 2015 installed?" | ||
rem exit 1 | ||
rem ) | ||
|
||
|
||
REM ========== REQUIRES Win 10 SDK be installed, or files otherwise copied to location below! | ||
robocopy "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\%VC_PATH%" "%LIBRARY_BIN%" *.dll /E | ||
robocopy "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\%VC_PATH%" "%PREFIX%" *.dll /E | ||
if %ERRORLEVEL% GEQ 8 exit 1 | ||
|
||
REM ========== This one comes from visual studio 2019 | ||
set "VC_VER=142" | ||
|
||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [16^,17^) -property installationPath`) do ( | ||
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" ( | ||
set "VS15VCVARSALL=%%i\VC\Auxiliary\Build\vcvarsall.bat" | ||
goto :eof | ||
) | ||
) | ||
|
||
@setlocal | ||
call "%VS15VARSALL%" x64 | ||
|
||
set "REDIST_ROOT=%VCToolsRedistDir%%VC_PATH%" | ||
|
||
robocopy "%REDIST_ROOT%\Microsoft.VC%VC_VER%.CRT" "%LIBRARY_BIN%" *.dll /E | ||
if %ERRORLEVEL% LSS 8 exit 0 | ||
robocopy "%REDIST_ROOT%\Microsoft.VC%VC_VER%.CRT" "%PREFIX%" *.dll /E | ||
if %ERRORLEVEL% LSS 8 exit 0 | ||
robocopy "%REDIST_ROOT%\Microsoft.VC%VC_VER%.OpenMP" "%LIBRARY_BIN%" *.dll /E | ||
if %ERRORLEVEL% LSS 8 exit 0 | ||
robocopy "%REDIST_ROOT%\Microsoft.VC%VC_VER%.OpenMP" "%PREFIX%" *.dll /E | ||
if %ERRORLEVEL% LSS 8 exit 0 | ||
@endlocal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% set vcver="14.2" %} | ||
{% set vcfeature="14" %} | ||
{% set vsyear="2019" %} | ||
{% set fullver="15.4.27004.2010" %} | ||
|
||
package: | ||
name: vs{{ vsyear }} | ||
version: {{ fullver }} | ||
|
||
build: | ||
skip: True [not win] | ||
script_env: | ||
- VSDEVCMD_ARGS # [win] | ||
|
||
outputs: | ||
- name: vs{{ vsyear }}_{{ cross_compiler_target_platform }} | ||
script: install_activate.bat | ||
track_features: | ||
# VS 2019 is binary-compatible with VS 2017/vc 14.1 and 2015/vc14. Tools are "v142". | ||
strong: | ||
- vc{{ vcfeature }} | ||
about: | ||
summary: Activation and version verification of MSVC {{ vcver }} (VS {{ vsyear }}) compiler | ||
license: BSD 3-clause |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,10 +44,19 @@ def check_env_flag(name, default=''): | |
# proper link order (sox, mad, flac, lame) | ||
# (the most important thing is that dependencies come after a libraryl | ||
# e.g., sox comes first) | ||
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/libsox.a')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/mad/lib/libmad.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')] | ||
if platform.system() == 'Windows': | ||
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/sox.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/mad/lib/mad.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/flac/lib/FLAC.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/lame/lib/mp3lame.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/ogg/lib/ogg.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/lpc10.lib')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/gsm.lib')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #625, I am merging third party libraries into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So maybe I should wait for your PR? Or I just do that for Windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just do that for Windows. |
||
else: | ||
extra_objects += [os.path.join(audio_path, 'third_party/sox/lib/libsox.a')] | ||
extra_objects += [os.path.join(audio_path, 'third_party/mad/lib/libmad.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'] | ||
|
||
|
@@ -79,19 +88,16 @@ def check_env_flag(name, default=''): | |
if pytorch_package_version is not None: | ||
pytorch_package_dep += "==" + pytorch_package_version | ||
|
||
if platform.system() == 'Windows': | ||
ext_modules = None | ||
else: | ||
ext_modules = [ | ||
CppExtension( | ||
'torchaudio._torchaudio', | ||
['torchaudio/csrc/sox.cpp'], | ||
libraries=libraries, | ||
include_dirs=include_dirs + [cwd], | ||
extra_compile_args=eca, | ||
extra_objects=extra_objects, | ||
extra_link_args=ela), | ||
] | ||
ext_modules = [ | ||
CppExtension( | ||
'torchaudio._torchaudio', | ||
['torchaudio/csrc/sox.cpp'], | ||
libraries=libraries, | ||
include_dirs=include_dirs + [cwd], | ||
extra_compile_args=eca, | ||
extra_objects=extra_objects, | ||
extra_link_args=ela), | ||
] | ||
|
||
|
||
setup( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several questions regarding this
torchaudio_deps.7z
contain?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header and the libraries of the third-party dependencies, like
FLAC
,libmad
andlibmp3lame
.Built locally by myself.
Binary.
Generally speaking, I built them one by one manually according to the steps given by the project itself using VS 2019. However, some of the project support only very old format of the MSVC project, so I have to rewrite it using CMake.
I hope that I could figure out the automatic build script for those projects. It is not easy because like I said in the previous question that I had to modify them a little bit. But I think it would be fine since some of the dependencies are not updated for a long time, like Sox and libmad. So for those old projects, maybe we could just download deps or maintain a fork. As for the active projects, like
FLAC
, we could just use the steps provided by the project itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not entirely sure if I would want to sign us up for this considering any update would have to be done by hand (however infrequent the updates may come).
Is there a way to contribute what we've done to make this dependency archive to those upstream dependencies?