sage.env.sage_include_directories: Remove hard dependency on numpy
Closed this issue · 21 comments
(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.
CC: @kiwifb @tobiasdiez
Component: refactoring
Author: Matthias Koeppe
Branch/Commit: 4550eb6
Reviewer: François Bissey
Issue created by migration from https://trac.sagemath.org/ticket/31333
Author: Matthias Koeppe
New commits:
19776a3 | sage.env.sage_include_directories: Do not fail if numpy cannot be imported |
Description changed:
---
+++
@@ -1 +1 @@
-
+(extracted from #29865)Branch pushed to git repo; I updated commit sha1. New commits:
e16ba2d | src/sage/doctest/control.py: Do not fail if sage.libs.arb cannot be imported |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
I think there should still be a log message if numpy couldn't be found, since otherwise errors further down the compile chain might be hard to track down.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
4550eb6 | sage.env.sage_include_directories: Do not fail if numpy cannot be imported |
Description changed:
---
+++
@@ -1 +1,2 @@
-(extracted from #29865)
+(extracted from and needed for #29865)
+The branch looks fine. Can the description be a bit more verbose on what this change will achieve? Obviously it makes the thing touched more resilient but for what purpose.
Description changed:
---
+++
@@ -1,2 +1,6 @@
(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.
+
+Reviewer: François Bissey
LGTM.
Thanks!
+ try:
+ import numpy
+ dirs.append(numpy.get_include())
+ except ModuleNotFoundError:
+ pass
Should this not better print an error message in case numpy is not found?
No, the whole point of this ticket is that it's not an error.
Changed branch from u/mkoeppe/sage_env_sage_include_directories__remove_hard_dependency_on_numpy to 4550eb6