Skip to content

Commit

Permalink
Migrate to src-layout
Browse files Browse the repository at this point in the history
Differential Revision: D49965263

Pull Request resolved: #3639
  • Loading branch information
moto-meta authored Oct 9, 2023
1 parent e3b11a8 commit ec13a81
Show file tree
Hide file tree
Showing 234 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmake/TorchAudioHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down Expand Up @@ -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})
Expand Down
15 changes: 5 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -50,7 +50,7 @@ def run(self):
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
Expand All @@ -64,13 +64,7 @@ def run(self):


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
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ target_link_libraries(
target_include_directories(
wall_collision
PRIVATE
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src"
)
add_test(NAME wall_collision_test COMMAND wall_collision)
5 changes: 0 additions & 5 deletions torchaudio/lib/.gitignore

This file was deleted.

0 comments on commit ec13a81

Please sign in to comment.