diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 5f864a9b6..c09c1b038 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -22,8 +22,9 @@ jobs: - name: Checkout uses: actions/checkout@v7 - name: Python - uses: actions/setup-python@v6 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: + activate-environment: true python-version: "3.14" - name: Linters run: make lint @@ -50,10 +51,10 @@ jobs: name: Checkout - name: Python ${{ matrix.config.python }} - uses: actions/setup-python@v6 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: + activate-environment: true python-version: ${{ matrix.config.python }} - allow-prereleases: true - name: OS Packages run: | @@ -163,27 +164,22 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 - - name: Set up host Python 3.12 - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - name: Set up host Python 3.14t - uses: actions/setup-python@v6 - with: - python-version: "3.14t" + - name: Set up uv + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install build tooling run: | - for py in python3.12 python3.14t; do - $py -m pip install -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel - done + uv venv --seed --python 3.12 .venv-3.12 + uv venv --seed --python 3.14t .venv-3.14t + uv pip install --python .venv-3.12/bin/python -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel + uv pip install --python .venv-3.14t/bin/python -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel # patchelf 0.18 (ubuntu-24.04's system version) corrupts ELF files # with large p_align; pin <0.18 for auditwheel to use. - python3.12 -m pip install -U ziglang auditwheel 'patchelf<0.18' + uv pip install --python .venv-3.12/bin/python -U ziglang auditwheel 'patchelf<0.18' - name: Cross-compile armv7l wheels with zig env: - HOST_PY312: python3.12 - HOST_PY314T: python3.14t - TOOLS_PY: python3.12 + HOST_PY312: .venv-3.12/bin/python + HOST_PY314T: .venv-3.14t/bin/python + TOOLS_PY: .venv-3.12/bin/python run: bash scripts/build-armv7l-cross.sh - name: Set up QEMU uses: docker/setup-qemu-action@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 074c06636..eb4b4c294 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,12 +8,13 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: + activate-environment: true python-version: "3.14" - name: Build source package run: | - pip install -U cython setuptools + uv pip install -U cython setuptools python scripts/fetch-vendor.py --config-file scripts/ffmpeg-latest.json /tmp/vendor PKG_CONFIG_PATH=/tmp/vendor/lib/pkgconfig python setup.py sdist - name: Upload source package @@ -42,8 +43,9 @@ jobs: arch: ARM64 steps: - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: + activate-environment: true python-version: "3.14" - name: Set Minimum MacOS Target if: runner.os == 'macOS' @@ -64,10 +66,11 @@ jobs: CIBW_ENVIRONMENT_WINDOWS: INCLUDE=C:\\cibw\\vendor\\include LIB=C:\\cibw\\vendor\\lib PYAV_SKIP_TESTS=unicode_filename CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair --add-path C:\cibw\vendor\bin -w {dest_dir} {wheel} CIBW_BUILD: "cp312* cp314t*" + CIBW_BUILD_FRONTEND: uv CIBW_TEST_COMMAND: mv {project}/av {project}/av.disabled && python -m pytest {package}/tests && mv {project}/av.disabled {project}/av CIBW_TEST_REQUIRES: pytest numpy run: | - pip install cibuildwheel delvewheel + uv pip install cibuildwheel delvewheel cibuildwheel --output-dir dist shell: bash - name: Upload wheels @@ -83,27 +86,22 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 - - name: Set up host Python 3.12 - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - name: Set up host Python 3.14t - uses: actions/setup-python@v6 - with: - python-version: "3.14t" + - name: Set up uv + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install build tooling run: | - for py in python3.12 python3.14t; do - $py -m pip install -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel - done + uv venv --seed --python 3.12 .venv-3.12 + uv venv --seed --python 3.14t .venv-3.14t + uv pip install --python .venv-3.12/bin/python -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel + uv pip install --python .venv-3.14t/bin/python -U "cython>=3.1.0,<4" "setuptools>=77.0" wheel # patchelf 0.18 (ubuntu-24.04's system version) corrupts ELF files # with large p_align; pin <0.18 for auditwheel to use. - python3.12 -m pip install -U ziglang auditwheel 'patchelf<0.18' + uv pip install --python .venv-3.12/bin/python -U ziglang auditwheel 'patchelf<0.18' - name: Cross-compile armv7l wheels with zig env: - HOST_PY312: python3.12 - HOST_PY314T: python3.14t - TOOLS_PY: python3.12 + HOST_PY312: .venv-3.12/bin/python + HOST_PY314T: .venv-3.14t/bin/python + TOOLS_PY: .venv-3.12/bin/python run: bash scripts/build-armv7l-cross.sh - name: Upload wheels uses: actions/upload-artifact@v6 diff --git a/Makefile b/Makefile index 4fb974eb2..60edd9a98 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ LDFLAGS ?= "" CFLAGS ?= "-O0 -Wno-unreachable-code" PYAV_PYTHON ?= python -PYAV_PIP ?= pip +PYAV_PIP ?= uv pip PYTHON := $(PYAV_PYTHON) PIP := $(PYAV_PIP) @@ -29,11 +29,11 @@ fate-suite: rsync -vrltLW rsync://fate-suite.ffmpeg.org/fate-suite/ tests/assets/fate-suite/ lint: - $(PIP) install -U ruff isort pillow numpy mypy==2.1.0 pytest + $(PIP) install --group lint ruff format --check av examples tests setup.py isort --check-only --diff av examples tests mypy av tests test: - $(PIP) install --upgrade cython numpy pillow pytest + $(PIP) install --group test $(PYTHON) -m pytest diff --git a/docs/Makefile b/docs/Makefile index e12e6f701..b6467584d 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,6 +1,6 @@ SPHINXOPTS = BUILDDIR = _build -PYAV_PIP ?= pip +PYAV_PIP ?= uv pip PIP := $(PYAV_PIP) ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) . diff --git a/pyproject.toml b/pyproject.toml index db9cc5b80..0c6fb718f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,3 +53,10 @@ homepage = "https://pyav.basswood.io" profile = "black" known_first_party = ["av"] skip = ["av/__init__.py"] + +[tool.uv] +prerelease = "allow" + +[dependency-groups] +test = ["cython>=3.3.0,<4", "numpy", "pillow", "pytest"] +lint = ["ruff", "isort", "mypy==2.1.0", {include-group = "test"}] diff --git a/scripts/activate.sh b/scripts/activate.sh index 2948b758c..49f79ba2b 100755 --- a/scripts/activate.sh +++ b/scripts/activate.sh @@ -43,7 +43,8 @@ if [[ "$PYAV_PYTHON" == *pypy* ]]; then fi export PYAV_PYTHON -export PYAV_PIP="${PYAV_PIP-$PYAV_PYTHON -m pip}" +export UV_PYTHON="$PYAV_PYTHON" +export PYAV_PIP="${PYAV_PIP-uv pip}" if [[ "$GITHUB_ACTION" ]]; then @@ -64,8 +65,7 @@ print("{}{}.{}".format(platform.python_implementation().lower(), *sys.version_in if [[ ! -e "$PYAV_VENV/bin/python" ]]; then mkdir -p "$PYAV_VENV" - virtualenv -p "$PYAV_PYTHON" "$PYAV_VENV" - "$PYAV_VENV/bin/pip" install --upgrade pip setuptools + uv venv -p "$PYAV_PYTHON" "$PYAV_VENV" fi if [[ -e "$PYAV_VENV/bin/activate" ]]; then