Skip to content

Commit fe0dd01

Browse files
authored
Speed-up CMake builds by allowing a persistent Cmake build dir (#788)
1 parent 0b6aa0a commit fe0dd01

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ git clone [email protected]:pytorch/torchcodec.git
4242
# Or, using https instead of ssh: git clone https://github.com/pytorch/torchcodec.git
4343
cd torchcodec
4444

45+
# Optional, but recommended: define a persistent build directory which speeds-up
46+
# subsequent builds.
47+
export TORCHCODEC_CMAKE_BUILD_DIR="${PWD}/build"
48+
4549
pip install -e ".[dev]" --no-build-isolation -vv
4650
# Or, for cuda support: ENABLE_CUDA=1 pip install -e ".[dev]" --no-build-isolation -vv
4751
```

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,17 @@ def _build_all_extensions_with_cmake(self):
126126
f"-DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR={torchcodec_disable_compile_warning_as_error}",
127127
]
128128

129+
self.build_temp = os.getenv("TORCHCODEC_CMAKE_BUILD_DIR", self.build_temp)
130+
print(f"Using {self.build_temp = }", flush=True)
129131
Path(self.build_temp).mkdir(parents=True, exist_ok=True)
130132

133+
print("Calling cmake (configure)", flush=True)
131134
subprocess.check_call(
132135
["cmake", str(_ROOT_DIR)] + cmake_args, cwd=self.build_temp
133136
)
137+
print("Calling cmake --build", flush=True)
134138
subprocess.check_call(["cmake", "--build", "."], cwd=self.build_temp)
139+
print("Calling cmake --install", flush=True)
135140
subprocess.check_call(["cmake", "--install", "."], cwd=self.build_temp)
136141

137142
def copy_extensions_to_source(self):

0 commit comments

Comments
 (0)