push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
# FIXME: make gdk-pixbuf dependency optional
{
stdenv,
buildPythonPackage,
pythonOlder,
fetchPypi,
lib,
replaceVars,
pikepdf,
pytestCheckHook,
cairo,
cffi,
flit-core,
numpy,
withXcffib ? false,
xcffib,
glib,
gdk-pixbuf,
}:
buildPythonPackage rec {
pname = "cairocffi";
version = "1.7.1";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchPypi {
inherit pname version;
hash = "sha256-LkjuhkiE7Eo6NL+oyauZmfaIKG63FKFaQ+ydBow2VXs=";
};
patches = [
# OSError: dlopen() failed to load a library: gdk-pixbuf-2.0 / gdk-pixbuf-2.0-0
(replaceVars ./dlopen-paths.patch {
ext = stdenv.hostPlatform.extensions.sharedLibrary;
cairo = cairo.out;
glib = glib.out;
gdk_pixbuf = gdk-pixbuf.out;
})
./fix_test_scaled_font.patch
];
nativeBuildInputs = [ flit-core ];
propagatedBuildInputs = [
cairo
cffi
]
++ lib.optional withXcffib xcffib;
nativeCheckInputs = [
numpy
pikepdf
pytestCheckHook
];
pythonImportsCheck = [ "cairocffi" ];
# Cairo tries to load system fonts by default.
# It's surfaced as a Cairo "out of memory" error in tests.
__impureHostDeps = [ "/System/Library/Fonts" ];
meta = with lib; {
changelog = "https://github.com/Kozea/cairocffi/blob/v${version}/NEWS.rst";
homepage = "https://github.com/SimonSapin/cairocffi";
license = licenses.bsd3;
maintainers = [ ];
description = "cffi-based cairo bindings for Python";
};
}

View File

@@ -0,0 +1,54 @@
Patch dlopen() to allow direct paths to all required libs
diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
index f917d90..31dab12 100644
--- a/cairocffi/__init__.py
+++ b/cairocffi/__init__.py
@@ -22,6 +22,14 @@ VERSION = __version__ = '1.7.1'
version = '1.17.2'
version_info = (1, 17, 2)
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be
+# required for runtime
+_LIBS = {
+ 'cairo': '@cairo@/lib/libcairo@ext@',
+ 'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
+ 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
+ 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
+}
# Python 3.8 no longer searches for DLLs in PATH, so we can add everything in
# CAIROCFFI_DLL_DIRECTORIES manually. Note that unlike PATH, add_dll_directory
@@ -36,26 +44,14 @@ if dll_directories and hasattr(os, 'add_dll_directory'):
def dlopen(ffi, library_names, filenames):
"""Try various names for the same library, for different platforms."""
- exceptions = []
-
for library_name in library_names:
- library_filename = find_library(library_name)
- if library_filename:
- filenames = (library_filename, *filenames)
- else:
- exceptions.append(
- 'no library called "{}" was found'.format(library_name))
-
- for filename in filenames:
- try:
- return ffi.dlopen(filename)
- except OSError as exception: # pragma: no cover
- exceptions.append(exception)
-
- error_message = '\n'.join( # pragma: no cover
- str(exception) for exception in exceptions)
- raise OSError(error_message) # pragma: no cover
+ path = _LIBS.get(library_name, None)
+ if path:
+ lib = ffi.dlopen(path)
+ if lib:
+ return lib
+ raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path))
cairo = dlopen(
ffi, ('cairo-2', 'cairo', 'libcairo-2'),

View File

@@ -0,0 +1,11 @@
--- a/cairocffi/test_cairo.py 2016-09-01 07:52:33.303180302 +0200
+++ b/cairocffi/test_cairo.py 2016-09-01 09:06:19.595701944 +0200
@@ -998,7 +998,7 @@
font = ScaledFont(ToyFontFace('monospace'))
_, _, _, _, x_advance_mono, y_advance = font.text_extents('i' * 10)
- assert x_advance_mono > x_advance
+ assert x_advance_mono >= x_advance
assert y_advance == 0
# Not much we can test:
# The toy font face was "materialized" into a specific backend.