From 481ccefad062f8a813908b5f80bfd8a5109f0b92 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 26 Dec 2023 16:05:09 +1100 Subject: [PATCH] Added ImageType as alias for Image.Image --- .appveyor.yml | 92 ----------- .github/workflows/cifuzz.yml | 60 ------- .github/workflows/docs.yml | 57 ------- .github/workflows/lint.yml | 54 ------- .github/workflows/release-drafter.yml | 28 ---- .github/workflows/stale.yml | 31 ---- .github/workflows/test-cygwin.yml | 160 ------------------- .github/workflows/test-docker.yml | 46 ------ .github/workflows/test-mingw.yml | 91 ----------- .github/workflows/test-valgrind.yml | 56 ------- .github/workflows/test-windows.yml | 219 -------------------------- .github/workflows/test.yml | 140 ---------------- .github/workflows/wheels.yml | 195 ----------------------- .travis.yml | 52 ------ Tests/oss-fuzz/test_fuzzers.py | 4 +- Tests/test_file_eps.py | 4 +- Tests/test_file_psd.py | 6 +- pyproject.toml | 2 +- src/PIL/Image.py | 8 +- src/PIL/__init__.py | 4 +- src/PIL/_deprecate.py | 2 +- 21 files changed, 17 insertions(+), 1294 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .github/workflows/cifuzz.yml delete mode 100644 .github/workflows/docs.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/release-drafter.yml delete mode 100644 .github/workflows/stale.yml delete mode 100644 .github/workflows/test-cygwin.yml delete mode 100644 .github/workflows/test-mingw.yml delete mode 100644 .github/workflows/test-valgrind.yml delete mode 100644 .github/workflows/test-windows.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/wheels.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 0f5dea9c515..00000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,92 +0,0 @@ -version: '{build}' -clone_folder: c:\pillow -init: -- ECHO %PYTHON% -#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) -# Uncomment previous line to get RDP access during the build. - -environment: - EXECUTABLE: python.exe - TEST_OPTIONS: - DEPLOY: YES - matrix: - - PYTHON: C:/Python312 - ARCHITECTURE: x86 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - - PYTHON: C:/Python38-x64 - ARCHITECTURE: x64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - -install: -- '%PYTHON%\%EXECUTABLE% --version' -- '%PYTHON%\%EXECUTABLE% -m pip install --upgrade pip' -- curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip -- 7z x pillow-test-images.zip -oc:\ -- xcopy /S /Y c:\test-images-main\* c:\pillow\tests\images -- curl -fsSL -o nasm-win64.zip https://raw.githubusercontent.com/python-pillow/pillow-depends/main/nasm-2.16.01-win64.zip -- 7z x nasm-win64.zip -oc:\ -- choco install ghostscript --version=10.0.0.20230317 -- path c:\nasm-2.16.01;C:\Program Files\gs\gs10.00.0\bin;%PATH% -- cd c:\pillow\winbuild\ -- ps: | - c:\python38\python.exe c:\pillow\winbuild\build_prepare.py -v --depends=C:\pillow-depends\ - c:\pillow\winbuild\build\build_dep_all.cmd - $host.SetShouldExit(0) -- path C:\pillow\winbuild\build\bin;%PATH% - -build_script: -- cd c:\pillow -- winbuild\build\build_env.cmd -- '%PYTHON%\%EXECUTABLE% -m pip install -v -C raqm=vendor -C fribidi=vendor .' -- '%PYTHON%\%EXECUTABLE% selftest.py --installed' - -test_script: -- cd c:\pillow -- '%PYTHON%\%EXECUTABLE% -m pip install pytest pytest-cov pytest-timeout defusedxml numpy olefile pyroma' -- c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE% -- '%PYTHON%\%EXECUTABLE% -c "from PIL import Image"' -- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests' -#- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' TODO TEST_OPTIONS with pytest? - -after_test: -- curl -Os https://uploader.codecov.io/latest/windows/codecov.exe -- .\codecov.exe --file coverage.xml --name %PYTHON% --flags AppVeyor - -matrix: - fast_finish: true - -cache: -- '%LOCALAPPDATA%\pip\Cache' - -artifacts: -- path: pillow\*.egg - name: egg -- path: pillow\*.whl - name: wheel - -before_deploy: - - cd c:\pillow - - '%PYTHON%\%EXECUTABLE% -m pip wheel -v -C raqm=vendor -C fribidi=vendor .' - - ps: Get-ChildItem .\*.whl | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - -deploy: - provider: S3 - region: us-west-2 - access_key_id: AKIAIRAXC62ZNTVQJMOQ - secret_access_key: - secure: Hwb6klTqtBeMgxAjRoDltiiqpuH8xbwD4UooDzBSiCWXjuFj1lyl4kHgHwTCCGqi - bucket: pillow-nightly - folder: win/$(APPVEYOR_BUILD_NUMBER)/ - artifact: /.*egg|wheel/ - on: - APPVEYOR_REPO_NAME: python-pillow/Pillow - branch: main - deploy: YES - - -# Uncomment the following lines to get RDP access after the build/test and block for -# up to the timeout limit (~1hr) -# -#on_finish: -#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml deleted file mode 100644 index eb73fc6a7cd..00000000000 --- a/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: CIFuzz - -on: - push: - branches: - - "**" - paths: - - ".github/workflows/cifuzz.yml" - - "**.c" - - "**.h" - pull_request: - paths: - - ".github/workflows/cifuzz.yml" - - "**.c" - - "**.h" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - Fuzzing: - runs-on: ubuntu-latest - steps: - - name: Build Fuzzers - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'pillow' - language: python - dry-run: false - - name: Run Fuzzers - id: run - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: 'pillow' - fuzz-seconds: 600 - language: python - dry-run: false - - name: Upload New Crash - uses: actions/upload-artifact@v4 - if: failure() && steps.build.outcome == 'success' - with: - name: artifacts - path: ./out/artifacts - - name: Upload Legacy Crash - uses: actions/upload-artifact@v4 - if: steps.run.outcome == 'success' - with: - name: crash - path: ./out/crash* - - name: Fail on legacy crash - if: success() - run: | - [ ! -e out/crash-* ] - echo No legacy crash detected diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9fe345c8a3d..00000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Docs - -on: - push: - branches: - - "**" - paths: - - ".github/workflows/docs.yml" - - "docs/**" - pull_request: - paths: - - ".github/workflows/docs.yml" - - "docs/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - FORCE_COLOR: 1 - -jobs: - build: - - runs-on: ubuntu-latest - name: Docs - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - cache: pip - cache-dependency-path: ".ci/*.sh" - - - name: Build system information - run: python3 .github/workflows/system-info.py - - - name: Install Linux dependencies - run: | - .ci/install.sh - env: - GHA_PYTHON_VERSION: "3.x" - - - name: Build - run: | - .ci/build.sh - - - name: Docs - run: | - make doccheck diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 9069fc615f3..00000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Lint - -on: [push, pull_request, workflow_dispatch] - -env: - FORCE_COLOR: 1 - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - - runs-on: ubuntu-latest - - name: Lint - - steps: - - uses: actions/checkout@v4 - - - name: pre-commit cache - uses: actions/cache@v3 - with: - path: ~/.cache/pre-commit - key: lint-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} - restore-keys: | - lint-pre-commit- - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - cache: pip - cache-dependency-path: "setup.py" - - - name: Build system information - run: python3 .github/workflows/system-info.py - - - name: Install dependencies - run: | - python3 -m pip install -U pip - python3 -m pip install -U tox - - - name: Lint - run: tox -e lint - env: - PRE_COMMIT_COLOR: always - - - name: Mypy - run: tox -e mypy diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml deleted file mode 100644 index 8fc7bd3799d..00000000000 --- a/.github/workflows/release-drafter.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release drafter - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - update_release_draft: - permissions: - contents: write # for release-drafter/release-drafter to create a github release - pull-requests: write # for release-drafter/release-drafter to add label to PR - if: github.repository == 'python-pillow/Pillow' - runs-on: ubuntu-latest - steps: - # Drafts your next release notes as pull requests are merged into "main" - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 545c2e3644a..00000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Close stale issues - -on: - schedule: - - cron: "10 0 * * *" - workflow_dispatch: - -permissions: - issues: write - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - stale: - if: github.repository_owner == 'python-pillow' - - runs-on: ubuntu-latest - - steps: - - name: "Check issues" - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - only-labels: "Awaiting OP Action" - close-issue-message: "Closing this issue as no feedback has been received." - days-before-stale: 7 - days-before-issue-close: 0 - days-before-pr-close: -1 - labels-to-remove-when-unstale: "Awaiting OP Action" diff --git a/.github/workflows/test-cygwin.yml b/.github/workflows/test-cygwin.yml deleted file mode 100644 index 32ac6f65e76..00000000000 --- a/.github/workflows/test-cygwin.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Test Cygwin - -on: - push: - branches: - - "**" - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - pull_request: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - python-minor-version: [8, 9] - - timeout-minutes: 40 - - name: Python 3.${{ matrix.python-minor-version }} - - steps: - - name: Fix line endings - run: | - git config --global core.autocrlf input - - - name: Checkout Pillow - uses: actions/checkout@v4 - - - name: Install Cygwin - uses: cygwin/cygwin-install-action@v4 - with: - platform: x86_64 - packages: > - gcc-g++ - ghostscript - ImageMagick - jpeg - libfreetype-devel - libimagequant-devel - libjpeg-devel - liblapack-devel - liblcms2-devel - libopenjp2-devel - libraqm-devel - libtiff-devel - libwebp-devel - libxcb-devel - libxcb-xinerama0 - make - netpbm - perl - python3${{ matrix.python-minor-version }}-cffi - python3${{ matrix.python-minor-version }}-cython - python3${{ matrix.python-minor-version }}-devel - python3${{ matrix.python-minor-version }}-numpy - python3${{ matrix.python-minor-version }}-sip - python3${{ matrix.python-minor-version }}-tkinter - wget - xorg-server-extra - zlib-devel - - - name: Add Lapack to PATH - uses: egor-tensin/cleanup-path@v3 - with: - dirs: 'C:\cygwin\bin;C:\cygwin\lib\lapack' - - - name: Select Python version - run: | - ln -sf c:/cygwin/bin/python3.${{ matrix.python-minor-version }} c:/cygwin/bin/python3 - - - name: Get latest NumPy version - id: latest-numpy - shell: bash.exe -eo pipefail -o igncr "{0}" - run: | - python3 -m pip list --outdated | grep numpy | sed -r 's/ +/ /g' | cut -d ' ' -f 3 | sed 's/^/version=/' >> $GITHUB_OUTPUT - - - name: pip cache - uses: actions/cache@v3 - with: - path: 'C:\cygwin\home\runneradmin\.cache\pip' - key: ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-numpy${{ steps.latest-numpy.outputs.version }}-${{ hashFiles('.ci/install.sh') }} - restore-keys: | - ${{ runner.os }}-cygwin-pip3.${{ matrix.python-minor-version }}-numpy${{ steps.latest-numpy.outputs.version }}- - - - name: Build system information - run: | - dash.exe -c "python3 .github/workflows/system-info.py" - - - name: Install dependencies - run: | - bash.exe .ci/install.sh - - - name: Upgrade NumPy - shell: dash.exe -l "{0}" - run: | - python3 -m pip install -U "numpy<1.26" - - - name: Build - shell: bash.exe -eo pipefail -o igncr "{0}" - run: | - .ci/build.sh - - - name: Test - run: | - bash.exe xvfb-run -s '-screen 0 1024x768x24' .ci/test.sh - - - name: Prepare to upload errors - if: failure() - run: | - dash.exe -c "mkdir -p Tests/errors" - - - name: Upload errors - uses: actions/upload-artifact@v4 - if: failure() - with: - name: errors - path: Tests/errors - - - name: After success - run: | - bash.exe .ci/after_success.sh - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - file: ./coverage.xml - flags: GHA_Cygwin - name: Cygwin Python 3.${{ matrix.python-minor-version }} - - success: - permissions: - contents: none - needs: build - runs-on: ubuntu-latest - name: Cygwin Test Successful - steps: - - name: Success - run: echo Cygwin Test Successful diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index eb27b4bf75b..069e744e08c 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -2,32 +2,10 @@ name: Test Docker on: push: - branches: - - "**" - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - pull_request: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - workflow_dispatch: permissions: contents: read -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: build: @@ -36,35 +14,11 @@ jobs: fail-fast: false matrix: docker: [ - # Run slower jobs first to give them a headstart and reduce waiting time - ubuntu-22.04-jammy-arm64v8, - ubuntu-22.04-jammy-ppc64le, - ubuntu-22.04-jammy-s390x, - # Then run the remainder alpine, amazon-2-amd64, amazon-2023-amd64, - arch, - centos-7-amd64, - centos-stream-8-amd64, - centos-stream-9-amd64, - debian-11-bullseye-amd64, - debian-12-bookworm-x86, - debian-12-bookworm-amd64, - fedora-38-amd64, - fedora-39-amd64, - gentoo, - ubuntu-20.04-focal-amd64, - ubuntu-22.04-jammy-amd64, ] dockerTag: [main] - include: - - docker: "ubuntu-22.04-jammy-arm64v8" - qemu-arch: "aarch64" - - docker: "ubuntu-22.04-jammy-ppc64le" - qemu-arch: "ppc64le" - - docker: "ubuntu-22.04-jammy-s390x" - qemu-arch: "s390x" name: ${{ matrix.docker }} diff --git a/.github/workflows/test-mingw.yml b/.github/workflows/test-mingw.yml deleted file mode 100644 index 115c2e9bebc..00000000000 --- a/.github/workflows/test-mingw.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Test MinGW - -on: - push: - branches: - - "**" - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - pull_request: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - - defaults: - run: - shell: bash.exe --login -eo pipefail "{0}" - env: - MSYSTEM: MINGW64 - CHERE_INVOKING: 1 - - timeout-minutes: 30 - name: "MinGW" - - steps: - - name: Checkout Pillow - uses: actions/checkout@v4 - - - name: Set up shell - run: echo "C:\msys64\usr\bin\" >> $env:GITHUB_PATH - shell: pwsh - - - name: Install dependencies - run: | - pacman -S --noconfirm \ - mingw-w64-x86_64-freetype \ - mingw-w64-x86_64-gcc \ - mingw-w64-x86_64-ghostscript \ - mingw-w64-x86_64-lcms2 \ - mingw-w64-x86_64-libimagequant \ - mingw-w64-x86_64-libjpeg-turbo \ - mingw-w64-x86_64-libraqm \ - mingw-w64-x86_64-libtiff \ - mingw-w64-x86_64-libwebp \ - mingw-w64-x86_64-openjpeg2 \ - mingw-w64-x86_64-python3-cffi \ - mingw-w64-x86_64-python3-numpy \ - mingw-w64-x86_64-python3-olefile \ - mingw-w64-x86_64-python3-pip \ - mingw-w64-x86_64-python3-setuptools \ - mingw-w64-x86_64-python-pyqt6 - - python3 -m pip install pyroma pytest pytest-cov pytest-timeout - - pushd depends && ./install_extra_test_images.sh && popd - - - name: Build Pillow - run: SETUPTOOLS_USE_DISTUTILS="stdlib" CFLAGS="-coverage" python3 -m pip install . - - - name: Test Pillow - run: | - python3 selftest.py --installed - python3 -c "from PIL import Image" - python3 -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - file: ./coverage.xml - flags: GHA_Windows - name: "MSYS2 MinGW" diff --git a/.github/workflows/test-valgrind.yml b/.github/workflows/test-valgrind.yml deleted file mode 100644 index 59bb958ec1c..00000000000 --- a/.github/workflows/test-valgrind.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Test Valgrind - -# like the Docker tests, but running valgrind only on *.c/*.h changes. - -on: - push: - branches: - - "**" - paths: - - ".github/workflows/test-valgrind.yml" - - "**.c" - - "**.h" - pull_request: - paths: - - ".github/workflows/test-valgrind.yml" - - "**.c" - - "**.h" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - docker: [ - ubuntu-22.04-jammy-amd64-valgrind, - ] - dockerTag: [main] - - name: ${{ matrix.docker }} - - steps: - - uses: actions/checkout@v4 - - - name: Build system information - run: python3 .github/workflows/system-info.py - - - name: Docker pull - run: | - docker pull pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }} - - - name: Build and Run Valgrind - run: | - # The Pillow user in the docker container is UID 1000 - sudo chown -R 1000 $GITHUB_WORKSPACE - docker run --name pillow_container -e "PILLOW_VALGRIND_TEST=true" -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }} - sudo chown -R runner $GITHUB_WORKSPACE diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml deleted file mode 100644 index 86cd5b5fa1e..00000000000 --- a/.github/workflows/test-windows.yml +++ /dev/null @@ -1,219 +0,0 @@ -name: Test Windows - -on: - push: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - pull_request: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - python-version: ["pypy3.10", "pypy3.9", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] - - timeout-minutes: 30 - - name: Python ${{ matrix.python-version }} - - steps: - - name: Checkout Pillow - uses: actions/checkout@v4 - - - name: Checkout cached dependencies - uses: actions/checkout@v4 - with: - repository: python-pillow/pillow-depends - path: winbuild\depends - - - name: Checkout extra test images - uses: actions/checkout@v4 - with: - repository: python-pillow/test-images - path: Tests\test-images - - # sets env: pythonLocation - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - cache: pip - cache-dependency-path: ".github/workflows/test-windows.yml" - - - name: Print build system information - run: python3 .github/workflows/system-info.py - - - name: python3 -m pip install pytest pytest-cov pytest-timeout defusedxml olefile pyroma - run: python3 -m pip install pytest pytest-cov pytest-timeout defusedxml olefile pyroma - - - name: Install dependencies - id: install - run: | - choco install nasm --no-progress - echo "C:\Program Files\NASM" >> $env:GITHUB_PATH - - choco install ghostscript --version=10.0.0.20230317 --no-progress - echo "C:\Program Files\gs\gs10.00.0\bin" >> $env:GITHUB_PATH - - # Install extra test images - xcopy /S /Y Tests\test-images\* Tests\images - - # make cache key depend on VS version - & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" ` - | find """catalog_buildVersion""" ` - | ForEach-Object { $a = $_.split(" ")[1]; echo "vs=$a" >> $env:GITHUB_OUTPUT } - shell: pwsh - - - name: Cache build - id: build-cache - uses: actions/cache@v3 - with: - path: winbuild\build - key: - ${{ hashFiles('winbuild\build_prepare.py') }}-${{ hashFiles('.github\workflows\test-windows.yml') }}-${{ env.pythonLocation }}-${{ steps.install.outputs.vs }} - - - name: Prepare build - if: steps.build-cache.outputs.cache-hit != 'true' - run: | - & python.exe winbuild\build_prepare.py -v - shell: pwsh - - - name: Build dependencies / libjpeg-turbo - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libjpeg.cmd" - - - name: Build dependencies / zlib - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_zlib.cmd" - - - name: Build dependencies / xz - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_xz.cmd" - - - name: Build dependencies / WebP - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libwebp.cmd" - - - name: Build dependencies / LibTiff - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libtiff.cmd" - - # for FreeType CBDT/SBIX font support - - name: Build dependencies / libpng - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libpng.cmd" - - # for FreeType WOFF2 font support - - name: Build dependencies / brotli - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_brotli.cmd" - - - name: Build dependencies / FreeType - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_freetype.cmd" - - - name: Build dependencies / LCMS2 - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_lcms2.cmd" - - - name: Build dependencies / OpenJPEG - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_openjpeg.cmd" - - # GPL licensed - - name: Build dependencies / libimagequant - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_libimagequant.cmd" - - # Raqm dependencies - - name: Build dependencies / HarfBuzz - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_harfbuzz.cmd" - - # Raqm dependencies - - name: Build dependencies / FriBidi - if: steps.build-cache.outputs.cache-hit != 'true' - run: "& winbuild\\build\\build_dep_fribidi.cmd" - - # trim ~150MB for each job - - name: Optimize build cache - if: steps.build-cache.outputs.cache-hit != 'true' - run: rmdir /S /Q winbuild\build\src - shell: cmd - - - name: Build Pillow - run: | - $FLAGS="-C raqm=vendor -C fribidi=vendor" - cmd /c "winbuild\build\build_env.cmd && $env:pythonLocation\python.exe -m pip install -v $FLAGS ." - & $env:pythonLocation\python.exe selftest.py --installed - shell: pwsh - - # skip PyPy for speed - - name: Enable heap verification - if: "!contains(matrix.python-version, 'pypy')" - run: | - & reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f - - - name: Test Pillow - run: | - path %GITHUB_WORKSPACE%\\winbuild\\build\\bin;%PATH% - python.exe -m pytest -vx -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests - shell: cmd - - - name: Prepare to upload errors - if: failure() - run: | - mkdir -p Tests/errors - shell: bash - - - name: Upload errors - uses: actions/upload-artifact@v4 - if: failure() - with: - name: errors - path: Tests/errors - - - name: After success - run: | - .ci/after_success.sh - shell: pwsh - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - file: ./coverage.xml - flags: GHA_Windows - name: ${{ runner.os }} Python ${{ matrix.python-version }} - - success: - permissions: - contents: none - needs: build - runs-on: ubuntu-latest - name: Windows Test Successful - steps: - - name: Success - run: echo Windows Test Successful diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index aa0e2513825..00000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,140 +0,0 @@ -name: Test - -on: - push: - branches: - - "**" - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - pull_request: - paths-ignore: - - ".github/workflows/docs.yml" - - ".github/workflows/wheels*" - - ".gitmodules" - - ".travis.yml" - - "docs/**" - - "wheels/**" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - - strategy: - fail-fast: false - matrix: - os: [ - "macos-latest", - "ubuntu-latest", - ] - python-version: [ - "pypy3.10", - "pypy3.9", - "3.13", - "3.12", - "3.11", - "3.10", - "3.9", - "3.8", - ] - include: - - python-version: "3.9" - PYTHONOPTIMIZE: 1 - REVERSE: "--reverse" - - python-version: "3.8" - PYTHONOPTIMIZE: 2 - - runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} Python ${{ matrix.python-version }} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - cache: pip - cache-dependency-path: ".ci/*.sh" - - - name: Build system information - run: python3 .github/workflows/system-info.py - - - name: Install Linux dependencies - if: startsWith(matrix.os, 'ubuntu') - run: | - .ci/install.sh - env: - GHA_PYTHON_VERSION: ${{ matrix.python-version }} - - - name: Install macOS dependencies - if: startsWith(matrix.os, 'macOS') - run: | - .github/workflows/macos-install.sh - env: - GHA_PYTHON_VERSION: ${{ matrix.python-version }} - - - name: Build - run: | - .ci/build.sh - - - name: Test - run: | - if [ $REVERSE ]; then - python3 -m pip install pytest-reverse - fi - if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then - xvfb-run -s '-screen 0 1024x768x24' sway& - export WAYLAND_DISPLAY=wayland-1 - .ci/test.sh - else - .ci/test.sh - fi - env: - PYTHONOPTIMIZE: ${{ matrix.PYTHONOPTIMIZE }} - REVERSE: ${{ matrix.REVERSE }} - - - name: Prepare to upload errors - if: failure() - run: | - mkdir -p Tests/errors - - - name: Upload errors - uses: actions/upload-artifact@v4 - if: failure() - with: - name: errors - path: Tests/errors - - - name: After success - run: | - .ci/after_success.sh - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - flags: ${{ matrix.os == 'macos-latest' && 'GHA_macOS' || 'GHA_Ubuntu' }} - name: ${{ matrix.os }} Python ${{ matrix.python-version }} - gcov: true - - success: - permissions: - contents: none - needs: build - runs-on: ubuntu-latest - name: Test Successful - steps: - - name: Success - run: echo Test Successful diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index d18552f296d..00000000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,195 +0,0 @@ -name: Wheels - -on: - push: - paths: - - ".ci/requirements-cibw.txt" - - ".github/workflows/wheel*" - - "wheels/*" - - "winbuild/build_prepare.py" - - "winbuild/fribidi.cmake" - tags: - - "*" - pull_request: - paths: - - ".ci/requirements-cibw.txt" - - ".github/workflows/wheel*" - - "wheels/*" - - "winbuild/build_prepare.py" - - "winbuild/fribidi.cmake" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - FORCE_COLOR: 1 - -jobs: - build: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - name: "macOS x86_64" - os: macos-latest - archs: x86_64 - macosx_deployment_target: "10.10" - - name: "macOS arm64" - os: macos-latest - archs: arm64 - macosx_deployment_target: "11.0" - - name: "manylinux2014 and musllinux x86_64" - os: ubuntu-latest - archs: x86_64 - - name: "manylinux_2_28 x86_64" - os: ubuntu-latest - archs: x86_64 - build: "*manylinux*" - manylinux: "manylinux_2_28" - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - - name: Build wheels - run: | - python3 -m pip install -r .ci/requirements-cibw.txt - python3 -m cibuildwheel --output-dir wheelhouse - env: - CIBW_ARCHS: ${{ matrix.archs }} - CIBW_BUILD: ${{ matrix.build }} - CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} - CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} - CIBW_SKIP: pp38-* - CIBW_TEST_SKIP: "*-macosx_arm64" - MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} - - - uses: actions/upload-artifact@v3 - with: - name: dist - path: ./wheelhouse/*.whl - - windows: - name: Windows ${{ matrix.arch }} - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - include: - - arch: x86 - cibw_arch: x86 - - arch: x64 - cibw_arch: AMD64 - - arch: ARM64 - cibw_arch: ARM64 - steps: - - uses: actions/checkout@v4 - - - name: Checkout extra test images - uses: actions/checkout@v4 - with: - repository: python-pillow/test-images - path: Tests\test-images - - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - - name: Prepare for build - run: | - choco install nasm --no-progress - echo "C:\Program Files\NASM" >> $env:GITHUB_PATH - - # Install extra test images - xcopy /S /Y Tests\test-images\* Tests\images - - & python.exe -m pip install -r .ci/requirements-cibw.txt - - & python.exe winbuild\build_prepare.py -v --no-imagequant --architecture=${{ matrix.arch }} - shell: pwsh - - - name: Build wheels - run: | - setlocal EnableDelayedExpansion - for %%f in (winbuild\build\license\*) do ( - set x=%%~nf - rem Skip FriBiDi license, it is not included in the wheel. - set fribidi=!x:~0,7! - if NOT !fribidi!==fribidi ( - rem Skip imagequant license, it is not included in the wheel. - set libimagequant=!x:~0,13! - if NOT !libimagequant!==libimagequant ( - echo. >> LICENSE - echo ===== %%~nf ===== >> LICENSE - echo. >> LICENSE - type %%f >> LICENSE - ) - ) - ) - call winbuild\\build\\build_env.cmd - %pythonLocation%\python.exe -m cibuildwheel . --output-dir wheelhouse - env: - CIBW_ARCHS: ${{ matrix.cibw_arch }} - CIBW_BEFORE_ALL: "{package}\\winbuild\\build\\build_dep_all.cmd" - CIBW_CACHE_PATH: "C:\\cibw" - CIBW_TEST_SKIP: "*-win_arm64" - CIBW_TEST_COMMAND: 'docker run --rm - -v {project}:C:\pillow - -v C:\cibw:C:\cibw - -v %CD%\..\venv-test:%CD%\..\venv-test - -e CI -e GITHUB_ACTIONS - mcr.microsoft.com/windows/servercore:ltsc2022 - powershell C:\pillow\.github\workflows\wheels-test.ps1 %CD%\..\venv-test' - shell: cmd - - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: dist - path: ./wheelhouse/*.whl - - - name: Upload fribidi.dll - uses: actions/upload-artifact@v4 - with: - name: fribidi-windows-${{ matrix.arch }} - path: winbuild\build\bin\fribidi* - - sdist: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - cache: pip - cache-dependency-path: "Makefile" - - - run: make sdist - - - uses: actions/upload-artifact@v3 - with: - name: dist - path: dist/*.tar.gz - - success: - permissions: - contents: none - needs: [build, windows, sdist] - runs-on: ubuntu-latest - name: Wheels Successful - steps: - - name: Success - run: echo Wheels Successful diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8f8250809d7..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -if: tag IS present OR type = api - -env: - global: - - CIBW_ARCHS=aarch64 - - CIBW_SKIP=pp38-* - -language: python -# Default Python version is usually 3.6 -python: "3.12" -dist: jammy -services: docker - -jobs: - include: - - name: "manylinux2014 aarch64" - os: linux - arch: arm64 - env: - - CIBW_BUILD="*manylinux*" - - CIBW_MANYLINUX_AARCH64_IMAGE=manylinux2014 - - CIBW_MANYLINUX_PYPY_AARCH64_IMAGE=manylinux2014 - - name: "manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - CIBW_BUILD="*manylinux*" - - CIBW_MANYLINUX_AARCH64_IMAGE=manylinux_2_28 - - CIBW_MANYLINUX_PYPY_AARCH64_IMAGE=manylinux_2_28 - - name: "musllinux aarch64" - os: linux - arch: arm64 - env: - - CIBW_BUILD="*musllinux*" - -install: - - python3 -m pip install -r .ci/requirements-cibw.txt - -script: - - python3 -m cibuildwheel --output-dir wheelhouse - - ls -l "${TRAVIS_BUILD_DIR}/wheelhouse/" - -# Upload wheels to GitHub Releases -deploy: - provider: releases - api_key: $GITHUB_RELEASE_TOKEN - file_glob: true - file: "${TRAVIS_BUILD_DIR}/wheelhouse/*.whl" - on: - repo: python-pillow/Pillow - tags: true - skip_cleanup: true diff --git a/Tests/oss-fuzz/test_fuzzers.py b/Tests/oss-fuzz/test_fuzzers.py index 68834045a52..186a0efd3fe 100644 --- a/Tests/oss-fuzz/test_fuzzers.py +++ b/Tests/oss-fuzz/test_fuzzers.py @@ -6,7 +6,7 @@ import packaging import pytest -from PIL import Image, features +from PIL import Image, UnidentifiedImageError, features from Tests.helper import skip_unless_feature if sys.platform.startswith("win32"): @@ -42,7 +42,7 @@ def test_fuzz_images(path): except ( Image.DecompressionBombError, Image.DecompressionBombWarning, - Image.UnidentifiedImageError, + UnidentifiedImageError, ): # Known Image.* exceptions assert True diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index c479c384a76..360ae11b515 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -3,7 +3,7 @@ import pytest -from PIL import EpsImagePlugin, Image, features +from PIL import EpsImagePlugin, Image, UnidentifiedImageError, features from .helper import ( assert_image_similar, @@ -417,7 +417,7 @@ def test_emptyline(): ) def test_timeout(test_file): with open(test_file, "rb") as f: - with pytest.raises(Image.UnidentifiedImageError): + with pytest.raises(UnidentifiedImageError): with Image.open(f): pass diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index 8b06ce2b163..d98f2335648 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -3,7 +3,7 @@ import pytest -from PIL import Image, PsdImagePlugin +from PIL import Image, PsdImagePlugin, UnidentifiedImageError from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy @@ -146,11 +146,11 @@ def test_combined_larger_than_size(): [ ( "Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd", - Image.UnidentifiedImageError, + UnidentifiedImageError, ), ( "Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd", - Image.UnidentifiedImageError, + UnidentifiedImageError, ), ("Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError), ("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError), diff --git a/pyproject.toml b/pyproject.toml index 193e8c9b247..47fda17d642 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ include-package-data = true package-dir = {"" = "src"} [tool.setuptools.dynamic] -version = {attr = "PIL.__version__"} +version = {attr = "PIL._version.__version__"} [tool.cibuildwheel] before-all = ".github/workflows/wheels-dependencies.sh" diff --git a/src/PIL/Image.py b/src/PIL/Image.py index d04801cba75..7cc008f943e 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -53,12 +53,10 @@ ExifTags, ImageMode, TiffTags, - UnidentifiedImageError, - __version__, - _plugins, ) from ._binary import i32le, o32be, o32le from ._util import DeferredError, is_path +from ._version import __version__ logger = logging.getLogger(__name__) @@ -357,6 +355,8 @@ def init(): if _initialized >= 2: return 0 + from . import _plugins + parent_name = __name__.rpartition(".")[0] for plugin in _plugins: try: @@ -3302,6 +3302,8 @@ def _open_core(fp, filename, prefix, formats): im._exclusive_fp = exclusive_fp return im + from . import UnidentifiedImageError + if exclusive_fp: fp.close() for message in accept_warnings: diff --git a/src/PIL/__init__.py b/src/PIL/__init__.py index 3fcac8643cb..deece802d8a 100644 --- a/src/PIL/__init__.py +++ b/src/PIL/__init__.py @@ -14,7 +14,7 @@ """ from __future__ import annotations -from . import _version +from . import Image, _version # VERSION was removed in Pillow 6.0.0. # PILLOW_VERSION was removed in Pillow 9.0.0. @@ -22,6 +22,8 @@ __version__ = _version.__version__ del _version +ImageType = Image.Image + _plugins = [ "BlpImagePlugin", diff --git a/src/PIL/_deprecate.py b/src/PIL/_deprecate.py index 33a0e07b3f4..720da95466d 100644 --- a/src/PIL/_deprecate.py +++ b/src/PIL/_deprecate.py @@ -2,7 +2,7 @@ import warnings -from . import __version__ +from ._version import __version__ def deprecate(