Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.env.cython_aliases: Handle ecl via default_required_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed May 5, 2022
1 parent eb1a786 commit 32c831c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def get_cblas_pc_module_name() -> str:


default_required_modules = ('fflas-ffpack', 'givaro', 'gsl', 'linbox', 'Singular',
'libpng', 'gdlib', 'm4ri', 'zlib', 'cblas')
'libpng', 'gdlib', 'm4ri', 'zlib', 'cblas', 'ecl')


default_optional_modules = ('lapack',)
Expand Down Expand Up @@ -481,6 +481,22 @@ def cython_aliases(required_modules=None,
from collections import defaultdict
pc = defaultdict(list, {'libraries': ['z']})
libs = "-lz"
elif lib == 'ecl':
try:
# Determine ecl-specific compiler arguments using the ecl-config script
ecl_cflags = subprocess.run([ECL_CONFIG, "--cflags"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split()
ecl_libs = subprocess.run([ECL_CONFIG, "--libs"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split()
except subprocess.CalledProcessError:
if required:
raise
else:
continue
aliases["ECL_CFLAGS"] = list(filter(lambda s: not s.startswith('-I'), ecl_cflags))
aliases["ECL_INCDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-I'), ecl_cflags)))
aliases["ECL_LIBDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-L'), ecl_libs)))
aliases["ECL_LIBRARIES"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-l'), ecl_libs)))
aliases["ECL_LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), ecl_libs))
continue
else:
try:
aliases[var + "CFLAGS"] = pkgconfig.cflags(lib).split()
Expand Down Expand Up @@ -537,15 +553,6 @@ def uname_specific(name, value, alternative):
except (ValueError, KeyError):
pass

# Determine ecl-specific compiler arguments using the ecl-config script
ecl_cflags = subprocess.run([ECL_CONFIG, "--cflags"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split()
aliases["ECL_CFLAGS"] = list(filter(lambda s: not s.startswith('-I'), ecl_cflags))
aliases["ECL_INCDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-I'), ecl_cflags)))
ecl_libs = subprocess.run([ECL_CONFIG, "--libs"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split()
aliases["ECL_LIBDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-L'), ecl_libs)))
aliases["ECL_LIBRARIES"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-l'), ecl_libs)))
aliases["ECL_LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), ecl_libs))

# NTL
aliases["NTL_CFLAGS"] = ['-std=c++11']
aliases["NTL_INCDIR"] = [NTL_INCDIR] if NTL_INCDIR else []
Expand Down

0 comments on commit 32c831c

Please sign in to comment.