Commits

Mathieu Courtois committed 07cb388

[BB0006] support installation of several versions under the same prefix

Use `--install-as=N.P` at configure, see `set_installdirs()` for the new
variables used at the install step.

compatibility change: ASTERDATADIR is not a list anymore
=> `waf configure` required even with updated data and validation repositories

Comments (0)

Files changed (12)

     get_srcs = self.path.get_src().ant_glob
     env = self.all_envs['default']
     self.install_files(
-        osp.join(*list(env.ASTERDATADIR + ['tests'])),
+        osp.join(env.ASTERDATADIR, 'tests'),
         get_srcs('**/*', excl='wscript'),
         relative_trick=True,
     )
     self.add_group()
     # install headers
     self.install_files(
-        osp.join(env.INCLUDEDIR, 'aster'),
+        env.ASTERINCLUDEDIR,
         get_srcs('include/*.h')
     )
     # install generated headers (C + fortran)
     bld = self.path.get_bld().parent
     config_includes = bld.ant_glob('aster*_config.h', quiet=True)
     self.install_files(
-        osp.join(env.INCLUDEDIR, 'aster'),
+        env.ASTERINCLUDEDIR,
         config_includes
     )
 
          defines = '_WITHOUT_PYMOD_',
              env = shenv.derive(),
              use = ['PYEMBED', 'NUMPY', 'asterbibfor'] + uses,
+    install_path = shenv.ASTERLIBDIR,
     )
 
     self.add_group()
           source = get_srcs('**/astercore_module.c'),
              env = shenv.derive(),
              use = ['asterlib'] + uses,
+    install_path = shenv.ASTERLIBDIR,
     )
 
     self(
           source = get_srcs('**/astermodule.c'),
              env = shenv.derive(),
              use = ['asterlib'] + uses,
+    install_path = shenv.ASTERLIBDIR,
     )
 
     self(
           source = get_srcs('**/fonctions_module.c'),
              env = shenv.derive(),
              use = ['NUMPY', 'asterlib'] + uses,
+    install_path = shenv.ASTERLIBDIR,
     )
 
     if shenv.BUILD_MED:
               source = get_srcs('**/med_aster_module.c'),
                  env = shenv.derive(),
                  use = ['asterlib'] + uses,
+        install_path = shenv.ASTERLIBDIR,
         )
 
 def build_as_embeded(self, stenv):
     # required for Intel compiler
     main = 'main' if stenv.FC_MAIN == -1 or 'ifort' in stenv.LINK_FC else stenv.FC_MAIN
 
-    tgt = (self.variant == 'release' and 'aster') or 'asterd'
+    tgt = (self.variant == 'release' and stenv.ASTERBINOPT) or stenv.ASTERBINDBG
     self(
         features = 'c fcprogram pyembed',
           target = tgt,
 # coding=utf-8
 
-import os
+import os.path as osp
 import shutil
 from pprint import pformat
 
 def build(self):
     get_srcs = self.path.get_src().ant_glob
     env = self.all_envs[self.variant]
-    if self.cmd.startswith('install'):
-        try:
-            shutil.rmtree(env.PYTHONDIR)
-        except OSError:
-            pass
+    #if self.cmd.startswith('install'):
+        #try:
+            #shutil.rmtree(env.PYTHONDIR)
+        #except OSError:
+            #pass
 
     self(
         features = 'py',
             name = 'bibpyt',
           source = get_srcs('**/*.py'),
     install_from = '.',
-    install_path = os.path.join(env.LIBDIR, 'aster'),
+    install_path = env.ASTERLIBDIR,
     )
 
     self(
             name = 'aster_pkginfo',
           source = 'aster_pkginfo.pytmpl',
           target = 'aster_pkginfo.py',
-    install_path = os.path.join(env.LIBDIR, 'aster'),
+    install_path = env.ASTERLIBDIR,
              use = ['bibpyt'],
     VERSION_INFO = pformat(env['ASTER_VERSION']),
     )
 def build(self):
     env = self.all_envs[self.variant]
     if self.cmd.startswith('uninstall'):
-        elem = osp.join(env.LIBDIR, 'aster', 'elements')
+        elem = osp.join(env.ASTERLIBDIR, 'elements')
         try:
             os.remove(elem)
         except OSError:
           target = 'elements',
              env = env,
             vars = ['CATALO_CMD'],
-    install_path = self.options.destdir + osp.join(env.LIBDIR, 'aster'),
+    install_path = self.options.destdir + env.ASTERLIBDIR,
     )
 
 @TaskGen.feature('catalo')
            name = 'catapy',
          target = 'cata.py',
          source = sources,
-   install_path = osp.join(env.LIBDIR, 'aster', 'Cata'),
+   install_path = osp.join(env.ASTERLIBDIR, 'Cata'),
     )
 
 ###############################################################################

data/config.txt.tmpl

 #
 PYTHON         | python  | -     | @PYTHON@
 #
-BIN_NODBG      | bin     | -     | @PREFIX@/bin/aster
-BIN_DBG        | bin     | -     | @PREFIX@/bin/asterd
-BINCMDE        | bin     | -     | @LIBDIR@/aster/Cata
-BINELE         | bin     | -     | @LIBDIR@/aster/elements
+BIN_NODBG      | bin     | -     | @PREFIX@/bin/aster@astervers@
+BIN_DBG        | bin     | -     | @PREFIX@/bin/asterd@astervers@
+BINCMDE        | bin     | -     | @ASTERLIBDIR@/Cata
+BINELE         | bin     | -     | @ASTERLIBDIR@/elements
 BINPICKLED     | bin     | -     | @SRC@/build/release/catalo/cata_ele.pickled
 #
 # for as_run --make_shared...
 # for as_run --messages, --get, --show..., and astout
 SRCFOR         | src     | -     | @SRC@/bibfor
 SRCC           | src     | -     | @SRC@/bibc
-SRCPY          | src     | -     | @LIBDIR@/aster
+SRCPY          | src     | -     | @ASTERLIBDIR@
 SRCCATA        | src     | -     | @SRC@/catalo
 SRCCAPY        | src     | -     | @SRC@/catapy
 @srctest@

data/profile.sh.tmpl

 export LD_LIBRARY_PATH
 
 PYTHONPATH=\
-@LIBDIR@/aster:\
+@ASTERLIBDIR@:\
 @CFG_PYTHONPATH@:\
 $PYTHONPATH
 export PYTHONPATH
     install_path = '${ASTERDATADIR}',
             vars = ['PREFIX', 'DEFINES', 'PYTHON',
                     'FC', 'FCFLAGS',
-                    'LIBPATH', 'LIBDIR', 'CFG_PYTHONPATH',
-                    'ASTERDATADIR', 'OPT_ENV', 'install_tests'],
+                    'LIBPATH', 'LIBDIR', 'CFG_PYTHONPATH', 'astervers',
+                    'ASTERDATADIR', 'ASTERLIBDIR', 'OPT_ENV', 'install_tests'],
      **dict_conv
     )
 
                     name = 'i18n_' + lang,
                     path = self.path,
                     lang = lang,
-            install_path = '${LOCALEDIR}',
+            install_path = self.env.ASTERLOCALEDIR,
             )
 
 ###############################################################################
     self.create_task('merge_po', src=[inpo, pot], tgt=outpo)
     self.create_task('compile_po', src=outpo, tgt=mof)
 
-    if not self.env.LOCALEDIR:
-        self.env.LOCALEDIR = osp.join(self.env.PREFIX, 'share', 'locale')
-    inst = getattr(self, 'install_path', '${LOCALEDIR}')
+    inst = getattr(self, 'install_path', '${ASTERLOCALEDIR}')
     if inst:
         path = osp.join(inst, self.lang, 'LC_MESSAGES')
         self.bld.install_files(path, mof)

waftools/runtest.py

         toolargs.append('--exectool=%s' % opts.exectool)
     dtmp = tempfile.mkdtemp(prefix='runtest_')
     Logs.info("destination of output files: %s" % dtmp)
-    versdir = osp.join(self.env['PREFIX'], 'share', 'aster')
     status = 0
     if not opts.testname:
         raise Errors.WafError('no testcase name provided, use the -n option')
     for test in opts.testname:
-        cmd = ['as_run', '--vers=%s' % versdir, '--test', test]
+        cmd = ['as_run', '--vers=%s' % self.env['ASTERDATADIR'], '--test', test]
         if self.variant == 'debug':
             cmd.extend(['-g', '--nodebug_stderr'])
         cmd.extend(toolargs)

waftools/scm_aster.py

        features = 'pkginfo py',
            name = 'pkginfo',
          target = 'pkginfo.py',
-   install_path = osp.join(env.LIBDIR, 'aster', 'Accas'),
+   install_path = osp.join(env.ASTERLIBDIR, 'Accas'),
     )
 
 
     group.add_option('--install-tests', dest='install_tests',
                     action='store_true', default=False,
                     help='install the testcases files')
+    group.add_option('--install-as', dest='astervers',
+                    action='store', default='',
+                    help='install as this version name, used for '
+        'subdirectories (example: X.Y will use aster/X.Y/...), '
+        "[Default: '']")
     self.recurse('bibfor')
     self.recurse('bibc')
     self.recurse('i18n')
     self.load('ext_aster', tooldir='waftools')
     self.load('use_config', tooldir='waftools')
     self.load('gnu_dirs')
-    self.env.append_value('ASTERDATADIR', osp.join(self.env.DATADIR, 'aster'))
     self.env['BIBPYTPATH'] = self.path.find_dir('bibpyt').abspath()
 
     self.env.ASTER_EMBEDS = []
     os.environ['LD_LIBRARY_PATH'] = os.pathsep.join(p for p in paths if p)
 
     self.load('scm_aster', tooldir='waftools')
+    self.set_installdirs()
     self.load('parallel', tooldir='waftools')
     self.check_platform()
 
     fun = 'runtest'
 
 @Configure.conf
+def set_installdirs(self):
+    """Set the installation subdirectories"""
+    vers = self.options.astervers
+    if vers is None:
+        try:
+            vers = str(self.env.ASTER_VERSION[0][0]) + '-dev'
+        except (TypeError, IndexError):
+            vers = 'N-dev'
+    self.env.astervers = vers
+    norm = lambda path : osp.normpath(osp.join(path, 'aster', vers))
+    self.env['ASTERBINOPT'] = 'aster' + vers
+    self.env['ASTERBINDBG'] = 'asterd' + vers
+    self.env['ASTERLIBDIR'] = norm(self.env.LIBDIR)
+    self.env['ASTERINCLUDEDIR'] = norm(self.env.INCLUDEDIR)
+    self.env['ASTERDATADIR'] = norm(self.env.DATADIR)
+    if not self.env.LOCALEDIR:
+        self.env.LOCALEDIR = osp.join(self.env.PREFIX, 'share', 'locale')
+    self.env['ASTERLOCALEDIR'] = norm(self.env.LOCALEDIR)
+
+@Configure.conf
 def uncompress64(self, compressed):
     return zlib.decompress(base64.decodestring(compressed))