Unverified Commit ec13a815 authored by moto-meta's avatar moto-meta Committed by GitHub
Browse files

Migrate to src-layout

Differential Revision: D49965263

Pull Request resolved: https://github.com/pytorch/audio/pull/3639
parent e3b11a8e
......@@ -29,7 +29,7 @@ repos:
rev: 4.0.1
hooks:
- id: flake8
args: ['torchaudio', 'test', 'tools', 'docs/source/conf.py', 'examples']
args: ['src', 'test', 'tools', 'docs/source/conf.py', 'examples']
exclude: 'build|docs/src|third_party'
additional_dependencies:
- flake8-breakpoint == 1.1.0
......
......@@ -165,10 +165,10 @@ else()
message(STATUS "Could not find ccache. Consider installing ccache to speed up compilation.")
endif()
add_subdirectory(torchaudio/csrc)
add_subdirectory(src/torchaudio/csrc)
if (BUILD_SOX)
add_subdirectory(third_party/sox)
add_subdirectory(torchaudio/csrc/sox)
add_subdirectory(src/torchaudio/csrc/sox)
endif()
if (USE_FFMPEG)
if (DEFINED ENV{FFMPEG_ROOT})
......@@ -177,13 +177,13 @@ if (USE_FFMPEG)
message(STATUS "Building FFmpeg integration with multi version support")
add_subdirectory(third_party/ffmpeg/multi)
endif()
add_subdirectory(torchaudio/csrc/ffmpeg)
add_subdirectory(src/torchaudio/csrc/ffmpeg)
endif()
if (BUILD_CUDA_CTC_DECODER)
if (NOT USE_CUDA)
message(FATAL "BUILD_CUDA_CTC_DECODER=1 but USE_CUDA=0.")
endif()
add_subdirectory(torchaudio/csrc/cuctc)
add_subdirectory(src/torchaudio/csrc/cuctc)
endif()
if (BUILD_CPP_TEST)
add_subdirectory(test/cpp)
......
......@@ -16,7 +16,7 @@ endif()
function (torchaudio_library name source include_dirs link_libraries compile_defs)
add_library(${name} SHARED ${source})
target_include_directories(${name} PRIVATE "${PROJECT_SOURCE_DIR};${include_dirs}")
target_include_directories(${name} PRIVATE "${PROJECT_SOURCE_DIR}/src;${include_dirs}")
target_link_libraries(${name} ${link_libraries})
target_compile_definitions(${name} PRIVATE ${compile_defs})
set_target_properties(${name} PROPERTIES PREFIX "")
......@@ -45,7 +45,7 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
target_include_directories(
${name}
PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src
${Python_INCLUDE_DIR}
"${TORCH_INSTALL_PREFIX}/include"
${include_dirs})
......
......@@ -32,7 +32,7 @@ def _get_version(sha):
def _make_version_file(version, sha):
sha = "Unknown" if sha is None else sha
version_path = ROOT_DIR / "torchaudio" / "version.py"
version_path = ROOT_DIR / "src" / "torchaudio" / "version.py"
with open(version_path, "w") as f:
f.write(f"__version__ = '{version}'\n")
f.write(f"git_version = '{sha}'\n")
......@@ -50,7 +50,7 @@ class clean(distutils.command.clean.clean):
distutils.command.clean.clean.run(self)
# Remove torchaudio extension
for path in (ROOT_DIR / "torchaudio").glob("**/*.so"):
for path in (ROOT_DIR / "src").glob("**/*.so"):
print(f"removing '{path}'")
path.unlink()
# Remove build directory
......@@ -64,13 +64,7 @@ class clean(distutils.command.clean.clean):
def _get_packages(branch_name, tag):
exclude = [
"build*",
"test*",
"torchaudio.csrc*",
"third_party*",
"tools*",
]
exclude = []
exclude_prototype = False
if branch_name is not None and branch_name.startswith("release/"):
exclude_prototype = True
......@@ -79,7 +73,7 @@ def _get_packages(branch_name, tag):
if exclude_prototype:
print("Excluding torchaudio.prototype from the package.")
exclude.append("torchaudio.prototype*")
return find_packages(exclude=exclude)
return find_packages(where="src", exclude=exclude)
def _parse_url(path):
......@@ -147,6 +141,7 @@ def _main():
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
packages=_get_packages(branch, tag),
package_dir={"": "src"},
ext_modules=setup_helpers.get_ext_modules(),
cmdclass={
"build_ext": setup_helpers.CMakeBuild,
......
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