From b0104921ca44b93b1d45314c77177cbc1a2217cb Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Mon, 11 Nov 2024 12:55:32 +0000 Subject: [PATCH] Update GitHub builds to use uv. --- .../continuous-integration-documentation.yml | 20 +++---- ...tinuous-integration-quality-unit-tests.yml | 56 +++++++++---------- ...nuous-integration-static-type-checking.yml | 15 ++--- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/.github/workflows/continuous-integration-documentation.yml b/.github/workflows/continuous-integration-documentation.yml index aafb88f..251ac1d 100644 --- a/.github/workflows/continuous-integration-documentation.yml +++ b/.github/workflows/continuous-integration-documentation.yml @@ -7,8 +7,8 @@ jobs: name: ${{ matrix.os }} - Python ${{ matrix.python-version }} strategy: matrix: - os: [ubuntu-22.04] - python-version: [3.11] + os: [ubuntu-latest] + python-version: [3.13] fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -22,29 +22,27 @@ jobs: echo "COLOUR_SCIENCE__DOCUMENTATION_BUILD=True" >> $GITHUB_ENV shell: bash - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Dependencies run: | sudo apt-get update sudo apt-get --yes install graphviz graphviz-dev latexmk texlive-full - - name: Install Poetry + - name: Install uv run: | - curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - - echo "$HOME/.poetry/bin" >> $GITHUB_PATH + pip install uv shell: bash - name: Install Package Dependencies run: | - poetry run python -m pip install --upgrade pip - poetry install - poetry run python -c "import imageio;imageio.plugins.freeimage.download()" + uv sync --all-extras --no-dev + uv run python -c "import imageio;imageio.plugins.freeimage.download()" shell: bash - name: Build Documentation run: | - poetry run invoke docs + uv run invoke docs shell: bash - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ${{ env.CI_PACKAGE }}-plots path: | diff --git a/.github/workflows/continuous-integration-quality-unit-tests.yml b/.github/workflows/continuous-integration-quality-unit-tests.yml index c5de82b..81772e2 100644 --- a/.github/workflows/continuous-integration-quality-unit-tests.yml +++ b/.github/workflows/continuous-integration-quality-unit-tests.yml @@ -7,8 +7,8 @@ jobs: name: ${{ matrix.os }} - Python ${{ matrix.python-version }} strategy: matrix: - os: [macOS-latest, ubuntu-22.04, windows-latest] - python-version: [3.9, "3.10", 3.11, 3.12] + os: [macOS-latest, ubuntu-latest, windows-latest] + python-version: ["3.10", 3.11, 3.12, 3.13] fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -20,60 +20,58 @@ jobs: echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV echo "MPLBACKEND=AGG" >> $GITHUB_ENV + # https://github.com/scipy/scipy/issues/20613 + echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV shell: bash - - name: Set up Python 3.9 for Pre-Commit - uses: actions/setup-python@v4 + - name: Set up Python 3.10 for Pre-Commit + uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: "3.10" - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install Dependencies (macOS) + if: matrix.os == 'macOS-latest' + run: | + brew install freeimage + # TODO: Drop when https://github.com/imageio/imageio/issues/628 is addressed + echo "IMAGEIO_FREEIMAGE_LIB=/opt/homebrew/Cellar/freeimage/3.18.0/lib/libfreeimage.3.18.0.dylib" >> $GITHUB_ENV - name: Install Dependencies (Ubuntu) - if: matrix.os == 'ubuntu-22.04' + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get --yes install graphviz graphviz-dev - - name: Install Poetry - run: | - curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - - echo "$HOME/.poetry/bin" >> $GITHUB_PATH - shell: bash - - name: Install Package Dependencies (Ubuntu) - if: matrix.os == 'ubuntu-22.04' + - name: Install uv run: | - poetry run python -m pip install --upgrade pip - poetry install - poetry run python -c "import imageio;imageio.plugins.freeimage.download()" + pip install uv shell: bash - - name: Install Package Dependencies (macOS & Windows) - if: matrix.os == 'macOS-latest' || matrix.os == 'windows-latest' + - name: Install Package Dependencies run: | - poetry run python -m pip install --upgrade pip - poetry install --without graphviz - poetry run python -c "import imageio;imageio.plugins.freeimage.download()" + uv sync --all-extras --no-dev + uv run python -c "import imageio;imageio.plugins.freeimage.download()" shell: bash - name: Install OpenImageIO (macOs) - if: matrix.os == 'macOS-latest' && matrix.python-version == '3.11' + if: matrix.os == 'macOS-latest' && matrix.python-version == '3.12' run: | brew install openimageio - ls /usr/local/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/ - ln -s /usr/local/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/OpenImageIO*.so /Library/Frameworks/Python.framework/Versions/${{ matrix.python-version }}/lib/python${{ matrix.python-version }}/site-packages/OpenImageIO.so + ln -s /opt/homebrew/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/OpenImageIO*.so ./.venv/lib/python3.12/site-packages/OpenImageIO.so + uv run python -c "import OpenImageIO;print(OpenImageIO.__version__)" shell: bash - name: Pre-Commit (All Files) run: | - poetry run pre-commit run --all-files + uv run pre-commit run --all-files shell: bash - name: Test Optimised Python Execution run: | - poetry run python -OO -c "import $CI_PACKAGE" + uv run python -OO -c "import $CI_PACKAGE" shell: bash - name: Test with Pytest run: | - poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE + uv run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE shell: bash - name: Upload Coverage to coveralls.io if: matrix.os == 'macOS-latest' && matrix.python-version == '3.12' run: | - if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi + if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else uv run coveralls; fi shell: bash diff --git a/.github/workflows/continuous-integration-static-type-checking.yml b/.github/workflows/continuous-integration-static-type-checking.yml index 64dadf2..295179e 100644 --- a/.github/workflows/continuous-integration-static-type-checking.yml +++ b/.github/workflows/continuous-integration-static-type-checking.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [macOS-latest] - python-version: [3.12] + python-version: [3.13] fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -18,18 +18,19 @@ jobs: echo "CI_PACKAGE=colour" >> $GITHUB_ENV shell: bash - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Dependencies (macOS) if: matrix.os == 'macOS-latest' run: | - brew install graphviz - export GRAPHVIZ_DIR="/usr/local/Cellar/graphviz/" - pip install pygraphviz --global-option=build_ext --global-option="-I$GRAPHVIZ_DIR/include" --global-option="-L$GRAPHVIZ_DIR/lib" + brew install freeimage graphviz + pip install --no-cache-dir --config-settings="--global-option=build_ext" --config-settings="--global-option=-I$(brew --prefix graphviz)/include/" --config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" pygraphviz + # TODO: Drop when https://github.com/imageio/imageio/issues/628 is addressed + echo "IMAGEIO_FREEIMAGE_LIB=/opt/homebrew/Cellar/freeimage/3.18.0/lib/libfreeimage.3.18.0.dylib" >> $GITHUB_ENV - name: Install Package Dependencies run: | - pip install -r requirements.txt + cat requirements.txt | grep -Eo '(^[^#]+)' | xargs -n 1 pip install || true - name: Static Type Checking run: | - pyright --skipunannotated + pyright --threads --skipunannotated