diff --git a/.appveyor.yml b/.appveyor.yml index 36f5bd0ad68..575b6caa603 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,6 +20,7 @@ environment: install: - '%PYTHON%\%EXECUTABLE% --version' +- '%PYTHON%\%EXECUTABLE% -m pip install --upgrade pip' - curl -fsSL -o pillow-depends.zip https://github.com/python-pillow/pillow-depends/archive/main.zip - curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip - 7z x pillow-depends.zip -oc:\ @@ -71,7 +72,7 @@ before_deploy: - cd c:\pillow - '%PYTHON%\%EXECUTABLE% -m pip install wheel' - cd c:\pillow\winbuild\ - - c:\pillow\winbuild\build\build_pillow.cmd bdist_wheel + - c:\pillow\winbuild\build\build_pillow.cmd --global-option="bdist_wheel" - cd c:\pillow - ps: Get-ChildItem .\dist\*.* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 076b8083966..fbfec8c13d9 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -65,8 +65,8 @@ jobs: - name: Print build system information run: python3 .github/workflows/system-info.py - - name: python3 -m pip install setuptools wheel pytest pytest-cov pytest-timeout defusedxml - run: python3 -m pip install setuptools wheel pytest pytest-cov pytest-timeout defusedxml + - name: python3 -m pip install wheel pytest pytest-cov pytest-timeout defusedxml + run: python3 -m pip install wheel pytest pytest-cov pytest-timeout defusedxml - name: Install dependencies id: install @@ -166,8 +166,8 @@ jobs: - name: Build Pillow run: | $FLAGS="" - if ('${{ github.event_name }}' -ne 'pull_request') { $FLAGS="--disable-imagequant" } - & winbuild\build\build_pillow.cmd $FLAGS install + if ('${{ github.event_name }}' -ne 'pull_request') { $FLAGS='--global-option="--disable-imagequant"' } + & winbuild\build\build_pillow.cmd $FLAGS --global-option="install" & $env:pythonLocation\python.exe selftest.py --installed shell: pwsh @@ -231,7 +231,7 @@ jobs: ) ) for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo dist=dist-%%a >> %GITHUB_OUTPUT% - winbuild\\build\\build_pillow.cmd --disable-imagequant bdist_wheel + winbuild\\build\\build_pillow.cmd --global-option="--disable-imagequant" --global-option="bdist_wheel" shell: cmd - name: Upload wheel diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4882a317faa..26762605007 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,7 @@ repos: hooks: - id: check-merge-conflict - id: check-json + - id: check-toml - id: check-yaml - repo: https://github.com/sphinx-contrib/sphinx-lint @@ -56,6 +57,16 @@ repos: hooks: - id: sphinx-lint + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.12.1 + hooks: + - id: pyproject-fmt + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.13 + hooks: + - id: validate-pyproject + - repo: https://github.com/tox-dev/tox-ini-fmt rev: 1.3.0 hooks: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..59eb08fa9bd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=67.8", +] diff --git a/setup.py b/setup.py index 0b6b0207764..e2a941ee23e 100755 --- a/setup.py +++ b/setup.py @@ -137,7 +137,6 @@ class RequiredDependencyException(Exception): PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version -PLATFORM_PYPY = hasattr(sys, "pypy_version_info") def _dbg(s, tp=None): @@ -847,14 +846,7 @@ def build_extensions(self): if struct.unpack("h", b"\0\1")[0] == 1: defs.append(("WORDS_BIGENDIAN", None)) - if ( - sys.platform == "win32" - and sys.version_info < (3, 9) - and not (PLATFORM_PYPY or PLATFORM_MINGW) - ): - defs.append(("PILLOW_VERSION", f'"\\"{PILLOW_VERSION}\\""')) - else: - defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"')) + defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"')) self._update_extension("PIL._imaging", libs, defs) diff --git a/winbuild/README.md b/winbuild/README.md index 2975acf283f..24b3eacdf88 100644 --- a/winbuild/README.md +++ b/winbuild/README.md @@ -20,10 +20,10 @@ set PYTHON=C:\Python38\bin cd /D C:\Pillow\winbuild C:\Python39\bin\python.exe build_prepare.py -v --depends=C:\pillow-depends build\build_dep_all.cmd -build\build_pillow.cmd install +build\build_pillow.cmd --global-option="install" cd .. path C:\Pillow\winbuild\build\bin;%PATH% %PYTHON%\python.exe selftest.py %PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests -build\build_pillow.cmd bdist_wheel +build\build_pillow.cmd --global-option="bdist_wheel" ``` diff --git a/winbuild/build.rst b/winbuild/build.rst index 99dfad3015f..c0d4c5c86c4 100644 --- a/winbuild/build.rst +++ b/winbuild/build.rst @@ -87,9 +87,9 @@ Building Pillow --------------- Once the dependencies are built, run -``winbuild\build\build_pillow.cmd install`` to build and install +``winbuild\build\build_pillow.cmd --global-option="install"`` to build and install Pillow for the selected version of Python. -``winbuild\build\build_pillow.cmd bdist_wheel`` will build wheels +``winbuild\build\build_pillow.cmd --global-option="bdist_wheel"`` will build wheels instead of installing Pillow. You can also use ``winbuild\build\build_pillow.cmd --inplace develop`` to build @@ -114,9 +114,9 @@ The following is a simplified version of the script used on AppVeyor:: cd /D C:\Pillow\winbuild C:\Python39\bin\python.exe build_prepare.py -v --depends C:\pillow-depends build\build_dep_all.cmd - build\build_pillow.cmd install + build\build_pillow.cmd --global-option="install" cd .. path C:\Pillow\winbuild\build\bin;%PATH% %PYTHON%\python.exe selftest.py %PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests - build\build_pillow.cmd bdist_wheel + build\build_pillow.cmd --global-option="bdist_wheel" diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 19552f3c787..21b6c10a59c 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -569,7 +569,10 @@ def build_pillow(): *prefs["header"], cmd_set("DISTUTILS_USE_SDK", "1"), # use same compiler to build Pillow cmd_set("py_vcruntime_redist", "true"), # always use /MD, never /MT - r'"{python_dir}\{python_exe}" setup.py build_ext --vendor-raqm --vendor-fribidi %*', # noqa: E501 + r'"{python_dir}\{python_exe}" -m pip install . ' + r'--global-option="--vendor-raqm" ' + r'--global-option="--vendor-fribidi" ' + r"%*", ] write_script("build_pillow.cmd", lines)