Skip to content

Commit

Permalink
Trac #33055: conda-forge: Fix build of python3 spkg
Browse files Browse the repository at this point in the history
(split out from #32113)

URL: https://trac.sagemath.org/33055
Reported by: mkoeppe
Ticket author(s): Isuru Fernando
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager committed Mar 1, 2022
2 parents beedaab + 3bcfde1 commit 490fdfd
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From aef4a7749dec9ecf942647af39d7a1303c758131 Mon Sep 17 00:00:00 2001
From: Isuru Fernando <[email protected]>
Date: Thu, 16 Sep 2021 15:46:09 -0500
Subject: [PATCH 08/24] bpo-22699: Allow compiling on debian/ubuntu with a
different compiler

This PR fixes one issue mentioned in the bpo
https://bugs.python.org/issue22699#msg364685 with a slightly better
patch than given
---
setup.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 8fb8ea5c47..783d20bdcd 100644
--- a/setup.py
+++ b/setup.py
@@ -663,9 +663,30 @@ def add_multiarch_paths(self):
# Debian/Ubuntu multiarch support.
# https://wiki.ubuntu.com/MultiarchSpec
cc = sysconfig.get_config_var('CC')
- tmpfile = os.path.join(self.build_temp, 'multiarch')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
+
+ tmpfile_sysroot = os.path.join(self.build_temp, 'sysroot')
+ ret_sysroot = run_command(
+ '%s -print-sysroot > %s 2> /dev/null' % (cc, tmpfile_sysroot))
+
+ try:
+ if ret_sysroot == 0:
+ with open(tmpfile_sysroot) as fp:
+ sysroot = fp.readline().strip()
+ # if the sysroot is not /, then we are not using
+ # the compiler from debian/ubuntu
+ if sysroot not in ['', '/']:
+ add_dir_to_list(self.compiler.library_dirs,
+ sysroot + '/usr/lib')
+ add_dir_to_list(self.compiler.include_dirs,
+ sysroot + '/usr/include')
+ return
+ finally:
+ os.unlink(tmpfile_sysroot)
+
+ tmpfile = os.path.join(self.build_temp, 'multiarch')
+
ret = run_command(
'%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
multiarch_path_component = ''
--- a/setup.py 2021-09-28 23:49:53.193868987 -0700
+++ b/setup.py 2021-09-28 23:50:13.554098642 -0700
@@ -738,7 +738,8 @@
for env_var, arg_name, dir_list in (
('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
('LDFLAGS', '-L', self.compiler.library_dirs),
- ('CPPFLAGS', '-I', self.compiler.include_dirs)):
+ ('CPPFLAGS', '-I', self.compiler.include_dirs),
+ ('CPPFLAGS', '-isystem', self.compiler.include_dirs)):
env_val = sysconfig.get_config_var(env_var)
if env_val:
parser = argparse.ArgumentParser()
--
2.30.2

2 changes: 1 addition & 1 deletion build/pkgs/python3/spkg-build.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ sdh_configure --enable-shared $PYTHON_CONFIGURE
# we need to provide paths into $SAGE_LOCAL, so that setup.py finds
# the libraries needed for the extension modules - in particular sqlite3.
# (The search code there does not know about CPATH and LIBRARY_PATH.)
make_LDFLAGS="-L. -L$SAGE_LOCAL/lib $LDFLAGS"
make_LDFLAGS="-L. -Wl,-rpath,. -L$SAGE_LOCAL/lib $LDFLAGS"
make_CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"

# Also, we need to add an rpath, like we do for SAGE_LOCAL in src/bin/sage-env.
Expand Down

0 comments on commit 490fdfd

Please sign in to comment.