Commit f651ab9b authored by Sébastien Maret's avatar Sébastien Maret
Browse files

imager: init at 4.4-01

parent 694814ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ stdenv.mkDerivation rec {
    echo "gag_doc:        $out/share/doc/" >> kernel/etc/gag.dico.lcl
  '';

  userExec = "astro class greg imager mapping sic";
  userExec = "astro class greg mapping sic";

  postInstall = ''
    mkdir -p $out/bin
+75 −0
Original line number Diff line number Diff line
diff --git a/admin/Makefile.def b/admin/Makefile.def
index 43ef322..cad3de2 100644
--- a/admin/Makefile.def
+++ b/admin/Makefile.def
@@ -306,7 +306,7 @@ endif
 
 # Apple CLANG flags (identical to GCC)
 ifeq ($(GAG_COMPILER_CKIND),clang)
-  GLOBAL_CFLAGS += -pipe -fPIC
+  GLOBAL_CFLAGS += -fPIC
   ifeq ($(RELEASE_MODE),no)
     OPTION_CFLAGS += -Wall
   endif
@@ -356,7 +356,7 @@ endif
 
 # GFORTRAN flags
 ifeq ($(GAG_COMPILER_FKIND),gfortran)
-  GLOBAL_FFLAGS += -J$(moddir) -pipe -fno-backslash -fno-range-check
+  GLOBAL_FFLAGS += -J$(moddir) -fno-backslash -fno-range-check
   ifeq ($(GAG_USE_SANITIZE),yes)
     GLOBAL_FFLAGS += -fsanitize=address -fsanitize=null
     # Can not be used with our memory(ip):
diff --git a/admin/define-system.sh b/admin/define-system.sh
index f68274d..dd1a9be 100644
--- a/admin/define-system.sh
+++ b/admin/define-system.sh
@@ -279,35 +279,22 @@ EOF
                 else
                     GAG_MACHINE=pc
                 fi
-                if which gcc > /dev/null 2>&1; then
-                    DEFAULT_CCOMPILER=gcc
-                fi
-                if which g++ > /dev/null 2>&1; then
-                    DEFAULT_CXXCOMPILER=g++
-                elif which clang++ > /dev/null 2>&1; then
-                    DEFAULT_CXXCOMPILER=clang++
-                fi
-                if which ifort > /dev/null 2>&1; then
-                    DEFAULT_FCOMPILER=ifort
-                elif which gfortran  > /dev/null 2>&1; then
-                    DEFAULT_FCOMPILER=gfortran
-                fi
             elif [ `uname -p` = "arm" ]; then
                 defsys_message "WARNING: experimental ARM support"
                 GAG_MACHINE=arm64
-                if which gcc > /dev/null 2>&1; then
-                    DEFAULT_CCOMPILER=gcc
-                fi
-                if which g++ > /dev/null 2>&1; then
-                    DEFAULT_CXXCOMPILER=g++
-                elif which clang++ > /dev/null 2>&1; then
-                    DEFAULT_CXXCOMPILER=clang++
-                fi
-                if which ifort > /dev/null 2>&1; then
-                    DEFAULT_FCOMPILER=ifort
-                elif which gfortran  > /dev/null 2>&1; then
-                    DEFAULT_FCOMPILER=gfortran
-                fi
+	    fi
+            if which clang > /dev/null 2>&1; then
+                DEFAULT_CCOMPILER=clang
+            fi
+            if which clang++ > /dev/null 2>&1; then
+                DEFAULT_CXXCOMPILER=clang++
+            elif which g++ > /dev/null 2>&1; then
+                DEFAULT_CXXCOMPILER=g++
+            fi
+            if which ifort > /dev/null 2>&1; then
+                DEFAULT_FCOMPILER=ifort
+            elif which gfortran  > /dev/null 2>&1; then
+                DEFAULT_FCOMPILER=gfortran
             fi ;;
         CYGWIN*)
             if [ `uname -m | grep -c "x86_64"` -ne 0 ]; then
+13 −0
Original line number Diff line number Diff line
diff --git a/admin/Makefile.def b/admin/Makefile.def
index 27a1c02..43ef322 100644
--- a/admin/Makefile.def
+++ b/admin/Makefile.def
@@ -228,7 +228,7 @@ GLOBAL_DIRTY = $(builddir) *~ TAGS ChangeLog* Makefile.bak
 # Fortran preprocessing
 
 # Preprocessor command
-CPP = cpp
+CPP = $(GAG_CPP)
 
 # Preprocessor generic flags
 GLOBAL_CPPFLAGS += -P -traditional -C
+112 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchurl,
  gtk2-x11,
  pkg-config,
  python3,
  gfortran,
  cfitsio,
  getopt,
  perl,
  groff,
  which,
  darwin,
  ncurses,
  makeWrapper,
}:

let
  python3Env = python3.withPackages (
    ps: with ps; [
      numpy
      setuptools
    ]
  );
in

stdenv.mkDerivation (finalAttrs: {
  version = "4.4-01";
  pname = "imager";

  src = fetchurl {
    # The recommended download link is on Nextcloud instance that
    # requires to accept some general terms of use. Use a mirror at
    # univ-grenoble-alpes.fr instead.
    url = "https://cloud.univ-grenoble-alpes.fr/s/J6yEqA6yZ8tX9da/download?path=%2F&files=imager-dec24.tar.gz";
    hash = "sha256-Pq92IsGY4heekm5zNGngnp6J6YiCHYAyuMT2RsD1/9o=";
  };

  nativeBuildInputs = [
    pkg-config
    groff
    perl
    getopt
    gfortran
    which
    makeWrapper
  ];

  buildInputs = [
    gtk2-x11
    cfitsio
    python3Env
    ncurses
  ];

  patches = [
    # Update the Python link flag script from Gildas upstream
    # version. This patch will be included in the the IMAGER release.
    ./python-ldflags.patch
    # Use Clang as the default compiler on Darwin.
    ./clang.patch
    # Replace hardcoded cpp with GAG_CPP (see below).
    ./cpp-darwin.patch
  ];

  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";

  # Workaround for https://github.com/NixOS/nixpkgs/issues/304528
  env.GAG_CPP = if stdenv.hostPlatform.isDarwin then "${gfortran.outPath}/bin/cpp" else "cpp";

  postPatch = ''
    substituteInPlace utilities/main/gag-makedepend.pl --replace-fail '/usr/bin/perl' ${lib.getExe perl}
  '';

  configurePhase = ''
    source admin/gildas-env.sh -c gfortran -o openmp
    echo "gag_doc:        $out/share/doc/" >> kernel/etc/gag.dico.lcl
  '';

  postInstall = ''
    cp -a ../gildas-exe/* $out
    mv $out/$GAG_EXEC_SYSTEM $out/libexec
    makeWrapper $out/libexec/bin/imager $out/bin/imager \
       --set GAG_ROOT_DIR $out \
       --set GAG_PATH $out/etc \
       --set GAG_EXEC_SYSTEM libexec \
       --set GAG_GAG \$HOME/.gag \
       --set PYTHONHOME ${python3Env} \
       --prefix PYTHONPATH : $out/libexec/python \
       --set LD_LIBRARY_PATH $out/libexec/lib/
  '';

  meta = {
    description = "Interferometric imaging package";
    longDescription = ''
      IMAGER is an interferometric imaging package in the GILDAS software,
      tailored for usage simplicity and efficiency for multi-spectral data sets.

      IMAGER was developed and optimized to handle large data files.
      Therefore, IMAGER works mostly on internal buffers and avoids as much as possible
      saving data to intermediate files.
      File saving is done ultimately once the data analysis process is complete,
      which offers an optimum use of the disk bandwidth.
    '';
    homepage = "https://imager.oasu.u-bordeaux.fr";
    license = lib.licenses.free;
    maintainers = [ lib.maintainers.smaret ];
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };

})
+104 −0
Original line number Diff line number Diff line
diff --git a/admin/python-config-ldflags.py b/admin/python-config-ldflags.py
index 0854698..f397a7c 100644
--- a/admin/python-config-ldflags.py
+++ b/admin/python-config-ldflags.py
@@ -1,38 +1,70 @@
-#!/usr/bin/env python
+# This scripts retrieves the proper options to be used to link against
+# the libpython, in a machine-independant way. It invokes the official
+# script python-config (which thankfully deals with all the details).
 
-# DUPLICATE of "python-config --ldflags", fixed for the library location
+import sys
+newerpython = (sys.version_info[0] == 3 and sys.version_info[1] > 7)
 
-# This utility is known to work with:
-#  python2.6 (system install)   under SL6.4
-#  python2.7 (custom install)   under SL6.4
-#  python3.4 (custom install)   under SL6.4
-#  python2.7 (system install)   under Fedora20
-#  python2.7 (Apple install)    under MacOSX
-#  python2.7 (MacPorts install) under MacOSX
-#  python3.4 (MacPorts install) under MacOSX
+if newerpython:
+  # From now on avoid duplicating python-config, which evolves on its own.
+  # Invoke 'python-config --ldflags --embed'. The embed option (under
+  # Python 3) adds the libpython itself, whose name is highly
+  # unpredictible under the variety of machines and configurations we
+  # support
+  import subprocess
+  output = subprocess.check_output(['python-config', '--ldflags','--embed'])
+  output = output.decode('utf-8')
+  #print(output)
 
-import sys
-import sysconfig
+  args = output.split()
 
-pyver = sysconfig.get_config_var('VERSION')
-getvar = sysconfig.get_config_var
+  output = ''
+  for arg in args:
+    # Discard /usr/lib* path which causes troubles on the link command
+    # line, as it basically overrides all other custom paths coming after
+    # it. No need to put these paths on command line, they are found
+    # implicitly by the linker.
+    if arg not in ['-L/usr/lib','-L/usr/lib32','-L/usr/lib64']:
+      output += arg+' '
+
+  print(output)
 
-libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
-if (hasattr(sys,'abiflags')):
-  libs.append('-lpython' + pyver + sys.abiflags)
 else:
-  libs.append('-lpython' + pyver)
+  # DUPLICATE of "python-config --ldflags", fixed for the library location
+  # This proved to work gracefully up to Python 3.5 (exact limit unclear)
+
+  # This utility is known to work with:
+  #  python2.6 (system install)   under SL6.4
+  #  python2.7 (custom install)   under SL6.4
+  #  python3.4 (custom install)   under SL6.4
+  #  python3.7 (custom install)   under Debian12
+  #  python2.7 (system install)   under Fedora20
+  #  python2.7 (Apple install)    under MacOSX
+  #  python2.7 (MacPorts install) under MacOSX
+  #  python3.4 (MacPorts install) under MacOSX
+
+  import sys
+  import sysconfig
+
+  pyver = sysconfig.get_config_var('VERSION')
+  getvar = sysconfig.get_config_var
+
+  libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
+  if (hasattr(sys,'abiflags')):
+    libs.append('-lpython' + pyver + sys.abiflags)
+  else:
+    libs.append('-lpython' + pyver)
 
-# Add the library path, except /usr/lib* which causes troubles
-# on the link command line, as it basically overrides all other
-# custom paths coming after it. No need to put these paths on
-# command line, they are found implicitly by the linker.
-ldpath = getvar('LIBDIR')
-if ldpath not in ['/usr/lib','/usr/lib32','/usr/lib64']:
-  libs.insert(0, '-L' + getvar('LIBDIR'))
+  # Add the library path, except /usr/lib* which causes troubles
+  # on the link command line, as it basically overrides all other
+  # custom paths coming after it. No need to put these paths on
+  # command line, they are found implicitly by the linker.
+  ldpath = getvar('LIBDIR')
+  if ldpath not in ['/usr/lib','/usr/lib32','/usr/lib64']:
+    libs.insert(0, '-L' + getvar('LIBDIR'))
 
-# Framework (specific for Mac)
-if not getvar('PYTHONFRAMEWORK'):
-    libs.extend(getvar('LINKFORSHARED').split())
+  # Framework (specific for Mac)
+  if not getvar('PYTHONFRAMEWORK'):
+      libs.extend(getvar('LINKFORSHARED').split())
 
-print(' '.join(libs))
+  print(' '.join(libs))