-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify version checks for freetype and libpng. #11983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Seems fine, but we lose the ability to display the version in the event of things working, no? Probably not the end of the world, though... |
I can add a |
Seeing the version number is helpful to make sure it found the right one (ex conda vs system versions). |
63bd68f
to
bf76c9e
Compare
Sure, I always emit it now. It's no longer at the top but having the compiler do the job of figuring out what file to include (... and not trying to parse freetype.h ourselves just for the purpose of finding its version...) is the whole point of this PR, so... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg-config is the defacto standard on Linux, so I don't really agree with not using it here. I can get behind dropping freetype-config
as it's not really used in modern systems. And if you want to ignore pkg-config on Windows, I guess that's fine.
src/checkdep_freetype2.c
Outdated
|
||
#pragma message "Compiling with FreeType version " \ | ||
XSTR(FREETYPE_MAJOR) "." XSTR(FREETYPE_MINOR) "." XSTR(FREETYPE_PATCH) "." | ||
#if FREETYPE_MAJOR << 16 + FREETYPE_MINOR << 8 + FREETYPE_PATCH < 0020300 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is octal; I think you want 0x020300
, which would match the bitshifts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, fixed
And I'm also confused, because your original post in #9737 said that we should require pkg-config and drop everything else. |
bf76c9e
to
4684773
Compare
The point here is to not parse the output of pkg-config to try and figure out what is the full include path, find ourselves whether the header is present, and parse the freetype version from freetype.h. This is problematic because we try to do this even if pkg-config is not present, which leads to us manually adding "standard" include paths (/usr/include, /usr/local/include), which causes problems with cross-compilation (as reported recently on gitter) or using conda's gcc (which also uses a separate prefix). The plan is definitely to still use pkg-config/freetype-config/libpng-config to get the correct compile and link flags (in fact that's more or less needed for freetype, as the standard install needs -I$prefix/include/freetype2), but then just shove all that into extra_compile_args/extra_link_args and let the compiler do its job. |
attn @sandrotosi |
Re-pinging @QuLogic @sandrotosi after #11983 (comment). Thanks in advance for your input. |
If we're going to ultimately rely on pkg-config, then I don't think the C macro thing is required at all. We can do |
4684773
to
29b088c
Compare
The macro-checking is useful both for windows, and for unices in case you don't have pkg-config installed but are passing all flags in manually using $CFLAGS/$LDFLAGS/$CPLUS_INCLUDE_PATH/etc. |
29b088c
to
3d4feec
Compare
@QuLogic Are you still rejecting the patch after the discussion above? |
Re-ping @QuLogic (even if you still reject after the discussion above, please leave a comment as to why, thanks!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve, tentatively to the pkg-config re-enablement you mentioned you'd do.
Currently, setupext.py replicates a lot of work done by the compiler to check whether header files are present, and whether freetype and libpng have sufficiently recent versions. Instead, we can just add a small stub source file at the top of the extension sources which just tries to include the header and checks the version macros. If the header is not found, compilation will immediately abort with `foo.h: No such file or directory`; if the version is too old, we can emit an appropriate error message (`#pragma message` is supported by all major compilers and allows expanding of macros in the error message).
3d4feec
to
923ce72
Compare
(rebased and force pushed additional parentheses in |
Currently, setupext.py replicates a lot of work done by the compiler to
check whether header files are present, and whether freetype and libpng
have sufficiently recent versions.
Instead, we can just add a small stub source file at the top of the
extension sources which just tries to include the header and checks the
version macros. If the header is not found, compilation will
immediately abort with
foo.h: No such file or directory
; if theversion is too old, we can emit an appropriate error message (
#pragma message
is supported by all major compilers and allows expanding of
macros in the error message).
Work related to #9737 (the goal being to not list the include paths ourselves).
PR Summary
PR Checklist