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