Creates a tarball to use for building the system elsewhere
433855
def package(options):
    
    import pkg_resources
    import tarfile
    import geonode

    version = geonode.get_version()
    # Use GeoNode's version for the package name.
    pkgname = 'GeoNode-%s-all' % version

    # Create the output directory.
    out_pkg = path(pkgname)
    out_pkg_tar = path("%s.tar.gz" % pkgname)

    # Create a distribution in zip format for the geonode python package.
    dist_dir = path('dist')
    dist_dir.rmtree()
    sh('python setup.py sdist --formats=zip')

    with pushd('package'):

        #Delete old tar files in that directory
        for f in glob.glob('GeoNode*.tar.gz'):
            old_package = path(f)
            if old_package != out_pkg_tar:
                old_package.remove()

        if out_pkg_tar.exists():
            info('There is already a package for version %s' % version)
            return

        # Clean anything that is in the oupout package tree.
        out_pkg.rmtree()
        out_pkg.makedirs()

        support_folder = path('support')
        install_file = path('install.sh')

        # And copy the default files from the package folder.
        justcopy(support_folder, out_pkg / 'support')
        justcopy(install_file, out_pkg)

        geonode_dist = path('..') / 'dist' / 'GeoNode-%s.zip' % version
        justcopy(geonode_dist, out_pkg)

        rogue_dist = path('../..') / 'dist' / 'geoshape-0.1.zip'
        justcopy(rogue_dist, out_pkg)

        # Create a tar file with all files in the output package folder.
        tar = tarfile.open(out_pkg_tar, "w:gz")
        for file in out_pkg.walkfiles():
            tar.add(file)

        # Add the README with the license and important links to documentation.
        tar.add('README', arcname=('%s/README.md' % out_pkg))
        tar.close()

        # Remove all the files in the temporary output package directory.
        out_pkg.rmtree()

    # Report the info about the new package.
    info("%s created" % out_pkg_tar.abspath())
350476
def build(self, dest=None):
        ""
        # dest can be set here or on init
        if not dest:
            dest = self.dest

        # raise an error if dest is None
        if dest is None:
            raise ValueError('destination directory must not be None')

        # store build dir for later
        self.dest = dest

        # ensure a build dir
        if not os.path.isdir(self.dest):
            os.makedirs(self.dest)

        # make sure we have files
        if not self.files:
            self.run()

        # write the content of each post to dest, using keys as filenames
        for filename, post in self.files.items():

            # join filename to dest dir
            path = os.path.join(self.dest, filename)
            with open(path, 'wb') as f:
                f.write(post.content.encode('utf-8'))
618658
def disttar(target, source, env):
        """"""

        import tarfile

        env_dict = env.Dictionary()

        if env_dict.get("DISTTAR_FORMAT") in ["gz", "bz2"]:
                tar_format = env_dict["DISTTAR_FORMAT"]
        else:
                tar_format = ""

        # split the target directory, filename, and stuffix
        base_name = str(target[0]).split('.tar')[0]
        (target_dir, dir_name) = os.path.split(base_name)

        # create the target directory if it does not exist
        if target_dir and not os.path.exists(target_dir):
                os.makedirs(target_dir)

        # open our tar file for writing
        print >> sys.stderr, 'DistTar: Writing %s' % str(target[0])
        print >> sys.stderr, '  with contents: %s' % [str(s) for s in source]
        tar = tarfile.open(str(target[0]), "w:%s" % tar_format)

        # write sources to our tar file
        for item in source:
                item = str(item)
                sys.stderr.write(".")
                #print "Adding to TAR file: %s/%s" % (dir_name,item)
                tar.add(item,'%s/%s' % (dir_name,item))

        # all done
        sys.stderr.write("\n") #print "Closing TAR file"
        tar.close()
96745
def build(self, input_path, output_paths):
        """"""
        for output in output_paths:
            shutil.copy(input_path, output_paths)
877795
def make_tar(tfn, source_dirs, ignore_path=[], optimize_python=True):
    '''
    
    '''

    # selector function
    def select(fn):
        rfn = realpath(fn)
        for p in ignore_path:
            if p.endswith('/'):
                p = p[:-1]
            if rfn.startswith(p):
                return False
        if rfn in python_files:
            return False
        return not is_blacklist(fn)

    # get the files and relpath file of all the directory we asked for
    files = []
    for sd in source_dirs:
        sd = realpath(sd)
        compile_dir(sd, optimize_python=optimize_python)
        files += [(x, relpath(realpath(x), sd)) for x in listfiles(sd)
                  if select(x)]

    # create tar.gz of thoses files
    tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
    dirs = []
    for fn, afn in files:
        dn = dirname(afn)
        if dn not in dirs:
            # create every dirs first if not exist yet
            d = ''
            for component in split(dn):
                d = join(d, component)
                if d.startswith('/'):
                    d = d[1:]
                if d == '' or d in dirs:
                    continue
                dirs.append(d)
                tinfo = tarfile.TarInfo(d)
                tinfo.type = tarfile.DIRTYPE
                tf.addfile(tinfo)

        # put the file
        tf.add(fn, afn)
    tf.close()
273507
def generate(env):
    """"""
    SCons.Tool.createStaticLibBuilder(env)

    # Set-up ms tools paths
    msvc_setup_env_once(env)

    env['AR']          = 'lib'
    env['ARFLAGS']     = SCons.Util.CLVar('/nologo')
    env['ARCOM']       = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES','$ARCOMSTR')}"
    env['LIBPREFIX']   = ''
    env['LIBSUFFIX']   = '.lib'
824237
def directory_tarball(dirname):
    
    assert os.path.isdir(dirname), dirname
    base_dir, tarball_dir = os.path.split(dirname)
    while not os.path.exists(os.path.join(base_dir, "seq")) and base_dir and base_dir != "/":
        base_dir, extra_tarball = os.path.split(base_dir)
        tarball_dir = os.path.join(extra_tarball, tarball_dir)
    if base_dir == "/" and not os.path.exists(os.path.join(base_dir, "seq")):
        raise ValueError("Did not find relative directory to create tarball for %s" % dirname)
    tarball = os.path.join(base_dir, "%s-wf.tar.gz" % (tarball_dir.replace(os.path.sep, "--")))
    if not utils.file_exists(tarball):
        print("Preparing CWL input tarball: %s" % tarball)
        with file_transaction({}, tarball) as tx_tarball:
            with utils.chdir(base_dir):
                with tarfile.open(tx_tarball, "w:gz") as tar:
                    tar.add(tarball_dir)
    return tarball
636664
def _create_dist(self,
                   dist_tgt,
                   dist_target_dir,
                   setup_requires_pex,
                   snapshot_fingerprint,
                   is_platform_specific):
    """"""
    self._copy_sources(dist_tgt, dist_target_dir)

    setup_py_snapshot_version_argv = self._generate_snapshot_bdist_wheel_argv(
      snapshot_fingerprint, is_platform_specific)

    cmd = safe_shlex_join(setup_requires_pex.cmdline(setup_py_snapshot_version_argv))
    with self.context.new_workunit('setup.py', cmd=cmd, labels=[WorkUnitLabel.TOOL]) as workunit:
      with pushd(dist_target_dir):
        result = setup_requires_pex.run(args=setup_py_snapshot_version_argv,
                                        stdout=workunit.output('stdout'),
                                        stderr=workunit.output('stderr'))
        if result != 0:
          raise self.BuildLocalPythonDistributionsError(
            "Installation of python distribution from target {target} into directory {into_dir} "
            "failed (return value of run() was: {rc!r}).\n"
            "The pex with any requirements is located at: {interpreter}.\n"
            "The host system's compiler and linker were used.\n"
            "The setup command was: {command}."
            .format(target=dist_tgt,
                    into_dir=dist_target_dir,
                    rc=result,
                    interpreter=setup_requires_pex.path(),
                    command=setup_py_snapshot_version_argv))
955737
def generate_tar_files(directory_list):
    """"""
    
    tar_file_list = []

    for directory in directory_list:
        if dir_exists(directory):
            _generate_tar(directory)                  # create the tar archive
            tar_file_list.append(directory + '.tar')  # append the tar archive filename to the returned tar_file_list list
        else:
            stderr("The directory '" + directory + "' does not exist and a tar archive could not be created from it.", exit=1)            

    return tar_file_list
1164175
def _tar_and_copy(src_dir, target_dir):
  """"""
  src_dir = src_dir.rstrip("/")
  target_dir = target_dir.rstrip("/")
  tmp_dir = tempfile.gettempdir().rstrip("/")
  src_base = os.path.basename(src_dir)
  shell_run(
      "tar --exclude=.git -zcf {tmp_dir}/{src_base}.tar.gz -C {src_dir} .",
      src_dir=src_dir,
      src_base=src_base,
      tmp_dir=tmp_dir)
  final_destination = "%s/%s.tar.gz" % (target_dir, src_base)
  shell_run(
      ("gsutil cp {tmp_dir}/{src_base}.tar.gz "
       "{final_destination}"),
      tmp_dir=tmp_dir,
      src_base=src_base,
      final_destination=final_destination)
  return final_destination
622771
function build(mode, system, cdef, out, cb) {
    logger.info('building');
    out.stdout('building');
    cb();
  }
160994
public function make() {
        if (!$this->createTargetDirectory()) {
            throw new Garp_Gumball_Exception_CannotWriteTargetDirectory();
        }

        if (!$this->copySourceFilesToTargetDirectory()) {
            throw new Garp_Gumball_Exception_CannotCopySourceFiles();
        }

        // Create database dump of given environment
        if (!$this->createDataDump()) {
            throw new Garp_Gumball_Exception_DatadumpFailed();
        }

        // Create VERSION file
        $this->addVersionFile();

        // Create Under Construction index.html in public that's used when unpacking the gumball
        $this->addUnderConstructionLock();

        // Create config file which can be read @ restore time
        $this->addSettingsFile();

        // Zip target folder
        $this->createZipArchive();

        // Remove target folder
        $this->_removeTargetDirectory();
    }
672985
def generate(env):
    """"""
    SCons.Tool.createSharedLibBuilder(env)
    SCons.Tool.createProgBuilder(env)

    env['LINK']        = '$CC'
    env['LINKFLAGS']   = SCons.Util.CLVar('')
    env['LINKCOM']     = '$LINK -q $LINKFLAGS -e$TARGET $SOURCES $LIBS'
    env['LIBDIRPREFIX']=''
    env['LIBDIRSUFFIX']=''
    env['LIBLINKPREFIX']=''
    env['LIBLINKSUFFIX']='$LIBSUFFIX'
69659
def _prepare_cwl_tarballs(data_dir):
    
    for dbref_dir in filter(os.path.isdir, glob.glob(os.path.join(data_dir, "genomes", "*", "*"))):
        base_dir, dbref = os.path.split(dbref_dir)
        for indexdir in TARBALL_DIRECTORIES:
            cur_target = os.path.join(dbref_dir, indexdir)
            if os.path.isdir(cur_target):
                # Some indices, like rtg, have a single nested directory
                subdirs = [x for x in os.listdir(cur_target) if os.path.isdir(os.path.join(cur_target, x))]
                if len(subdirs) == 1:
                    cur_target = os.path.join(cur_target, subdirs[0])
                create.directory_tarball(cur_target)
1036191
def generate(env):
    """"""
    SCons.Tool.createStaticLibBuilder(env)
    SCons.Tool.createSharedLibBuilder(env)
    SCons.Tool.createProgBuilder(env)

    env['AR'] = 'mwld'
    env['ARCOM'] = '$AR $ARFLAGS -library -o $TARGET $SOURCES'

    env['LIBDIRPREFIX'] = '-L'
    env['LIBDIRSUFFIX'] = ''
    env['LIBLINKPREFIX'] = '-l'
    env['LIBLINKSUFFIX'] = '.lib'

    env['LINK'] = 'mwld'
    env['LINKCOM'] = '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'

    env['SHLINK'] = '$LINK'
    env['SHLINKFLAGS'] = '$LINKFLAGS'
    env['SHLINKCOM']   = shlib_action
    env['SHLIBEMITTER']= shlib_emitter
    env['LDMODULEEMITTER']= shlib_emitter
341672
def _create_tar(self, name):
        """"""
        fileobj = utils.create_spooled_temporary_file()
        mode = 'w:gz' if self.compress else 'w'
        tar_file = tarfile.open(name=name, fileobj=fileobj, mode=mode)
        for media_filename in self._explore_storage():
            tarinfo = tarfile.TarInfo(media_filename)
            media_file = self.media_storage.open(media_filename)
            tarinfo.size = len(media_file)
            tar_file.addfile(tarinfo, media_file)
        # Close the TAR for writing
        tar_file.close()
        return fileobj
38469
def build_distributions(context):
    """"""
    rmtree('dist', ignore_errors=True)

    build_package_command = 'python setup.py clean sdist bdist_wheel'
    result = shell.dry_run(build_package_command, context.dry_run)
    packages = Path('dist').files() if not context.dry_run else "nothing"

    if not result:
        raise Exception('Error building packages: %s' % result)
    else:
        log.info('Built %s' % ', '.join(packages))
    return packages