Example #1
0
    def _functest(self):
        # use nose by default
        target = 'functests'
        setup = os.path.join(target, 'setup.py')
        if os.path.exists(target):
            if os.path.exists(setup):
                os.chdir(target)
                envstr = self._get_env()
                # handle explicit test target
                filetarget = ""
                for o in self._comopts:
                    if o.startswith(target + "/"):
                        filetarget = "--tests=" + os.path.split(o)[-1]

                cmd = "%s python setup.py -q nosetests --with-xunit " \
                      "--xunit-file=%s-junit-results.xml %s" \
                      % (envstr, target, filetarget)
                clncmd = "python setup.py -q clean"
                utils.run("%s" % cmd, self.nowarnings, ignore_traceback=True)
                utils.runcmd("%s" % clncmd)
                os.chdir(self._bdir)
            else:
                pass  # fail quietly as they may have run scons tests.
        else:
            print "error: missing functests subdirectory in %s" % \
                    os.path.relpath(self._bdir, self._askaproot)
Example #2
0
    def _release(self):
        '''
        Create a tarball of the staged location.
        The rbuild program has -N option that stops the adding of virtualenv
        to the release.  This is for developers sharing purely python packages.
        In this case there is no point creating the release envfile and
        cannot update the easy-install.pth file.
        '''
        utils.q_print("info: running the release process")
        utils.q_print(
            "info: resetting python scripts to use '#!/usr/bin/env python'")
        bindir = os.path.join(self._stagedir, "bin")
        for fn in glob.glob("%s/*" % bindir):
            sedcmd = "sed -i -e '1s&^#\!.*/bin/python&#\!/usr/bin/env python&' %s" % fn
            utils.runcmd(sedcmd, shell=True)

        if os.path.exists(os.path.join(self._stagedir, "bin", "python")):
            self._create_release_envfile()
            self._update_easyinstall()
        dn, bn = os.path.split(self._stagedir.rstrip("/"))
        if not dn:
            dn = '.'
        utils.q_print("info: creating %s.tgz" % self._releasename)
        utils.runcmd("tar -C %s -czf %s.tgz %s" % (dn, self._releasename, bn))
        utils.rmtree(self._stagedir)
Example #3
0
    def __init__(self, pkgname=None, archivename=None, extractdir=None,
                 epicsbase=None, releasefile=None, srcdir=None,
                 fileprefix=None, dbprefix=None, *args, **kwargs):
        Builder.__init__(self, pkgname=pkgname,
                               archivename=archivename,
                               extractdir=extractdir,
                               buildcommand="",
                               buildtargets=[""])
        self.parallel = False
        self._appname = os.getcwd().split(os.sep)[-2]

        if epicsbase is None:
            self._epicsBuild = False
            self._srcdir = srcdir
            srcOutDir = srcdir
            dbOutDir = None
            xmlOutDir = None
        else:
            self._epicsBuild = True
            self._epicsbase = self.dep.get_install_path(epicsbase)
            self._epicsbase = self._epicsbase.rstrip(os.sep)
            self._srcdir = os.path.join(srcdir, 'src')
            comm = os.path.join(os.path.dirname(self._epicsbase), "EpicsHostArch")
            #self._epicsarch = utils.runcmd(comm)[0].strip() + '-debug'
            self._epicsarch = utils.runcmd(comm)[0].strip()

            srcOutDir = os.path.join(srcdir, 'src', 'O.' + self._epicsarch)
            dbOutDir = os.path.join(srcdir, 'Db', 'O.Common')
            xmlOutDir = os.path.join('install', 'epicsxml')

        self._adePoints = []
        self._adeParser = AdbeParser(self._appname, dbprefix, fileprefix, srcOutDir, dbOutDir, xmlOutDir, *args, **kwargs)
Example #4
0
def add_to_svn(dirpath):
    (stdout, stderr, status) = utils.runcmd("svn add --no-ignore %s" % dirpath)
    if status == 0:
        print stdout.strip()
        print "info: templates add to repository. You will need to do a commit."
        return True
    else:
        return False
Example #5
0
    def __init__(self,
                 pkgname=None,
                 archivename=None,
                 extractdir=None,
                 epicsbase=None,
                 releasefile=None,
                 supportmodule=False):
        Builder.__init__(self,
                         pkgname=pkgname,
                         archivename=archivename,
                         extractdir=extractdir,
                         buildcommand="make",
                         buildtargets=[""])
        self.parallel = False
        self._epicssupportdict = {}  # support modules
        self._iocbootdirsdict = {}  # iocboot directories to install
        self._implicit_deps = []
        self._support_module = supportmodule

        if epicsbase is None:
            # We are building EPICS base (no need for RELEASE file)
            self._epicsbase = os.path.join(os.path.abspath(os.curdir),
                                           self._installdir)
            self._is_epics_base = True
        else:
            self._epicsbase = self.dep.get_install_path(epicsbase)
            self._is_epics_base = False
            self._appname = os.getcwd().split(os.sep)[-2]

        self._epicsbase = self._epicsbase.rstrip(os.sep)

        # Set EPICS architecture using shell script in EPICS base directory.
        comm = os.path.join(os.path.dirname(self._epicsbase), "EpicsHostArch")
        self._epicsarch = utils.runcmd(comm)[0].strip()
        self.add_env("EPICS_HOST_ARCH", self._epicsarch)
        self._oldreleasefile = None

        if releasefile is None:
            self._releasefile = "RELEASE." + self._epicsarch + ".Common"
            # Create old (<3.14.11) release file for compatibility with
            # old style of CONFIG files that uses CONFIG_APP, for example
            # asyn, modbus
            self._oldreleasefile = 'RELEASE.' + self._epicsarch
            self.add_extra_clean_targets(
                self._oldreleasefile,
                os.path.join('configure', self._oldreleasefile))
        else:
            self._releasefile = releasefile
        self.add_extra_clean_targets(
            self._releasefile, "package.info",
            os.path.join('configure', self._releasefile))
        self._deps_file = os.path.join(self._bdir, "configure", "ASKAPDEPS")
        self.add_extra_clean_targets(self._deps_file)

        ldname = "LD_LIBRARY_PATH"
        if sys.platform == "darwin":
            ldname = "DY" + ldname
        if ldname in os.environ:
            os.environ[ldname] = \
                os.path.pathsep.join([self.dep.get_ld_library_path(),
                                      os.environ[ldname]])
        else:
            os.environ[ldname] = self.dep.get_ld_library_path()
        os.environ["PATH"] = os.path.pathsep.join(
            [self.dep.get_path(), os.environ["PATH"]])
        # Setup version header file name if not epics base
        if not self._is_epics_base:
            self._version_header_filename = self._appname + '_version.h'
            self.add_extra_clean_targets(self._version_header_filename)

        self._csv_files = []
Example #6
0
    def __init__(self, pkgname=None, archivename=None, extractdir=None,
            epicsbase=None, releasefile=None):
        Builder.__init__(self, pkgname=pkgname,
                               archivename=archivename,
                               extractdir=extractdir,
                               buildcommand="make",
                               buildtargets=[""])
        self.parallel = False
        self._epicssupportdict = {} # support modules
        self._iocbootdirsdict = {}  # iocboot directories to install
        self._implicit_deps = []

        if epicsbase is None:
            # We are building EPICS base (no need for RELEASE file)
            self._epicsbase = os.path.join(os.path.abspath(os.curdir), 
                                           self._installdir)
            self._is_epics_base = True
        else:
            self._epicsbase = self.dep.get_install_path(epicsbase)
            self._is_epics_base = False
            self._appname = os.getcwd().split(os.sep)[-2]

        self._epicsbase = self._epicsbase.rstrip(os.sep)

        # Set EPICS architecture using shell script in EPICS base directory.
        comm = os.path.join(os.path.dirname(self._epicsbase), "EpicsHostArch")
        self._epicsarch = utils.runcmd(comm)[0].strip()
        self.add_env("EPICS_HOST_ARCH", self._epicsarch)
        self._oldreleasefile = None

        if releasefile is None:
            self._releasefile = "RELEASE." + self._epicsarch + ".Common"
            # Create old (<3.14.11) release file for compatibility with
            # old style of CONFIG files that uses CONFIG_APP, for example
            # asyn, modbus
            self._oldreleasefile = 'RELEASE.' + self._epicsarch
            self.add_extra_clean_targets(self._oldreleasefile, 
                                         os.path.join('configure', 
                                                      self._oldreleasefile))
        else:
            self._releasefile = releasefile
        self.add_extra_clean_targets(self._releasefile, 
                                     "package.info", 
                                     os.path.join('configure',
                                                  self._releasefile))
        self._deps_file = os.path.join(self._bdir, "configure",
                                       "ASKAPDEPS")
        self.add_extra_clean_targets(self._deps_file)

        ldname  = "LD_LIBRARY_PATH"
        if sys.platform == "darwin":
            ldname = "DY"+ldname
        if ldname in os.environ:
            os.environ[ldname] = \
                os.path.pathsep.join([self.dep.get_ld_library_path(),
                                                os.environ[ldname]])
        else:
            os.environ[ldname] = self.dep.get_ld_library_path()
        os.environ["PATH"] = os.path.pathsep.join([self.dep.get_path(),
                                                   os.environ["PATH"]])
        # Setup version header file name if not epics base
        if not self._is_epics_base:
            self._version_header_filename = self._appname + '_version.h'
            self.add_extra_clean_targets(self._version_header_filename)

        self._csv_files = []
Example #7
0
    def create_dependency_graph(self,
                                pkg_path,
                                depfilename=DEPFILENAME,
                                use_repo='second',
                                recursion=True):
        '''
        Adds new edges to the self._graph object from a packages
        dependency.default file.
        From the dependency file, pull out from each line:
        * alias,
        * relative path to dependent package,
        * optional libraries.
        If edge already in the graph skip, else add the edge (package)
        to the graph via its add_edge() method.
        use_repo ['first', 'second', 'never']
          'first'  - always check repo and if not found skip
          'second' - check work area if it exists else if not found try repo
          'never'  - check work area if not found skip
        '''
        data = ''
        rel_depfile = os.path.join(pkg_path, depfilename)
        work_pkgdir = os.path.join(ASKAP_ROOT, pkg_path)
        work_depfile = os.path.join(ASKAP_ROOT, rel_depfile)
        repo_depfile = os.path.join(ASKAP_URL, rel_depfile)

        if use_repo in ['first', 'second'] and ASKAP_URL == '':
            utils.q_print(
                'warn: depends module unable to determine ASKAP_ROOT repository URL.'
            )
            use_repo = 'never'

        # Get contents of dependency.default file if it exists.
        # Can get from work area or from repository depending on use_repo
        # setting and whether work area and/or repo availability.
        #
        if use_repo == 'second' and os.path.exists(work_pkgdir):
            if os.path.exists(work_depfile):
                fh = open(work_depfile)
                data = fh.read()
                fh.close()
        elif use_repo != 'never':
            cmd = 'svn cat %s' % repo_depfile
            stdout, stderr, returncode = utils.runcmd(cmd)
            if returncode == 0:
                data = stdout

        # Process the dependency.default contents.
        # Format of dependencies.default line is:
        # <alias> = <relpath to dep pkg> [;] [<lib1> <lib2> ... <libN>]
        #
        for line in data.split('\n'):
            line = line.strip()
            if not line or line.startswith('#'):
                continue
            alias, pkg_spec = line.split('=', 1)
            pkg_spec = pkg_spec.split(';', 1)
            dep_pkg_path = pkg_spec[0].strip()
            if len(pkg_spec) == 2:
                dep_pkg_libs = pkg_spec[1].strip().split()
            else:
                dep_pkg_libs = []
            # Check if already processed rootpkgdir.
            # Need edge check not node check because the node may already
            # exist as dependency but have not processed its
            # dependencies yet.
            if self._graph.has_edge(pkg_path, dep_pkg_path):
                continue  # Already analyzed this node.
            else:
                self._graph.add_edge(pkg_path, dep_pkg_path, libs=dep_pkg_libs)
                if recursion:
                    self.create_dependency_graph(dep_pkg_path)
Example #8
0
import networkx as nx
import askapdev.rbuild.utils as utils

# Allow relative import to work when run as standalone script.
# http://www.python.org/dev/peps/pep-0366/
if __name__ == "__main__" and __package__ is None:
    __package__ = "askapdev.rbuild.Depends"

from ..exceptions import BuildError

ASKAP_ROOT = os.environ.get("ASKAP_ROOT")
if ASKAP_ROOT is None:
    raise BuildError("ASKAP_ROOT environment variable is not defined")

stdout, stderr, returncode = utils.runcmd('svn info %s' % ASKAP_ROOT)
if returncode == 0:
    for line in stdout.split('\n'):
        if line.startswith('URL:'):
            ASKAP_URL = line.split(':', 1)[1]
            break
else:
    ASKAP_URL = ''

DEPFILENAME = 'dependencies.default'
DEPTEST = '''
#
# alias=path<;optional space separated libs>
#
scimath=Code/Base/scimath/current
casacore=3rdParty/casacore/casacore-1.2.0; casa_ms casa_images cas