10000 Fix wheels' bundled libcurl.so incompatibility with Debian [HACK] · pysam-developers/pysam@b18dde8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b18dde8

Browse files
committed
Fix wheels' bundled libcurl.so incompatibility with Debian [HACK]
Linux wheels are (currently) built on AlmaLinux, so the libcurl.so bundled into the wheel follows Alma/Red Hat/Fedora conventions for the location of its certificate bundle. This fails when the wheel is used on a Debian/Ubuntu platform with a different convention for this location. When not overridden by $CURL_CA_BUNDLE, work around this by specifying the expected Debian bundle location if the Red Hat one isn't present. Fixes #1257 via a hacky work around. (Take care to preserve this patch when importing HTSlib in future.)
1 parent 82634f1 commit b18dde8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

htslib/hfile_libcurl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ DEALINGS IN THE SOFTWARE. */
3434
#ifndef _WIN32
3535
# include <sys/select.h>
3636
#endif
37+
#include <sys/stat.h>
3738
#include <assert.h>
3839

3940
#include "hfile_internal.h"
@@ -1246,6 +1247,19 @@ libcurl_open(const char *url, const char *modes, http_headers *headers)
12461247
if (env_curl_ca_bundle) {
12471248
err |= curl_easy_setopt(fp->easy, CURLOPT_CAINFO, env_curl_ca_bundle);
12481249
}
1250+
#if defined __linux__ && defined BUILDING_WHEEL
1251+
else {
1252+
// Linux wheels are (currently) built on AlmaLinux, so the libcurl.so bundled
1253+
// into the wheel follows Alma/Red Hat/Fedora conventions for the location of
1254+
// its certificate bundle. This fails when the wheel is used on a Debian/Ubuntu
1255+
// platform with a different convention for this location. When not overridden
1256+
// by $CURL_CA_BUNDLE, work around this by specifying the expected Debian bundle
1257+
// location if the Red Hat one isn't present.
1258+
struct stat st;
1259+
if (stat("/etc/pki", &st) < 0 && errno == ENOENT)
1260+
err |= curl_easy_setopt(fp->easy, CURLOPT_CAINFO, "/etc/ssl/certs/ca-certificates.crt");
1261+
}
1262+
#endif
12491263
}
12501264
err |= curl_easy_setopt(fp->easy, CURLOPT_USERAGENT, curl.useragent.s);
12511265
if (fp->headers.callback) {

setup.py

Lines changed: 9 additions & 1 deletion
Original file line number< EF71 /th>Diff line numberDiff line change
@@ -186,6 +186,10 @@ def set_compiler_envvars():
186186
del os.environ[var]
187187

188188

189+
def format_macro_option(name, value):
190+
return f"-D{name}={value}" if value is not None else f"-D{name}"
191+
192+
189193
def configure_library(library_dir, env_options=None, options=[]):
190194

191195
configure_script = os.path.join(library_dir, "configure")
@@ -532,6 +536,9 @@ def run(self):
532536

533537
define_macros = []
534538

539+
if os.environ.get("CIBUILDWHEEL", "0") == "1":
540+
define_macros.append(("BUILDING_WHEEL", None))
541+
535542
suffix = sysconfig.get_config_var('EXT_SUFFIX')
536543

537544
internal_htslib_libraries = [
@@ -567,7 +574,8 @@ def prebuild_libchtslib(ext, force):
567574
# TODO Eventually by running configure here, we can set these
568575
# extra flags for configure instead of hacking on ALL_CPPFLAGS.
569576
args = " ".join(ext.extra_compile_args)
570-
run_make(["ALL_CPPFLAGS=-I. " + args + " $(CPPFLAGS)", "lib-static"])
577+
defines = " ".join([format_macro_option(*pair) for pair in ext.define_macros])
578+
run_make(["ALL_CPPFLAGS=-I. " + args + " " + defines + " $(CPPFLAGS)", "lib-static"])
571579
else:
572580
log.warning("skipping 'libhts.a' (already built)")
573581

0 commit comments

Comments
 (0)
0