Use --config-settings instead of deprecated --global-option

This commit is contained in:
Andrew Murray 2023-05-20 15:38:36 +10:00
parent 599979caae
commit 4f734d295f
6 changed files with 51 additions and 15 deletions

View File

@ -80,7 +80,7 @@ jobs:
pushd depends && ./install_extra_test_images.sh && popd
- name: Build Pillow
run: SETUPTOOLS_USE_DISTUTILS="stdlib" CFLAGS="-coverage" python3 -m pip install --global-option="build_ext" .
run: SETUPTOOLS_USE_DISTUTILS="stdlib" CFLAGS="-coverage" python3 -m pip install .
- name: Test Pillow
run: |

View File

@ -15,6 +15,7 @@ graft src
graft depends
graft winbuild
graft docs
graft _custom_build
# build/src control detritus
exclude .appveyor.yml

View File

@ -65,7 +65,7 @@ install:
.PHONY: install-coverage
install-coverage:
CFLAGS="-coverage -Werror=implicit-function-declaration" python3 -m pip -v install --global-option="build_ext" .
CFLAGS="-coverage -Werror=implicit-function-declaration" python3 -m pip -v install .
python3 selftest.py
.PHONY: debug
@ -74,7 +74,7 @@ debug:
# for our stuff, kills optimization, and redirects to dev null so we
# see any build failures.
make clean > /dev/null
CFLAGS='-g -O0' python3 -m pip -v install --global-option="build_ext" . > /dev/null
CFLAGS='-g -O0' python3 -m pip -v install . > /dev/null
.PHONY: release-test
release-test:

31
_custom_build/backend.py Executable file
View File

@ -0,0 +1,31 @@
import sys
from setuptools.build_meta import * # noqa: F401, F403
from setuptools.build_meta import _BuildMetaBackend
class _CustomBuildMetaBackend(_BuildMetaBackend):
def run_setup(self, setup_script="setup.py"):
if self.config_settings:
flags = []
for key in ("enable", "disable", "vendor"):
settings = self.config_settings.get(key)
if settings:
if not isinstance(settings, list):
settings = [settings]
for value in settings:
flags.append("--" + key + "-" + value)
if self.config_settings.get("debug") == "true":
flags.append("--debug")
if flags:
sys.argv = sys.argv[:1] + ["build_ext"] + flags + sys.argv[1:]
return super().run_setup(setup_script)
def build_wheel(
self, wheel_directory, config_settings=None, metadata_directory=None
):
self.config_settings = config_settings
return super().build_wheel(wheel_directory, config_settings, metadata_directory)
build_wheel = _CustomBuildMetaBackend().build_wheel

View File

@ -380,40 +380,40 @@ Build Options
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
available, as many as are present.
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
``--disable-tiff``, ``--disable-freetype``, ``--disable-raqm``,
``--disable-lcms``, ``--disable-webp``, ``--disable-webpmux``,
``--disable-jpeg2000``, ``--disable-imagequant``, ``--disable-xcb``.
* Config settings: ``-C disable=zlib``, ``-C disable=jpeg``,
``-C disable=tiff``, ``-C disable=freetype``, ``-C disable=raqm``,
``-C disable=lcms``, ``-C disable=webp``, ``-C disable=webpmux``,
``-C disable=jpeg2000``, ``-C disable=imagequant``, ``-C disable=xcb``.
Disable building the corresponding feature even if the development
libraries are present on the building machine.
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
``--enable-tiff``, ``--enable-freetype``, ``--enable-raqm``,
``--enable-lcms``, ``--enable-webp``, ``--enable-webpmux``,
``--enable-jpeg2000``, ``--enable-imagequant``, ``--enable-xcb``.
* Config settings: ``-C enable=zlib``, ``-C enable=jpeg``,
``-C enable=tiff``, ``-C enable=freetype``, ``-C enable=raqm``,
``-C enable=lcms``, ``-C enable=webp``, ``-C enable=webpmux``,
``-C enable=jpeg2000``, ``-C enable=imagequant``, ``-C enable=xcb``.
Require that the corresponding feature is built. The build will raise
an exception if the libraries are not found. Webpmux (WebP metadata)
relies on WebP support. Tcl and Tk also must be used together.
* Build flags: ``--vendor-raqm``, ``--vendor-fribidi``.
* Config settings: ``-C vendor=raqm``, ``-C vendor=fribidi``.
These flags are used to compile a modified version of libraqm and
a shim that dynamically loads libfribidi at runtime. These are
used to compile the standard Pillow wheels. Compiling libraqm requires
a C99-compliant compiler.
* Build flag: ``--disable-platform-guessing``. Skips all of the
* Build flag: ``-C disable=platform-guessing``. Skips all of the
platform dependent guessing of include and library directories for
automated build systems that configure the proper paths in the
environment variables (e.g. Buildroot).
* Build flag: ``--debug``. Adds a debugging flag to the include and
* Build flag: ``-C debug=true``. Adds a debugging flag to the include and
library search process to dump all paths searched for and found to
stdout.
Sample usage::
python3 -m pip install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]"
python3 -m pip install --upgrade Pillow -C enable=[feature]
Platform Support
----------------

4
pyproject.toml Normal file
View File

@ -0,0 +1,4 @@
[build-system]
requires = ["setuptools >= 40.8.0", "wheel"]
build-backend = "backend"
backend-path = ["_custom_build"]