Repository: sagemath/sage

Issue:
spkg-configure for symengine
<div id="comment:0"></div>

symengine does not seem to have pkg-configure interface, so we need to test something

CC:  @orlitzky @mkoeppe @isuruf @slel

Component: **build: configure**

_Issue created by migration from https://trac.sagemath.org/ticket/32421_




Discussion:
<div id="comment:3" align="right">comment:3</div>

Note that the Python wrapper `symengine.py` uses CMake to find the library (via the CMake metadata installed in `local/lib/cmake/symengine`) - so that's what `spkg-configure.m4` should use too. Of course, this assumes that system `cmake` is available; but I think it's fine to only use system `symengine` when also system `cmake` is present.
<div id="comment:4" align="right">comment:4</div>

Replying to [@mkoeppe](#comment%3A3):
> Note that the Python wrapper `symengine.py` uses CMake to find the library (via the CMake metadata installed in `local/lib/cmake/symengine`) - so that's what `spkg-configure.m4` should use too. 


This requires writing cmake config script, i.e. `CMakeLists.txt`, as far as I can see.
Integrating this into `spkg-configure.m4` is above my pay grade...
<div id="comment:5" align="right">comment:5</div>

See https://github.com/symengine/symengine/wiki/Using-SymEngine-from-a-Cpp-project#non-cmake-projects
<div id="comment:6" align="right">comment:6</div>

Replying to [@isuruf](#comment%3A5):
> See https://github.com/symengine/symengine/wiki/Using-SymEngine-from-a-Cpp-project#non-cmake-projects

and how about asking for the version?
<div id="comment:7" align="right">comment:7</div>

If we need a specific feature in newer versions of symengine, we can test for that feature instead of the version. And if nobody knows what features we need... then as a last resort, we can accept any version of symengine, and any consequent bug reports will tell us what we should have checked for.
<div id="comment:8" align="right">comment:8</div>

There's a `symengine_version()` C function that you can call to get it.
Or you can use the following program to see if it compiles,

```
#include <symengine/symengine_config.h>
#if (SYMENGINE_MAJOR_VERSION*10000 + SYMENGINE_MINOR_VERSION*100 + SYMENGINE_PATCH_VERSION < 00700)
# error "SymEngine 0.7.0 or newer is required"
error
#endif
```
<div id="comment:9" align="right">comment:9</div>

Replying to [@dimpase](#comment%3A4):
> Replying to [@mkoeppe](#comment%3A3):
> > Note that the Python wrapper `symengine.py` uses CMake to find the library (via the CMake metadata installed in `local/lib/cmake/symengine`) - so that's what `spkg-configure.m4` should use too. 
> 
> 
> 
> This requires writing cmake config script, i.e. `CMakeLists.txt`, as far as I can see.
> Integrating this into `spkg-configure.m4` is above my pay grade...
> 

Just create a directory `conftest.dir` and generate the file in there

Resolving patch:
diff --git a/src/sage/features/symengine_py.py b/src/sage/features/symengine_py.py
new file mode 100644
--- /dev/null
+++ b/src/sage/features/symengine_py.py
@@ -0,0 +1,43 @@
+r"""
+Check for symengine_py
+"""
+
+# ****************************************************************************
+#       Copyright (C) 2023 Dima Pasechnik
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#                  https://www.gnu.org/licenses/
+# ****************************************************************************
+
+from . import PythonModule
+from .join_feature import JoinFeature
+
+
+class symengine_py(JoinFeature):
+    r"""
+    A :class:`sage.features.Feature` describing the presence of the
+    Python package :ref:`symengine_py <spkg_symengine_py>`.
+
+    EXAMPLES::
+
+        sage: from sage.features.symengine_py import symengine_py
+        sage: symengine_py().is_present()                    # optional - symengine_py
+        FeatureTestResult('symengine_py', True)
+    """
+    def __init__(self):
+        r"""
+        TESTS::
+
+            sage: from sage.features.symengine_py import symengine_py
+            sage: isinstance(symengine_py(), symengine_py)
+            True
+        """
+        JoinFeature.__init__(self, 'symengine_py',
+                             [PythonModule('symengine', spkg="symengine_py",
+                                            url="https://pypi.org/project/symengine")])
+
+def all_features():
+    return [symengine_py()]


Test patch: