gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 07706b8a: Configuration: Python extensions hav


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 07706b8a: Configuration: Python extensions have to be manually activated
Date: Sat, 3 Dec 2022 17:21:50 -0500 (EST)

branch: master
commit 07706b8a73352a82ed25873a8a1085e83e4cbb72
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Configuration: Python extensions have to be manually activated
    
    Until now, Gnuastro would always attempt to build the Python extensions if
    the host had the necessary Python headers. However, due to the many
    peculiarities of Python, this caused some problems for special cases where
    Python wasn't necessary at all.
    
    With this commit, Python extensions will no longer be included by default!
    Even if Python is present on the host, if the user doesn't configure
    Gnuastro with the '--with-python' option, they will not be used.
    
    This change was implemented after the feedback of Zohreh Ghaffari.
---
 NEWS                         | 11 +++++++++++
 configure.ac                 | 40 +++++++++++++++++++++-------------------
 doc/announce-acknowledge.txt |  1 +
 doc/gnuastro.texi            | 17 +++++++++++++----
 4 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/NEWS b/NEWS
index 12e2738c..e885649e 100644
--- a/NEWS
+++ b/NEWS
@@ -94,6 +94,17 @@ See the end of the file for license conditions.
 
 ** Changed features
 
+  Configuration:
+  --with-python: this has replaced the old '--without-python' option. The
+    Python extension features in the Gnuastro library are no longer built
+    by default. To have them, you need to explicitly configure Gnuastro
+    with this option. This was necessary because Python has many
+    peculiarities that were causing problems for users that don't need it
+    in Gnuastro. These features are only necessary for those who compile
+    pyGnuastro from source, most future users of pyGnuastro will be
+    installing pre-built binaries it through services like PyPI, so they
+    won't be needing it either.
+
   MakeCatalog:
   --sum: new name for the old '--brightness' column. "Brightness" has a
     specific meaning in astronomy/physics and has units of
diff --git a/configure.ac b/configure.ac
index c9274f98..36321114 100644
--- a/configure.ac
+++ b/configure.ac
@@ -766,16 +766,18 @@ AS_IF([test "x$has_topcat" = "xno"], [anywarnings=yes])
 # NOTE: If using a venv then set the $PYTHON variable to point to the
 #       python3 command of the venv before running ./configure to perform
 #       all the following checks in the venv.
-py_check_cmd='from sysconfig import get_paths; \
-              print(get_paths().get("include"))'
-np_check_cmd='from numpy import get_include; \
-              print(get_include())'
 AC_ARG_WITH([python],
-            [AS_HELP_STRING([--without-python],
+            [AS_HELP_STRING([--with-python],
                             [disable support for python])],
-            [], [with_python=yes])
+            [], [with_python=no])
 AS_IF([test "x$with_python" != xno],
       [
+        # Variables to simplify commands below.
+        py_check_cmd='from sysconfig import get_paths; \
+                      print(get_paths().get("include"))'
+        np_check_cmd='from numpy import get_include; \
+                      print(get_include())'
+
         # Checks if user has a Python version>=3.0
         AM_PATH_PYTHON(3.0,,[:])
         AS_IF([test "$PYTHON" != :],
@@ -794,7 +796,7 @@ AS_IF([test "x$with_python" != xno],
         AC_SUBST(PYTHON_INCLUDE_DIR, [$python_includedir])
       ])
 AS_IF([test "x$numpy_includedir" = x],
-      [has_numpy=0; anywarnings=yes;], [has_numpy=1;])
+      [has_numpy=0], [has_numpy=1;])
 AC_SUBST(HAVE_PYTHON, [$has_numpy])
 AM_CONDITIONAL([COND_NUMPY], [test "x$numpy_includedir" != x])
 
@@ -838,8 +840,8 @@ AS_IF([test "x$missing_mandatory" = "xyes"],
                       [ AS_ECHO([" - Missing Libgit2: https://libgit2.org";])   
                   ])
                 AS_IF([test "x$has_curl" = "x0"],
                       [ AS_ECHO([" - Missing cURL: https://curl.haxx.se";])     
                   ])
-                AS_IF([test "x$has_numpy" = "x0"],
-                      [ AS_ECHO([" - Missing Numpy (for Python wrappers): 
https://numpy.org";])    ])
+dnl             AS_IF([test "x$has_numpy" = "x0"],
+dnl                   [ AS_ECHO([" - Missing Numpy (for Python wrappers): 
https://numpy.org";])    ])
                 AS_IF([test "x$has_ds9" = "xno"],
                       [ AS_ECHO([" - Missing SAO DS9: 
https://sites.google.com/cfa.harvard.edu/saoimageds9";]) ])
                 AS_IF([test "x$has_topcat" = "xno"],
@@ -1352,16 +1354,16 @@ AS_IF([test x$enable_guide_message = xyes],
                AS_ECHO(["    to improve your Makefiles for data analysis 
workflows."])
                AS_ECHO([]) ])
 
-        AS_IF([test "x$has_numpy" = "x0"],
-              [dependency_notice=yes
-               AS_ECHO(["  - Numpy (https://numpy.org) headers couldn't be 
found within a "])
-               AS_ECHO(["    Python3 installation. If available, Gnuastro's 
library will be "])
-               AS_ECHO(["    installed with some functions that can help 
Python wrappers "])
-               AS_ECHO(["    communicate with Gnuastro's library (for example 
pyGnuastro)."])
-               AS_ECHO(["    If you are within a virtual environment, and 
Python3 is"])
-               AS_ECHO(["    available there, please set the 'PYTHON' 
environment variable"])
-               AS_ECHO(["    to the Python3 executable's absolute location."])
-               AS_ECHO([]) ])
+dnl    AS_IF([test "x$has_numpy" = "x0"],
+dnl          [dependency_notice=yes
+dnl           AS_ECHO(["  - Numpy (https://numpy.org) headers couldn't be 
found within a "])
+dnl           AS_ECHO(["    Python3 installation. If available, Gnuastro's 
library will be "])
+dnl           AS_ECHO(["    installed with some functions that can help Python 
wrappers "])
+dnl           AS_ECHO(["    communicate with Gnuastro's library (for example 
pyGnuastro)."])
+dnl           AS_ECHO(["    If you are within a virtual environment, and 
Python3 is"])
+dnl           AS_ECHO(["    available there, please set the 'PYTHON' 
environment variable"])
+dnl           AS_ECHO(["    to the Python3 executable's absolute location."])
+dnl           AS_ECHO([]) ])
 
         AS_IF([test "x$has_ds9" = "xno"],
               [dependency_notice=yes
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 34b71c95..c7f4bdbe 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -2,6 +2,7 @@ Alphabetically ordered list to acknowledge in the next release.
 
 Alejandro Serrano Borlaff
 Sepideh Eskandarlou
+Zohreh Ghaffari
 Giulia Golini
 Samane Raji
 Elham Saremi
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index daea8857..a6d92040 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -8774,13 +8774,15 @@ libjpeg is an optional dependency, with this option, 
Gnuastro will ignore any po
 Build Gnuastro without libtiff (for reading/writing to TIFF files), see 
@ref{Optional dependencies}.
 libtiff is an optional dependency, with this option, Gnuastro will ignore any 
possibly existing libtiff that may already be on the system.
 
-@item --without-python
+@item --with-python
 @cindex PyPI
 @cindex Python
-Don't build the Python interface within Gnuastro's dynamic library.
+Build the Python interface within Gnuastro's dynamic library.
 This interface can be used for easy communication with Python wrappers (for 
example, the pyGnuastro package).
-However upon installing the pyGnuastro package from PyPI, the correct 
configuration of the Gnuastro Library(with the python interface) is already 
packaged with it.
-The Python interface is only necessary if you want to build pyGnuastro from 
source.
+
+When you install the pyGnuastro package from PyPI, the correct configuration 
of the Gnuastro Library is already packaged with it (with the Python interface) 
and that is independent of your Gnuastro installation.
+The Python interface is only necessary if you want to build pyGnuastro from 
source (which is only necessary for developers).
+Therefore it has to be explicitly activated at configure time with this option.
 For more on the interface functions, see @ref{Python interface}.
 
 @end vtable
@@ -37946,6 +37948,13 @@ Hence Gnuastro's library can be directly used in 
Python wrappers.
 The functions in this section provide some low-level features to simplify the 
creation of Python modules that may want to use Gnuastro's advanced and 
powerful features directly.
 To see why Gnuastro was written in C, please see @ref{Why C}.
 
+@cartouche
+@noindent
+@strong{Python interface is not built by default:} to have the features 
described in this section, Gnuastro's library needs to be built with the 
@option{--with-python} configuration option.
+For more, on this configuration option, see @ref{Gnuastro configure options}.
+To see if the Gnuastro library that you are linking with has these features, 
you can check the value of @code{GAL_CONFIG_HAVE_PYTHON} macro, see 
@ref{Configuration information}.
+@end cartouche
+
 The Gnuastro Python Package is built using CPython.
 This entails using Python wrappers around currently existing Gnuastro library 
functions to build @url{https://docs.python.org/3/extending/extending.html#, 
Python Extension Modules}.
 It also makes use of the 
@url{https://numpy.org/doc/stable/reference/c-api/index.html, NumPy C-API} for 
dealing with data arrays.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]