gentoo/dev-python/blake3/files/blake3-1.0.8-use-installed-library.patch
Brett A C Sheffield 74f0e59996
dev-python/blake3: do not use vendored C sources
Fix build with USE="-rust" to not use bundled outdated blake3 C sources,
but depend on dev-libs/blake3 package.

Closes: https://bugs.gentoo.org/943281
Signed-off-by: Brett A C Sheffield <bacs@librecast.net>
Signed-off-by: Sam James <sam@gentoo.org>
2026-02-09 23:44:37 +00:00

50 lines
1.6 KiB
Diff

# Link against shared blake3 library. Gentoo bug 943281.
# Set FORCE_SYSTEM_BLAKE3=1 to force use of installed system library.
diff --git a/c_impl/setup.py b/c_impl/setup.py
index 417385b..2a664f0 100644
--- a/c_impl/setup.py
+++ b/c_impl/setup.py
@@ -69,6 +69,9 @@ def is_aarch64():
def force_intrinsics():
return os.environ.get("FORCE_INTRINSICS") == "1"
+def force_system_blake3():
+ # force use of system library for blake3
+ return os.environ.get("FORCE_SYSTEM_BLAKE3") == "1"
def compile_x86_intrinsics():
object_files = []
@@ -203,9 +206,17 @@ def prepare_extension():
"vendor/blake3_dispatch.c",
"vendor/blake3_portable.c",
]
+ include_dirs=[
+ "vendor",
+ ],
+ extra_link_args = [ "-lblake3" ]
target = platform.machine()
extra_objects = []
- if is_macos():
+ if force_system_blake3():
+ print("using installed system library")
+ sources = sources[:1]
+ include_dirs = []
+ elif is_macos():
# On macOS we build a "universal" binary containing both x86 and ARM
# code.
extra_objects = compile_macos_universal_staticlib()
@@ -239,10 +250,9 @@ def prepare_extension():
return setuptools.Extension(
"blake3",
sources=sources,
- include_dirs=[
- "vendor",
- ],
+ include_dirs=include_dirs,
extra_objects=extra_objects,
+ extra_link_args=extra_link_args,
define_macros=[
("SETUP_PY_VERSION", escape_preprocessor_string(VERSION)),
("SETUP_PY_DESCRIPTION", escape_preprocessor_string(DESCRIPTION)),