Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

cp316 drops required macro for Pillow to compile

已关闭
#10,323 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lazerg 已经在做这个了。

开始于 2026年10月26日。

  • #10324 来自 @lazerg —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, python
领域
build-system

调研方向

Start with src/libImaging/ImPlatform.h and inspect the HAVE_PROTOTYPES check alongside Pillow’s supported Python versions and C requirements. Reproduce the build failure using the reported CPython main branch and GCC or Clang, then check compatibility across the support window. Done when Pillow builds on CPython main without breaking its supported older Python versions.

由索引模型根据 Issue 内容生成。

描述

What did you do?

Tried to compile from source with cpython main branch

What did you expect to happen?

It to compile.

What actually happened?

Failed to compile.

What are your OS, Python and Pillow versions?
  • OS: arch, gcc (gcc (GCC) 16.2.1 20260810) or clang (clang version 23.1.4)
  • Python: main branch (v3.16.0a1-393-ga9049ee4fb6)
  • Pillow: main branch (1.7.6-21484-g5e898683d)
      In file included from src/libImaging/Imaging.h:13,
                       from src/libImaging/Effects.c:18:
      src/libImaging/ImPlatform.h:15:2: error: #error Sorry, this library requires support for ANSI prototypes.
         15 | #error Sorry, this library requires support for ANSI prototypes.
            |  ^~~~~
      In file included from src/libImaging/Imaging.h:13,
                       from src/libImaging/Draw.c:35:
      src/libImaging/ImPlatform.h:15:2: error: #error Sorry, this library requires support for ANSI prototypes.
         15 | #error Sorry, this library requires support for ANSI prototypes.
            |  ^~~~~
      error: Command ['gcc', '-DCYTHON_FAST_THREAD_STATE=0', '-fPIC', '-DHAVE_LIBTIFF', '-DHAVE_LIBJPEG', '-DHAVE_OPENJPEG', '-DHAVE_LIBZ', '-DHAVE_LIBIMAGEQUANT', '-DHAVE_XCB', '-DPILLOW_VERSION="13.1.0.dev0"', '-I/usr/include/freetype2', '-I/usr/include/openjpeg-2.5', '-I/usr/include', '-I/usr/include/webp', '-I/usr/include/libpng16', '-I/usr/include/harfbuzz', '-I/usr/include/glib-2.0', '-I/usr/lib/glib-2.0/include', '-I/usr/include/sysprof-6', '-I/usr/include/fribidi', '-I/home/tcaswell/.virtualenvs/cp316/include', '-I/usr/local/include', '-I/home/tcaswell/.virtualenvs/cp316/include', '-I/home/tcaswell/.pybuild/cp316/include/python3.16', '-c', 'src/libImaging/ColorLUT.c', '-o', 'build/temp.linux-x86_64-cpython-316/src/libImaging/ColorLUT.o'] returned non-zero exit status 1.
      [end of output]
     error: Command ['clang', '-DCYTHON_FAST_THREAD_STATE=0', '-fPIC', '-DHAVE_LIBTIFF', '-DHAVE_LIBJPEG', '-DHAVE_OPENJPEG', '-DHAVE_LIBZ', '-DHAVE_LIBIMAGEQUANT', '-DHAVE_XCB', '-DPILLOW_VERSION="13.1.0.dev0"', '-I/usr/include/freetype2', '-I/usr/include/openjpeg-2.5', '-I/usr/include', '-I/usr/include/webp', '-I/usr/include/libpng16', '-I/usr/include/harfbuzz', '-I/usr/include/glib-2.0', '-I/usr/lib/glib-2.0/include', '-I/usr/include/sysprof-6', '-I/usr/include/fribidi', '-I/home/tcaswell/.virtualenvs/cp316-clang/include', '-I/usr/local/include', '-I/home/tcaswell/.virtualenvs/cp316-clang/include', '-I/home/tcaswell/.pybuild/cp316-clang/include/python3.16', '-c', 'src/libImaging/Arrow.c', '-o', 'build/temp.linux-x86_64-cpython-316/src/libImaging/Arrow.o'] returned non-zero exit status 1.
      src/_imaging.c:1324:84: warning: implicit conversion from enumeration type 'const ModeID' to different enumeration type 'RawModeID' [-Wimplicit-enum-enum-cast]
       1324 |     const RawModeID rawmode = rawmode_name != NULL ? findRawModeID(rawmode_name) : mode;
            |                     ~~~~~~~                                                        ^~~~
      1 error generated.
      In file included from src/libImaging/ColorLUT.c:1:
      In file included from src/libImaging/Imaging.h:13:
      src/libImaging/ImPlatform.h:15:2: error: Sorry, this library requires support for ANSI prototypes.
         15 | #error Sorry, this library requires support for ANSI prototypes.
            |  ^
      1 error generated.
      1 error generated.
      1 warning and 1 error generated.
      In file included from src/libImaging/Draw.c:35:
      In file included from src/libImaging/Imaging.h:13:
      src/libImaging/ImPlatform.h:15:2: error: Sorry, this library requires support for ANSI prototypes.
         15 | #error Sorry, this library requires support for ANSI prototypes.
            |  ^
      1 error generated.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.

The source of the problem is that upstream removed the HAVE_PROTOTYPES macro in https://github.com/python/cpython/pull/159513 .

This minimal fix is:

diff --git a/src/libImaging/ImPlatform.h b/src/libImaging/ImPlatform.h
index a800d8278..29c4425e4 100644
--- a/src/libImaging/ImPlatform.h
+++ b/src/libImaging/ImPlatform.h
@@ -11,9 +11,6 @@
 #include <Python.h>
 
 /* Check that we have an ANSI compliant compiler */
-#ifndef HAVE_PROTOTYPES
-#error Sorry, this library requires support for ANSI prototypes.
-#endif
 #ifndef STDC_HEADERS
 #error Sorry, this library requires ANSI header files.
 #endif

but I am not sure the exact intersection of when Python's minimum C is high enough that this is unneeded and and the support window of old Python for Pillow intersect to make this safe to just drop or if it requires some version gating on CPython version.

I also leave to @hugovk if there is a case to be made to revert this upstream or just deal with it here.

主要语言
Python
星标
13.9k
派生
2.6k
平均合并
1 天 7 小时
30 天内合并 PR
174

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-pillow/Pillow 的其他 Issue

查看 python-pillow/Pillow 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。