Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build wheel

on:
workflow_call:

jobs:
build-wheel:
name: "Build wheel ${{ matrix.py_build }} ${{ matrix.arch }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-13, windows-latest, windows-11-arm]
arch: [auto64]
py_build: ["cp39", "cp310", "cp311", "cp312", "cp313"]
include:
- os: ubuntu-24.04-arm
arch: aarch64
py_build: "cp39"
- os: ubuntu-24.04-arm
arch: aarch64
py_build: "cp310"
- os: ubuntu-24.04-arm
arch: aarch64
py_build: "cp311"
- os: ubuntu-24.04-arm
arch: aarch64
py_build: "cp312"
- os: ubuntu-24.04-arm
arch: aarch64
py_build: "cp313"

defaults:
run:
shell: ${{ (matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm') && 'msys2 {0}' || 'bash' }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install platform-specific requirements X64 (Windows)
if: runner.os == 'Windows' && runner.arch == 'X64'
uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
path-type: inherit
install: >-
mingw-w64-clang-x86_64-autotools
mingw-w64-clang-x86_64-toolchain
mingw-w64-clang-x86_64-nasm

- name: Install platform-specific requirements ARM64 (Windows)
if: runner.os == 'Windows' && runner.arch == 'ARM64'
uses: msys2/setup-msys2@v2
with:
msystem: CLANGARM64
path-type: inherit
install: >-
mingw-w64-clang-aarch64-autotools
mingw-w64-clang-aarch64-toolchain
mingw-w64-clang-aarch64-nasm

- name: Install platform-specific requirements (macOS)
if: runner.os == 'macOS'
run: brew install autoconf automake libtool nasm

- name: Run cibuildwheel
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
export CIBW_ENVIRONMENT="PKG_CONFIG_PATH='/project/build_dependencies/usr/local/lib/pkgconfig'"
else
PKG_CONFIG_PATH="$(pwd)/build_dependencies/usr/local/lib/pkgconfig"
if [[ "$RUNNER_OS" == "Windows" ]]; then
PKG_CONFIG_PATH=$(cygpath -w "$(pwd)/build_dependencies/usr/local/lib/pkgconfig")
fi
export CIBW_ENVIRONMENT="PKG_CONFIG_PATH='$PKG_CONFIG_PATH' MACOSX_DEPLOYMENT_TARGET='10.15'"
fi
pip install cibuildwheel delvewheel
cibuildwheel --output-dir dist
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: "${{ matrix.py_build }}-*"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair -w {dest_dir} {wheel}
CIBW_BEFORE_ALL_LINUX: |
if command -v yum >/dev/null 2>&1; then
yum install -y wget nasm meson
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache wget nasm meson
else
echo "No supported package manager found" >&2
exit 1
fi
./build_dependencies.sh
CIBW_BEFORE_ALL_WINDOWS: pip install meson && bash build_dependencies.sh
CIBW_BEFORE_ALL: |
pip install meson
./build_dependencies.sh
MSYS2_ENV_CONV_EXCL: "*"

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.py_build }}
path: dist
21 changes: 9 additions & 12 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@ on:
types: [published]

jobs:
call-build-wheel:
uses: ./.github/workflows/build_wheel.yml

publish-to-pypi:
name: Publish Package to PyPI
runs-on: ubuntu-latest
needs: call-build-wheel

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
- name: Download wheel artifact
uses: actions/download-artifact@v5
with:
python-version: '3.10'

- name: "Install build"
run: >-
pip install build
path: dist

- name: Build package
run: >-
python -m build

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
58 changes: 43 additions & 15 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,34 @@ on:
pull_request:

jobs:
call-build-wheel:
uses: ./.github/workflows/build_wheel.yml

run-tests:
name: "Test (${{matrix.os}}, Python ${{ matrix.python-version }})"
runs-on: ${{ matrix.os }}
needs: call-build-wheel

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest, macos-13, windows-latest, windows-11-arm]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- python-version: "3.9"
py_build: "cp39"
- python-version: "3.10"
py_build: "cp310"
- python-version: "3.11"
py_build: "cp311"
- python-version: "3.12"
py_build: "cp312"
- python-version: "3.13"
py_build: "cp313"
exclude:
- os: windows-11-arm
python-version: "3.9"
- os: windows-11-arm
python-version: "3.10"

steps:
- name: Checkout code
Expand All @@ -25,24 +45,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python requirements
run: pip install --upgrade --upgrade-strategy eager .[dev]
- name: Download wheel artifact
uses: actions/download-artifact@v4
with:
name: wheel-${{ matrix.os }}-auto64-${{ matrix.py_build }}

- name: Install platform-specific requirements (Ubuntu)
if: runner.os == 'Linux'
- name: Download wheels
run: |
sudo apt update
sudo apt install ffmpeg
pip download videotimestamps[dev] -d wheelhouse

- name: Install platform-specific requirements (macOS)
if: runner.os == 'macOS'
- name: Delete videotimestamps wheel from PyPI
shell: bash
run: |
brew install ffmpeg
find wheelhouse -name 'videotimestamps-*.whl' -delete

- name: Install platform-specific requirements (Windows)
if: runner.os == 'Windows'
- name: Install wheel
run: |
choco install ffmpeg --no-progress --yes
pip install videotimestamps[dev] --no-index --find-links . --find-links wheelhouse

- name: Run tests
run: |
Expand All @@ -56,13 +75,22 @@ jobs:
run: |
ruff check

- name: Delete
shell: bash
run: |
rm -rf video_timestamps

- name: Run coverage
run: |
coverage run --source=video_timestamps,tests -m pytest

- name: Generate coverage report
run: |
coverage run -m pytest
coverage xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
disable_file_fixes: true # temp patch for https://github.com/getsentry/prevent-cli/issues/101
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@ dist/
.idea/
.vscode/
venv/
.coverage
.venv/
.coverage
*.bsindex

# Meson
/subprojects/*
!/subprojects/*.wrap
!/subprojects/packagefiles

# Dependencies
/build_dependencies/*
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ It also help to convert a frame to a time in milliseconds and vice-versa.
pip install VideoTimestamps
```

## Dependencies
- [ffprobe](https://ffmpeg.org/download.html)

## How to use it?
See the [example file](./examples/get_timestamps.py).

## How to build the project from scratch?
### Unix
1. Run: `./build_dependencies.sh`
2. Run: `export PKG_CONFIG_PATH="$(pwd)/build_dependencies/usr/local/lib/pkgconfig"`
3. Run `python -m build` to create a wheel. To perform an editable install, first run `pip install meson meson-python` and then `pip install --no-build-isolation --editable .`
### Windows
1. In MSYS2 (any environment), run `./build_dependencies.sh`
2. In Windows CMD, run `C:\msys64\usr\bin\env.exe MSYSTEM=CLANG64 MSYS2_PATH_TYPE=inherit /usr/bin/bash -l` (replace the **MSYSTEM** value with the one you used in the first step)
3. Run `export PKG_CONFIG_PATH="$(cygpath -w "$(pwd)/build_dependencies/usr/local/lib/pkgconfig")"`
4. Repeat step 3 from the Unix section. Verify that `python` refers to your Windows installation, not the MSYS2 one, by running `which python`. If it points to the MSYS2 Python, use the absolute path to your Windows Python installation instead.
Loading
Loading