mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Merge pull request #7171 from radarhere/build
Use --config-settings instead of deprecated --global-option
This commit is contained in:
commit
c48263494c
2
.github/workflows/test-mingw.yml
vendored
2
.github/workflows/test-mingw.yml
vendored
|
@ -80,7 +80,7 @@ jobs:
|
||||||
pushd depends && ./install_extra_test_images.sh && popd
|
pushd depends && ./install_extra_test_images.sh && popd
|
||||||
|
|
||||||
- name: Build Pillow
|
- 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
|
- name: Test Pillow
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -15,6 +15,7 @@ graft src
|
||||||
graft depends
|
graft depends
|
||||||
graft winbuild
|
graft winbuild
|
||||||
graft docs
|
graft docs
|
||||||
|
graft _custom_build
|
||||||
|
|
||||||
# build/src control detritus
|
# build/src control detritus
|
||||||
exclude .appveyor.yml
|
exclude .appveyor.yml
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -46,7 +46,6 @@ help:
|
||||||
@echo " docserve run an HTTP server on the docs directory"
|
@echo " docserve run an HTTP server on the docs directory"
|
||||||
@echo " html make HTML docs"
|
@echo " html make HTML docs"
|
||||||
@echo " htmlview open the index page built by the html target in your browser"
|
@echo " htmlview open the index page built by the html target in your browser"
|
||||||
@echo " inplace make inplace extension"
|
|
||||||
@echo " install make and install"
|
@echo " install make and install"
|
||||||
@echo " install-coverage make and install with C coverage"
|
@echo " install-coverage make and install with C coverage"
|
||||||
@echo " lint run the lint checks"
|
@echo " lint run the lint checks"
|
||||||
|
@ -54,10 +53,6 @@ help:
|
||||||
@echo " release-test run code and package tests before release"
|
@echo " release-test run code and package tests before release"
|
||||||
@echo " test run tests on installed Pillow"
|
@echo " test run tests on installed Pillow"
|
||||||
|
|
||||||
.PHONY: inplace
|
|
||||||
inplace: clean
|
|
||||||
python3 -m pip install -e --global-option="build_ext" --global-option="--inplace" .
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
python3 -m pip -v install .
|
python3 -m pip -v install .
|
||||||
|
@ -65,7 +60,7 @@ install:
|
||||||
|
|
||||||
.PHONY: install-coverage
|
.PHONY: install-coverage
|
||||||
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
|
python3 selftest.py
|
||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
|
@ -74,7 +69,7 @@ debug:
|
||||||
# for our stuff, kills optimization, and redirects to dev null so we
|
# for our stuff, kills optimization, and redirects to dev null so we
|
||||||
# see any build failures.
|
# see any build failures.
|
||||||
make clean > /dev/null
|
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
|
.PHONY: release-test
|
||||||
release-test:
|
release-test:
|
||||||
|
|
56
_custom_build/backend.py
Executable file
56
_custom_build/backend.py
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from setuptools.build_meta import * # noqa: F401, F403
|
||||||
|
from setuptools.build_meta import build_wheel
|
||||||
|
|
||||||
|
backend_class = build_wheel.__self__.__class__
|
||||||
|
|
||||||
|
|
||||||
|
class _CustomBuildMetaBackend(backend_class):
|
||||||
|
def run_setup(self, setup_script="setup.py"):
|
||||||
|
if self.config_settings:
|
||||||
|
|
||||||
|
def config_has(key, value):
|
||||||
|
settings = self.config_settings.get(key)
|
||||||
|
if settings:
|
||||||
|
if not isinstance(settings, list):
|
||||||
|
settings = [settings]
|
||||||
|
return value in settings
|
||||||
|
|
||||||
|
flags = []
|
||||||
|
for dependency in (
|
||||||
|
"zlib",
|
||||||
|
"jpeg",
|
||||||
|
"tiff",
|
||||||
|
"freetype",
|
||||||
|
"raqm",
|
||||||
|
"lcms",
|
||||||
|
"webp",
|
||||||
|
"webpmux",
|
||||||
|
"jpeg2000",
|
||||||
|
"imagequant",
|
||||||
|
"xcb",
|
||||||
|
):
|
||||||
|
if config_has(dependency, "enable"):
|
||||||
|
flags.append("--enable-" + dependency)
|
||||||
|
elif config_has(dependency, "disable"):
|
||||||
|
flags.append("--disable-" + dependency)
|
||||||
|
for dependency in ("raqm", "fribidi"):
|
||||||
|
if config_has(dependency, "vendor"):
|
||||||
|
flags.append("--vendor-" + dependency)
|
||||||
|
if self.config_settings.get("platform-guessing") == "disable":
|
||||||
|
flags.append("--disable-platform-guessing")
|
||||||
|
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
|
|
@ -385,40 +385,40 @@ Build Options
|
||||||
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
|
using a setting of 1. By default, it uses 4 CPUs, or if 4 are not
|
||||||
available, as many as are present.
|
available, as many as are present.
|
||||||
|
|
||||||
* Build flags: ``--disable-zlib``, ``--disable-jpeg``,
|
* Config settings: ``-C zlib=disable``, ``-C jpeg=disable``,
|
||||||
``--disable-tiff``, ``--disable-freetype``, ``--disable-raqm``,
|
``-C tiff=disable``, ``-C freetype=disable``, ``-C raqm=disable``,
|
||||||
``--disable-lcms``, ``--disable-webp``, ``--disable-webpmux``,
|
``-C lcms=disable``, ``-C webp=disable``, ``-C webpmux=disable``,
|
||||||
``--disable-jpeg2000``, ``--disable-imagequant``, ``--disable-xcb``.
|
``-C jpeg2000=disable``, ``-C imagequant=disable``, ``-C xcb=disable``.
|
||||||
Disable building the corresponding feature even if the development
|
Disable building the corresponding feature even if the development
|
||||||
libraries are present on the building machine.
|
libraries are present on the building machine.
|
||||||
|
|
||||||
* Build flags: ``--enable-zlib``, ``--enable-jpeg``,
|
* Config settings: ``-C zlib=enable``, ``-C jpeg=enable``,
|
||||||
``--enable-tiff``, ``--enable-freetype``, ``--enable-raqm``,
|
``-C tiff=enable``, ``-C freetype=enable``, ``-C raqm=enable``,
|
||||||
``--enable-lcms``, ``--enable-webp``, ``--enable-webpmux``,
|
``-C lcms=enable``, ``-C webp=enable``, ``-C webpmux=enable``,
|
||||||
``--enable-jpeg2000``, ``--enable-imagequant``, ``--enable-xcb``.
|
``-C jpeg2000=enable``, ``-C imagequant=enable``, ``-C xcb=enable``.
|
||||||
Require that the corresponding feature is built. The build will raise
|
Require that the corresponding feature is built. The build will raise
|
||||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||||
relies on WebP support. Tcl and Tk also must be used together.
|
relies on WebP support. Tcl and Tk also must be used together.
|
||||||
|
|
||||||
* Build flags: ``--vendor-raqm``, ``--vendor-fribidi``.
|
* Config settings: ``-C raqm=vendor``, ``-C fribidi=vendor``.
|
||||||
These flags are used to compile a modified version of libraqm and
|
These flags are used to compile a modified version of libraqm and
|
||||||
a shim that dynamically loads libfribidi at runtime. These are
|
a shim that dynamically loads libfribidi at runtime. These are
|
||||||
used to compile the standard Pillow wheels. Compiling libraqm requires
|
used to compile the standard Pillow wheels. Compiling libraqm requires
|
||||||
a C99-compliant compiler.
|
a C99-compliant compiler.
|
||||||
|
|
||||||
* Build flag: ``--disable-platform-guessing``. Skips all of the
|
* Build flag: ``-C platform-guessing=disable``. Skips all of the
|
||||||
platform dependent guessing of include and library directories for
|
platform dependent guessing of include and library directories for
|
||||||
automated build systems that configure the proper paths in the
|
automated build systems that configure the proper paths in the
|
||||||
environment variables (e.g. Buildroot).
|
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
|
library search process to dump all paths searched for and found to
|
||||||
stdout.
|
stdout.
|
||||||
|
|
||||||
|
|
||||||
Sample usage::
|
Sample usage::
|
||||||
|
|
||||||
python3 -m pip install --upgrade Pillow --global-option="build_ext" --global-option="--enable-[feature]"
|
python3 -m pip install --upgrade Pillow -C [feature]=enable
|
||||||
|
|
||||||
Platform Support
|
Platform Support
|
||||||
----------------
|
----------------
|
||||||
|
|
4
pyproject.toml
Normal file
4
pyproject.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools >= 40.8.0", "wheel"]
|
||||||
|
build-backend = "backend"
|
||||||
|
backend-path = ["_custom_build"]
|
2
tox.ini
2
tox.ini
|
@ -13,7 +13,7 @@ extras =
|
||||||
tests
|
tests
|
||||||
commands =
|
commands =
|
||||||
make clean
|
make clean
|
||||||
{envpython} -m pip install --global-option="build_ext" --global-option="--inplace" .
|
{envpython} -m pip install .
|
||||||
{envpython} selftest.py
|
{envpython} selftest.py
|
||||||
{envpython} -m pytest -W always {posargs}
|
{envpython} -m pytest -W always {posargs}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user