Changeset 1184 for trunk


Ignore:
Timestamp:
08/25/06 16:34:59 (18 years ago)
Author:
mar637
Message:

complete rework of install target, added data install, and also building a distribution archive

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SConstruct

    r1182 r1184  
    33import distutils.sysconfig
    44import platform
     5import SCons
    56# scons plug-ins
    67#from installtree import InstallTree
    78
    8 version = "2.1.0b"
    99moduledir = distutils.sysconfig.get_python_lib()
    1010if  platform.architecture()[0] == '64bit':
     
    3131
    3232env = Environment( toolpath = ['./scons'],
    33                    tools = ["default", "installtree", "casa",
    34                             "utils"],
     33                   tools = ["default", "casa", "archiver", "utils",
     34                            "quietinstall"],
    3535                   ENV = { 'PATH' : os.environ[ 'PATH' ],
    3636                          'HOME' : os.environ[ 'HOME' ] },
     
    7676    env = conf.Finish()
    7777
    78 env["stage_dir"] = Dir("#/stage/asap")
     78env["version"] = "2.1.0b"
    7979
    8080# general CPPFLAGS
     
    8585    env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B'])
    8686
    87 if env["PLATFORM"] == "darwin":
    88     env['SHLINKFLAGS'] = '$LINKFLAGS -bundle'
    89     #env['SHLIBSUFFIX'] = '.dylib'
    90 
    9187if env['mode'] == 'release':
    9288    env.Append(LINKFLAGS=['-Wl,-O1'])
     89
     90# Export for SConscript files
    9391Export("env")
    9492
     93# build library
    9594so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
    96 stagebuild = env.Install(env["stage_dir"], so )
    97 stagedoc = env.Install("stage", ["doc/README", "doc/CHANGELOG"] )
    98 stagepys = env.SConscript("python/SConscript")
    99 stage0 = env.Install("stage", "bin/install")
    100 stage1 = env.Install("stage/bin", ["bin/asap", "bin/asap_update_data"])
    101 stage2 = env.Install("stage/data", "share/ipythonrc-asap")
    102 env.Alias('stage', [stagebuild,stagedoc,stagepys, stage0, stage1, stage2])
    103 # install locally
    104 asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"),
    105                           src_dir  = "stage",
    106                           includes = ['asap','data'],
    107                           excludes = [])
    108 asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap")
    109 env.Alias('install', [asapmod, asapbin])
     95
     96# install targets
     97somod = env.Install("$moduledir/asap", so )
     98pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
     99bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
     100shares = env.Install("$moduledir/data", "share/ipythonrc-asap")
     101env.Alias('install', [somod, pymods, bins, shares])
     102
     103# install aips++ data repos
     104rootdir=None
     105outdir =  os.path.join(env["moduledir"],'asap','data')
     106sources = ['ephemerides','geodetic']
     107if os.path.exists("/nfs/aips++/data"):
     108    rootdir = "/nfs/aips++/data"
     109elif os.path.exists("data"):
     110    rootdir = "data"
     111if rootdir is not None:
     112    ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
     113    data =  env.InstallAs(ofiles, ifiles)
     114    env.Alias('install', data)
     115   
    110116# make binary distribution
    111117if len(env["makedist"]):
    112     md =env.CreateDist("dist/asap-%s-%s" % (version, env["makedist"]),
    113                    ["install", "README", "CHANGELOG", "asap", "data",
    114                     "bin"],
    115                    "stage")
     118    env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
     119    env.Command('Staging distribution for archive in %s' % env["stagedir"],
     120                '', env.MessageAction)
     121    env.QInstall("$stagedir/asap", [so,  pymods] )
     122    env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
     123    env.QInstall("$stagedir/install", ["bin/install"])
     124    env.QInstall("$stagedir/data", "share/ipythonrc-asap")
     125    if os.path.exists("/nfs/aips++/data"):
     126        rootdir = "/nfs/aips++/data"
     127        sources = ['ephemerides','geodetic']
     128        outdir =  os.path.join(env["stagedir"],'asap','data')
     129        ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
     130        env.QInstallAs(ofiles, ifiles)
     131    arch = env.Archiver(os.path.join("dist",env["stagedir"]),
     132                        env["stagedir"])
     133    env.AddPostAction(arch, Delete("$stagedir"))
     134   
  • trunk/scons/utils.py

    r1178 r1184  
    1515    env.AddCustomPath = AddCustomPath
    1616
    17     def CreateDist(target, sources, descend="stage"):
    18         import tarfile
    19         base_name = str(target).split('.tar')[0]
    20         (target_dir, dir_name) = os.path.split(base_name)
    21         # create the target directory if it does not exist
    22         if target_dir and not os.path.exists(target_dir):
    23             os.makedirs(target_dir)
    24         tar_format = "bz2"
    25         tar = tarfile.open(str(target)+".tar.bz2", "w:%s" % (tar_format,))
    26         if os.path.exists(descend): os.chdir(descend)
    27         taritems = []
    28         excludedirs = [".svn"]
    29         for item in sources:
    30             if os.path.isdir(item):
    31                 for root, dirs, files in os.walk(str(item)):
    32                     if not root in excludedirs:
    33                         for name in files:
    34                             if not name.startswith("."):
    35                                 taritems.append(os.path.join(root, name))
    36             else:
    37                 taritems.append(item)
    38         for item in taritems:
    39             print "Adding to archive: %s/%s" % (dir_name, item)
    40             tar.add(item,'%s/%s' % (dir_name, item))
    41         tar.close()
     17    def WalkDirTree(targetroot, sourceroot, sources):
     18        ifiles = []
     19        ofiles = []
     20        for s in sources:
     21            if os.path.isdir(os.path.join(sourceroot ,s)):
     22                for d,ld,f in os.walk(os.path.join(sourceroot ,s)):
     23                    for fl in f:
     24                        ifile = os.path.join(d, fl)
     25                        ifiles.append(ifile)
     26                        ofile = ifile.replace(sourceroot, targetroot)
     27                        ofiles.append(ofile)
     28        return ofiles, ifiles
     29    env.WalkDirTree = WalkDirTree
    4230
    43     env.CreateDist = CreateDist
     31    def null_action(target, source, env): return 0
     32
     33    def message(target, source, env):
     34        return "%s" % target[0]
     35    env.MessageAction = env.Action(null_action, message)
    4436
    4537def exists(env):
     
    4739        import os
    4840        import glob
    49         import tarfile
    5041    except ImportError:
    5142        return False
Note: See TracChangeset for help on using the changeset viewer.