Skip to content

Commit db3522d

Browse files
author
pytorchbot
committed
2025-08-27 nightly release (1dd1bc7)
1 parent abb0062 commit db3522d

17 files changed

+181
-50
lines changed

.github/workflows/docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54-
# 3.9 corresponds to the minimum python version for which we build
54+
# 3.10 corresponds to the minimum python version for which we build
5555
# the wheel unless the label cliflow/binaries/all is present in the
5656
# PR.
57-
python-version: ['3.9']
57+
python-version: ['3.10']
5858
cuda-version: ['12.6']
5959
ffmpeg-version-for-tests: ['7']
6060
container:

.github/workflows/linux_cuda_wheel.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ jobs:
6161
strategy:
6262
fail-fast: false
6363
matrix:
64-
# 3.9 corresponds to the minimum python version for which we build
64+
# 3.10 corresponds to the minimum python version for which we build
6565
# the wheel unless the label cliflow/binaries/all is present in the
6666
# PR.
6767
# For the actual release we should add that label and change this to
6868
# include more python versions.
69-
python-version: ['3.9']
69+
python-version: ['3.10']
7070
# We test against 12.6 and 12.9 to avoid having too big of a CI matrix,
7171
# but for releases we should add 12.8.
7272
cuda-version: ['12.6', '12.9']

.github/workflows/linux_wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
strategy:
6363
fail-fast: false
6464
matrix:
65-
python-version: ['3.9']
65+
python-version: ['3.10']
6666
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
6767
needs: build
6868
steps:

.github/workflows/macos_wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
strategy:
6464
fail-fast: false
6565
matrix:
66-
python-version: ['3.9']
66+
python-version: ['3.10']
6767
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
6868
needs: build
6969
steps:

.github/workflows/reference_resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
python-version: ['3.9']
22+
python-version: ['3.10']
2323
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
2424
steps:
2525
- name: Setup conda env

.github/workflows/windows_wheel.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,74 @@ jobs:
6060
# The BUILD_AGAINST_ALL_FFMPEG_FROM_S3 var, needed to build the wheel, is
6161
# set in vc_env_helper.bat Couldn't find a way to set it from here.
6262
build-command: "python -m build --wheel -vvv --no-isolation"
63+
64+
install-and-test:
65+
runs-on: windows-latest
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
python-version: ['3.10']
70+
# TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing
71+
# bad parameters.
72+
# See https://github.com/pytorch/torchcodec/pull/806
73+
ffmpeg-version-for-tests: ['4.4.2', '6.1.1', '7.0.1']
74+
needs: build
75+
steps:
76+
- uses: actions/download-artifact@v4
77+
with:
78+
name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_x64
79+
path: pytorch/torchcodec/dist/
80+
- name: Setup conda env
81+
uses: conda-incubator/setup-miniconda@v2
82+
with:
83+
auto-update-conda: true
84+
miniconda-version: "latest"
85+
activate-environment: test
86+
python-version: ${{ matrix.python-version }}
87+
- name: Update pip
88+
run: python -m pip install --upgrade pip
89+
- name: Install PyTorch
90+
run: |
91+
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
92+
- name: Install torchcodec from the wheel
93+
run: |
94+
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
95+
echo Installing $wheel_path
96+
python -m pip install $wheel_path -vvv
97+
- name: Check out repo
98+
uses: actions/checkout@v3
99+
- name: Install ffmpeg, post build
100+
run: |
101+
# Ideally we would have checked for that before installing the wheel,
102+
# but we need to checkout the repo to access this file, and we don't
103+
# want to checkout the repo before installing the wheel to avoid any
104+
# side-effect. It's OK.
105+
source packaging/helpers.sh
106+
assert_ffmpeg_not_installed
107+
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
108+
ffmpeg -version
109+
- name: Test torchcodec import after FFmpeg installation
110+
run: |
111+
echo "Testing torchcodec import after FFmpeg is installed and PATH is updated..."
112+
python -c "import torchcodec; print('TorchCodec import successful!')"
113+
- name: Install test dependencies
114+
run: |
115+
# Ideally we would find a way to get those dependencies from pyproject.toml
116+
python -m pip install numpy pytest pillow
117+
- name: Delete the src/ folder just for fun
118+
run: |
119+
# The only reason we checked-out the repo is to get access to the
120+
# tests. We don't care about the rest. Out of precaution, we delete
121+
# the src/ folder to be extra sure that we're running the code from
122+
# the installed wheel rather than from the source.
123+
# This is just to be extra cautious and very overkill because a)
124+
# there's no way the `torchcodec` package from src/ can be found from
125+
# the PythonPath: the main point of `src/` is precisely to protect
126+
# against that and b) if we ever were to execute code from
127+
# `src/torchcodec`, it would fail loudly because the built .so files
128+
# aren't present there.
129+
rm -r src/
130+
ls
131+
- name: Run Python tests
132+
run: |
133+
pytest test -vvv

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The following table indicates the compatibility between versions of
130130

131131
| `torchcodec` | `torch` | Python |
132132
| ------------------ | ------------------ | ------------------- |
133-
| `main` / `nightly` | `main` / `nightly` | `>=3.9`, `<=3.13` |
133+
| `main` / `nightly` | `main` / `nightly` | `>=3.10`, `<=3.13` |
134134
| `0.6` | `2.8` | `>=3.9`, `<=3.13` |
135135
| `0.5` | `2.7` | `>=3.9`, `<=3.13` |
136136
| `0.4` | `2.7` | `>=3.9`, `<=3.13` |

benchmarks/decoders/benchmark_decoders_library.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def decode_first_n_frames(self, video_file, n):
4747
def decode_first_n_frames_description(self, n) -> str:
4848
return f"first {n} frames"
4949

50+
def init_decode_and_resize(self):
51+
pass
52+
5053
@abc.abstractmethod
5154
def decode_and_resize(self, video_file, pts_list, height, width, device):
5255
pass
@@ -107,9 +110,12 @@ def __init__(self, backend):
107110
self._backend = backend
108111
self._print_each_iteration_time = False
109112
import torchvision # noqa: F401
110-
from torchvision.transforms import v2 as transforms_v2
111113

112114
self.torchvision = torchvision
115+
116+
def init_decode_and_resize(self):
117+
from torchvision.transforms import v2 as transforms_v2
118+
113119
self.transforms_v2 = transforms_v2
114120

115121
def decode_frames(self, video_file, pts_list):
@@ -267,6 +273,7 @@ def __init__(
267273
self._color_conversion_library = color_conversion_library
268274
self._device = device
269275

276+
def init_decode_and_resize(self):
270277
from torchvision.transforms import v2 as transforms_v2
271278

272279
self.transforms_v2 = transforms_v2
@@ -379,6 +386,7 @@ def __init__(
379386
self._seek_mode = seek_mode
380387
self._stream_index = int(stream_index) if stream_index else None
381388

389+
def init_decode_and_resize(self):
382390
from torchvision.transforms import v2 as transforms_v2
383391

384392
self.transforms_v2 = transforms_v2
@@ -443,6 +451,7 @@ def __init__(
443451
self._device = device
444452
self._seek_mode = seek_mode
445453

454+
def init_decode_and_resize(self):
446455
from torchvision.transforms import v2 as transforms_v2
447456

448457
self.transforms_v2 = transforms_v2
@@ -546,10 +555,12 @@ def __init__(self, stream_index: str | None = None):
546555

547556
self.torchaudio = torchaudio
548557

558+
self._stream_index = int(stream_index) if stream_index else None
559+
560+
def init_decode_and_resize(self):
549561
from torchvision.transforms import v2 as transforms_v2
550562

551563
self.transforms_v2 = transforms_v2
552-
self._stream_index = int(stream_index) if stream_index else None
553564

554565
def decode_frames(self, video_file, pts_list):
555566
stream_reader = self.torchaudio.io.StreamReader(src=video_file)
@@ -883,6 +894,7 @@ def run_benchmarks(
883894

884895
if dataloader_parameters:
885896
bp = dataloader_parameters.batch_parameters
897+
decoder.init_decode_and_resize()
886898
description = (
887899
f"concurrency {bp.num_threads}"
888900
f"batch {bp.batch_size}"

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ def _build_all_extensions_with_cmake(self):
135135
["cmake", str(_ROOT_DIR)] + cmake_args, cwd=self.build_temp
136136
)
137137
print("Calling cmake --build", flush=True)
138-
subprocess.check_call(["cmake", "--build", "."], cwd=self.build_temp)
138+
subprocess.check_call(
139+
["cmake", "--build", ".", "--config", cmake_build_type], cwd=self.build_temp
140+
)
139141
print("Calling cmake --install", flush=True)
140-
subprocess.check_call(["cmake", "--install", "."], cwd=self.build_temp)
142+
subprocess.check_call(
143+
["cmake", "--install", ".", "--config", cmake_build_type],
144+
cwd=self.build_temp,
145+
)
141146

142147
def copy_extensions_to_source(self):
143148
"""Copy built extensions from temporary folder back into source tree.
@@ -156,7 +161,7 @@ def copy_extensions_to_source(self):
156161
# https://stackoverflow.com/a/2339910
157162
extensions = ["dylib", "so"]
158163
elif sys.platform in ("win32", "cygwin"):
159-
extensions = ["dll"]
164+
extensions = ["dll", "pyd"]
160165
else:
161166
raise NotImplementedError(f"Platform {sys.platform} is not supported")
162167

src/torchcodec/_core/CMakeLists.txt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,6 @@ function(make_torchcodec_sublibrary
5353
# Avoid adding the "lib" prefix which we already add explicitly.
5454
set_target_properties(${library_name} PROPERTIES PREFIX "")
5555

56-
if(WIN32)
57-
# On Windows, the built artifacts are put in Release/Debug
58-
# subdirectories by default. We want to avoid that, otherwise our
59-
# install() step would not know where to find those.
60-
set_target_properties(${library_name} PROPERTIES
61-
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
62-
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
63-
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
64-
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
65-
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
66-
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
67-
)
68-
endif()
69-
7056
target_link_libraries(
7157
${library_name}
7258
PUBLIC
@@ -84,16 +70,17 @@ function(make_torchcodec_libraries
8470
#
8571
# 1. libtorchcodec_coreN.{ext}: Base library which contains the
8672
# implementation of VideoDecoder and everything VideoDecoder needs. On
87-
# Linux, {ext} is so. On Mac, it is dylib.
73+
# Linux, {ext} is so. On Mac, it is dylib. On Windows it's dll.
8874
#
8975
# 2. libtorchcodec_custom_opsN.{ext}: Implementation of the PyTorch custom
9076
# ops. Depends on libtorchcodec_coreN.{ext}. On Linux, {ext} is so.
91-
# On Mac, it is dylib.
77+
# On Mac, it is dylib. On Windows it's dll.
9278
#
9379
# 3. libtorchcodec_pybind_opsN.{ext}: Implementation of the pybind11 ops. We
9480
# keep these separate from the PyTorch custom ops because we have to
9581
# load these libraries separately on the Python side. Depends on
96-
# libtorchcodec_coreN.{ext}. On BOTH Linux and Mac {ext} is so.
82+
# libtorchcodec_coreN.{ext}. On BOTH Linux and Mac {ext} is so. On
83+
# Windows, it's pyd.
9784

9885
# 1. Create libtorchcodec_coreN.{ext}.
9986
set(core_library_name "libtorchcodec_core${ffmpeg_major_version}")
@@ -174,6 +161,14 @@ function(make_torchcodec_libraries
174161
"${pybind_ops_sources}"
175162
"${pybind_ops_dependencies}"
176163
)
164+
165+
if(WIN32)
166+
# On Windows, we need to set the suffix to .pyd so that Python can
167+
# import the shared library as a module. Just setting the MODULE type
168+
# isn't enough.
169+
set_target_properties(${pybind_ops_library_name} PROPERTIES SUFFIX ".pyd")
170+
endif()
171+
177172
# pybind11 limits the visibility of symbols in the shared library to prevent
178173
# stray initialization of py::objects. The rest of the object code must
179174
# match. See:
@@ -223,7 +218,7 @@ function(make_torchcodec_libraries
223218
install(
224219
TARGETS ${all_libraries}
225220
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}
226-
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} # For Windows DLLs
221+
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} # For Windows
227222
)
228223

229224
endfunction()

0 commit comments

Comments
 (0)