Skip to content

Commit

Permalink
Trac #31333: sage.env.sage_include_directories: Remove hard dependenc…
Browse files Browse the repository at this point in the history
…y on numpy

(extracted from and needed for #29865)

`sage_include_directories` returns the basic list of include directories
for compiling extensions, not including directories obtained through
pkgconfig etc.  This basic list includes directories supplied by numpy.
This is fine for the monolithic Sage library because `numpy` is a
standard package; but in the course of modularization, we will have
various distributions that do not need the dependency on numpy.
We use try/expect around the import and call to numpy.

URL: https://trac.sagemath.org/31333
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): François Bissey
  • Loading branch information
Release Manager committed Jun 29, 2021
2 parents 265cd13 + 4550eb6 commit 1650c1a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))

# post process
if ' ' in DOT_SAGE:
if DOT_SAGE is not None and ' ' in DOT_SAGE:
if UNAME[:6] == 'CYGWIN':
# on windows/cygwin it is typical for the home directory
# to have a space in it. Fortunately, users also have
Expand Down Expand Up @@ -378,14 +378,18 @@ def sage_include_directories(use_sources=False):
sage: any(os.path.isfile(os.path.join(d, file)) for d in dirs)
True
"""
import numpy
import distutils.sysconfig

TOP = SAGE_SRC if use_sources else SAGE_LIB

return [TOP,
distutils.sysconfig.get_python_inc(),
numpy.get_include()]
dirs = [TOP,
distutils.sysconfig.get_python_inc()]
try:
import numpy
dirs.append(numpy.get_include())
except ModuleNotFoundError:
pass
return dirs

def get_cblas_pc_module_name() -> str:
"""
Expand Down

0 comments on commit 1650c1a

Please sign in to comment.