mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-03 20:10:08 +03:00
lib_imaging POC
This commit is contained in:
parent
4c5345cf53
commit
3de19ad305
|
@ -73,7 +73,7 @@ on some Python versions.
|
|||
:mod:`PIL.Image.core` Module
|
||||
----------------------------
|
||||
|
||||
.. module:: PIL._imaging
|
||||
.. module:: PIL.lib_imaging
|
||||
.. module:: PIL.Image.core
|
||||
|
||||
An internal interface module previously known as :mod:`~PIL._imaging`,
|
||||
|
|
20
setup.py
20
setup.py
|
@ -14,11 +14,14 @@ import shutil
|
|||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import sysconfig
|
||||
import warnings
|
||||
|
||||
from setuptools import Extension, setup
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
EXT_SUFFIX, _, _ = sysconfig.get_config_var("EXT_SUFFIX").rpartition(".")
|
||||
|
||||
|
||||
def get_version():
|
||||
version_file = "src/PIL/_version.py"
|
||||
|
@ -411,7 +414,7 @@ class pil_build_ext(build_ext):
|
|||
if FUZZING_BUILD:
|
||||
extension.language = "c++"
|
||||
extension.extra_link_args = ["--stdlib=libc++"]
|
||||
break
|
||||
return extension
|
||||
|
||||
def _remove_extension(self, name):
|
||||
for extension in self.extensions:
|
||||
|
@ -854,7 +857,7 @@ class pil_build_ext(build_ext):
|
|||
|
||||
defs.append(("PILLOW_VERSION", f'"{PILLOW_VERSION}"'))
|
||||
|
||||
self._update_extension("PIL._imaging", libs, defs)
|
||||
self._update_extension("PIL.lib_imaging", libs, defs)
|
||||
|
||||
#
|
||||
# additional libraries
|
||||
|
@ -891,8 +894,15 @@ class pil_build_ext(build_ext):
|
|||
self._remove_extension("PIL._imagingcms")
|
||||
|
||||
if feature.webp:
|
||||
libs = [feature.webp, feature.webp + "mux", feature.webp + "demux"]
|
||||
self._update_extension("PIL._webp", libs)
|
||||
libs = [
|
||||
f"_imaging{EXT_SUFFIX}",
|
||||
feature.webp,
|
||||
feature.webp + "mux",
|
||||
feature.webp + "demux",
|
||||
]
|
||||
ext = self._update_extension("PIL._webp", libs)
|
||||
ext.library_dirs.append(f"{self.build_lib}/PIL/")
|
||||
ext.runtime_library_dirs.append("$ORIGIN")
|
||||
else:
|
||||
self._remove_extension("PIL._webp")
|
||||
|
||||
|
@ -972,7 +982,7 @@ for src_file in _IMAGING:
|
|||
for src_file in _LIB_IMAGING:
|
||||
files.append(os.path.join("src/libImaging", src_file + ".c"))
|
||||
ext_modules = [
|
||||
Extension("PIL._imaging", files),
|
||||
Extension("PIL.lib_imaging", files),
|
||||
Extension("PIL._imagingft", ["src/_imagingft.c"]),
|
||||
Extension("PIL._imagingcms", ["src/_imagingcms.c"]),
|
||||
Extension("PIL._webp", ["src/_webp.c"]),
|
||||
|
|
|
@ -12,7 +12,7 @@ from . import Image
|
|||
from ._deprecate import deprecate
|
||||
|
||||
modules = {
|
||||
"pil": ("PIL._imaging", "PILLOW_VERSION"),
|
||||
"pil": ("PIL.lib_imaging", "PILLOW_VERSION"),
|
||||
"tkinter": ("PIL._tkinter_finder", "tk_version"),
|
||||
"freetype2": ("PIL._imagingft", "freetype2_version"),
|
||||
"littlecms2": ("PIL._imagingcms", "littlecms_version"),
|
||||
|
@ -128,7 +128,7 @@ features: dict[str, tuple[str, str | bool, str | None]] = {
|
|||
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
||||
"libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO", "libjpeg_turbo_version"),
|
||||
"libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT", "imagequant_version"),
|
||||
"xcb": ("PIL._imaging", "HAVE_XCB", None),
|
||||
"xcb": ("PIL.lib_imaging", "HAVE_XCB", None),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4412,15 +4412,15 @@ setup_module(PyObject *m) {
|
|||
}
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit__imaging(void) {
|
||||
PyInit_lib_imaging(void) {
|
||||
PyObject *m;
|
||||
|
||||
static PyModuleDef module_def = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_imaging", /* m_name */
|
||||
NULL, /* m_doc */
|
||||
-1, /* m_size */
|
||||
functions, /* m_methods */
|
||||
"lib_imaging", /* m_name */
|
||||
NULL, /* m_doc */
|
||||
-1, /* m_size */
|
||||
functions, /* m_methods */
|
||||
};
|
||||
|
||||
m = PyModule_Create(&module_def);
|
||||
|
|
10
src/_webp.c
10
src/_webp.c
|
@ -16,16 +16,6 @@
|
|||
#error libwebp 0.5.0 and above is required. Upgrade libwebp or build Pillow with --disable-webp flag
|
||||
#endif
|
||||
|
||||
void
|
||||
ImagingSectionEnter(ImagingSectionCookie *cookie) {
|
||||
*cookie = (PyThreadState *)PyEval_SaveThread();
|
||||
}
|
||||
|
||||
void
|
||||
ImagingSectionLeave(ImagingSectionCookie *cookie) {
|
||||
PyEval_RestoreThread((PyThreadState *)*cookie);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* WebP Muxer Error Handling */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue
Block a user