From 04ba47dcd299cb60e8e8775bccca02ac77da3a79 Mon Sep 17 00:00:00 2001 From: "Patrick M. Niedzielski" Date: Fri, 16 Oct 2026 14:52:22 -0400 Subject: [PATCH] CI: Use uv to manage Python environments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch replaces the manual Python and pip munging that we do in our build CI, using `actions/setup-python`, `python3 -m venv`, and `pip`, with the newer `uv` command. This has a few benefits: 1. We no longer have to manage the venv location ourselves. `uv` handles this for us. 2. We aren’t limited to the Python versions that are available in Ubuntu at any particular version. With `uv`, we can continue to support older versions of Python while we support newer versions. 3. Familiarity. It seems like the Python community is pretty quickly switching over to using `uv` to manage interpreter versions and dependencies. Signed-off-by: Patrick M. Niedzielski --- .github/workflows/build.yaml | 45 ++++++++++++++---------------- .github/workflows/build_wheels.yml | 5 +++- .github/workflows/codeql.yaml | 13 ++++----- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 169eb84..f21de8e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -110,17 +110,15 @@ jobs: key: ${{ needs.blazingmq-dependency.outputs.deps_cache_key }} - name: Restore cached BlazingMQ build artifacts run: tar xzf blazingmq_artifacts.tar.gz - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v7 + - name: Set up uv with Python ${{ matrix.python-version }} + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 with: python-version: ${{ matrix.python-version }} - - name: Create virtual environment - run: | - python3 -m venv venv + activate-environment: true + venv-path: venv - name: Install Python dependencies run: | - ./venv/bin/python -m pip install --upgrade pip - ./venv/bin/python -m pip install -r requirements-dev.txt + uv pip install -r requirements-dev.txt - name: Install package manager dependencies run: | sudo apt-get update @@ -165,7 +163,9 @@ jobs: PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig:./blazingmq_artifacts/lib64/pkgconfig run: | ulimit -c unlimited - make test-build && make test-install && make check + make test-build \ + && make test-install PIP_INSTALL="uv pip install" \ + && make check - name: Print backtrace from core dump if: failure() run: | @@ -200,23 +200,21 @@ jobs: key: ${{ needs.blazingmq-dependency.outputs.deps_cache_key }} - name: Restore cached BlazingMQ build artifacts run: tar xzf blazingmq_artifacts.tar.gz - - name: Set up Python 3.14 - uses: actions/setup-python@v7 + - name: Set up uv with Python 3.14 + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 with: python-version: "3.14" - - name: Create virtual environment - run: | - python3 -m venv venv + activate-environment: true + venv-path: venv - name: Install Python dependencies run: | - ./venv/bin/python -m pip install --upgrade pip - ./venv/bin/python -m pip install -r requirements-dev.txt + uv pip install -r requirements-dev.txt - name: Set up dependencies run: sudo apt-get install clang-format - name: Install Package run: | - ./venv/bin/python -m pip install -e . + uv pip install -e . env: PREFIX: blazingmq_artifacts PYTHON: ./venv/bin/python @@ -250,17 +248,15 @@ jobs: key: ${{ needs.blazingmq-dependency.outputs.deps_cache_key }} - name: Restore cached BlazingMQ build artifacts run: tar xzf blazingmq_artifacts.tar.gz - - name: Set up Python - uses: actions/setup-python@v7 + - name: Set up uv with Python 3.14 + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 with: python-version: "3.14" - - name: Create virtual environment - run: | - python3 -m venv venv + activate-environment: true + venv-path: venv - name: Install Python dependencies run: | - ./venv/bin/python3 -m pip install --upgrade pip - ./venv/bin/python3 -m pip install -r requirements-dev.txt + uv pip install -r requirements-dev.txt - name: Setup Core Dumps config run: | sudo mkdir /cores @@ -290,7 +286,8 @@ jobs: run: | # Allow core dumps ulimit -c unlimited - make coverage-install && make coverage + make coverage-install PIP_INSTALL="uv pip install" \ + && make coverage - name: Stop BlazingMQ broker if: always() run: docker rm -f bmqbrkr diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index f323bf6..4808e21 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -28,10 +28,13 @@ jobs: with: persist-credentials: false + - name: Set up uv + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + - name: Build sdist env: BLAZINGMQ_PYTHON_NO_PKGCONFIG: '1' - run: pipx run build --sdist + run: uv build --sdist - uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 78ab612..1874522 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -147,19 +147,16 @@ jobs: - name: Restore cached BlazingMQ build artifacts run: tar xzf blazingmq_artifacts.tar.gz - - name: Set up Python - uses: actions/setup-python@v7 + - name: Set up uv with Python 3.14 + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 with: python-version: "3.14" - - - name: Create virtual environment - run: | - python3 -m venv venv + activate-environment: true + venv-path: venv - name: Install Python dependencies run: | - ./venv/bin/python -m pip install --upgrade pip - ./venv/bin/python -m pip install -r requirements-dev.txt + uv pip install -r requirements-dev.txt - name: Install package manager dependencies run: |