예제 #1
0
def unpack(src_path, tempdir):
    if src_path.endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz', '.tar')):
        tar_xf(src_path, tempdir)
    elif src_path.endswith('.zip'):
        unzip(src_path, tempdir)
    else:
        raise Exception("not a valid source")
예제 #2
0
def unpack(source_dict, src_dir, cache_folder, recipe_path, croot, verbose=False,
           timeout=90, locking=True):
    ''' Uncompress a downloaded source. '''
    src_path, unhashed_fn = download_to_cache(cache_folder, recipe_path, source_dict)

    if not isdir(src_dir):
        os.makedirs(src_dir)
    if verbose:
        print("Extracting download")
    with TemporaryDirectory(dir=croot) as tmpdir:
        unhashed_dest = os.path.join(tmpdir, unhashed_fn)
        if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
                '.tar', 'tar.z')):
            tar_xf(src_path, tmpdir)
        elif src_path.lower().endswith('.zip'):
            unzip(src_path, tmpdir)
        elif src_path.lower().endswith('.whl'):
            # copy wheel itself *and* unpack it
            # This allows test_files or about.license_file to locate files in the wheel,
            # as well as `pip install name-version.whl` as install command
            unzip(src_path, tmpdir)
            copy_into(src_path, unhashed_dest, timeout, locking=locking)
        else:
            # In this case, the build script will need to deal with unpacking the source
            print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
            copy_into(src_path, unhashed_dest, timeout, locking=locking)
        flist = os.listdir(tmpdir)
        folder = os.path.join(tmpdir, flist[0])
        if len(flist) == 1 and os.path.isdir(folder):
            hoist_single_extracted_folder(folder)
        flist = os.listdir(tmpdir)
        for f in flist:
            shutil.move(os.path.join(tmpdir, f), os.path.join(src_dir, f))
예제 #3
0
def unpack(meta, config):
    ''' Uncompress a downloaded source. '''
    src_path = download_to_cache(meta, config)

    if not isdir(config.work_dir):
        os.makedirs(config.work_dir)
    if config.verbose:
        print("Extracting download")
    if src_path.lower().endswith(
        ('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz', '.tar', 'tar.z')):
        tar_xf(src_path, config.work_dir)
    elif src_path.lower().endswith('.zip'):
        unzip(src_path, config.work_dir)
    elif src_path.lower().endswith('.whl'):
        # copy wheel itself *and* unpack it
        # This allows test_files or about.license_file to locate files in the wheel,
        # as well as `pip install name-version.whl` as install command
        unzip(src_path, config.work_dir)
        copy_into(src_path,
                  config.work_dir,
                  config.timeout,
                  locking=config.locking)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print(
            "Warning: Unrecognized source format. Source file will be copied to the SRC_DIR"
        )
        copy_into(src_path,
                  config.work_dir,
                  config.timeout,
                  locking=config.locking)
예제 #4
0
def unpack(src_path, tempdir):
    if src_path.endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz', '.tar')):
        tar_xf(src_path, tempdir)
    elif src_path.endswith('.zip'):
        unzip(src_path, tempdir)
    else:
        raise Exception("not a valid source: %s" % src_path)
예제 #5
0
파일: source.py 프로젝트: cav71/conda-build
def unpack(source_dict, src_dir, cache_folder, recipe_path, croot, verbose=False,
           timeout=90, locking=True):
    ''' Uncompress a downloaded source. '''
    src_path, unhashed_fn = download_to_cache(cache_folder, recipe_path, source_dict)

    if not isdir(src_dir):
        os.makedirs(src_dir)
    if verbose:
        print("Extracting download")
    with TemporaryDirectory(dir=croot) as tmpdir:
        unhashed_dest = os.path.join(tmpdir, unhashed_fn)
        if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
                '.tar', 'tar.z')):
            tar_xf(src_path, tmpdir)
        elif src_path.lower().endswith('.zip'):
            unzip(src_path, tmpdir)
        elif src_path.lower().endswith('.whl'):
            # copy wheel itself *and* unpack it
            # This allows test_files or about.license_file to locate files in the wheel,
            # as well as `pip install name-version.whl` as install command
            unzip(src_path, tmpdir)
            copy_into(src_path, unhashed_dest, timeout, locking=locking)
        else:
            # In this case, the build script will need to deal with unpacking the source
            print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
            copy_into(src_path, unhashed_dest, timeout, locking=locking)
        flist = os.listdir(tmpdir)
        folder = os.path.join(tmpdir, flist[0])
        if len(flist) == 1 and os.path.isdir(folder):
            hoist_single_extracted_folder(folder)
        flist = os.listdir(tmpdir)
        for f in flist:
            shutil.move(os.path.join(tmpdir, f), os.path.join(src_dir, f))
예제 #6
0
파일: pypi.py 프로젝트: jlas/conda-build
def unpack(src_path, tempdir):
    if src_path.endswith((".tar.gz", ".tar.bz2", ".tgz", ".tar.xz", ".tar")):
        tar_xf(src_path, tempdir)
    elif src_path.endswith(".zip"):
        unzip(src_path, tempdir)
    else:
        raise Exception("not a valid source")
예제 #7
0
파일: source.py 프로젝트: minrk/conda-build
def unpack(meta):
    src_path = download_to_cache(meta)

    os.makedirs(WORK_DIR)
    if src_path.endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz', '.tar')):
        tar_xf(src_path, WORK_DIR)
    elif src_path.endswith('.zip'):
        unzip(src_path, WORK_DIR)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy2(src_path, WORK_DIR)
예제 #8
0
def test_unzip(testing_workdir):
    with open('file_with_execute_permission', 'w') as f:
        f.write("test")
    file_path = os.path.join(testing_workdir, 'file_with_execute_permission')
    current_permissions = os.stat(file_path).st_mode
    os.chmod(file_path, current_permissions | stat.S_IXUSR)
    with zipfile.ZipFile('test.zip', 'w') as z:
        z.write('file_with_execute_permission')
    utils.unzip('test.zip', 'unpack')
    unpacked_path = os.path.join('unpack', 'file_with_execute_permission')
    assert os.path.isfile(unpacked_path)
    st_mode = os.stat(unpacked_path).st_mode
    assert st_mode & stat.S_IXUSR
예제 #9
0
def unpack(meta):
    """ Uncompress a downloaded source. """
    src_path = download_to_cache(meta)

    os.makedirs(WORK_DIR)
    if src_path.lower().endswith((".tar.gz", ".tar.bz2", ".tgz", ".tar.xz", ".tar")):
        tar_xf(src_path, WORK_DIR)
    elif src_path.lower().endswith(".zip"):
        unzip(src_path, WORK_DIR)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy2(src_path, WORK_DIR)
예제 #10
0
파일: source.py 프로젝트: opotowsky/ciclus
def unpack(meta):
    ''' Uncompress a downloaded source. '''
    src_path = download_to_cache(meta)

    os.makedirs(WORK_DIR)
    if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz', '.tar')):
        tar_xf(src_path, WORK_DIR)
    elif src_path.lower().endswith('.zip'):
        unzip(src_path, WORK_DIR)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy2(src_path, WORK_DIR)
예제 #11
0
def test_unzip(testing_workdir):
    with open('file_with_execute_permission', 'w') as f:
        f.write("test")
    file_path = os.path.join(testing_workdir, 'file_with_execute_permission')
    current_permissions = os.stat(file_path).st_mode
    os.chmod(file_path, current_permissions | stat.S_IXUSR)
    with zipfile.ZipFile('test.zip', 'w') as z:
        z.write('file_with_execute_permission')
    utils.unzip('test.zip', 'unpack')
    unpacked_path = os.path.join('unpack', 'file_with_execute_permission')
    assert os.path.isfile(unpacked_path)
    st_mode = os.stat(unpacked_path).st_mode
    assert st_mode & stat.S_IXUSR
예제 #12
0
def unpack(meta, verbose=False):
    ''' Uncompress a downloaded source. '''
    src_path = download_to_cache(meta)

    os.makedirs(WORK_DIR)
    if verbose:
        print("Extracting download")
    if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
            '.tar', 'tar.z')):
        tar_xf(src_path, WORK_DIR)
    elif src_path.lower().endswith('.zip'):
        unzip(src_path, WORK_DIR)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy2(src_path, WORK_DIR)
예제 #13
0
def unpack(meta, config):
    """ Uncompress a downloaded source. """
    src_path = download_to_cache(meta, config)

    if not isdir(config.work_dir):
        os.makedirs(config.work_dir)
    if config.verbose:
        print("Extracting download")
    if src_path.lower().endswith((".tar.gz", ".tar.bz2", ".tgz", ".tar.xz", ".tar", "tar.z")):
        tar_xf(src_path, get_dir(config))
    elif src_path.lower().endswith(".zip"):
        unzip(src_path, get_dir(config))
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy_into(src_path, get_dir(config), config.timeout)
예제 #14
0
def unpack(meta, config):
    ''' Uncompress a downloaded source. '''
    src_path = download_to_cache(meta, config)

    if not isdir(config.work_dir):
        os.makedirs(config.work_dir)
    if config.verbose:
        print("Extracting download")
    if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
            '.tar', 'tar.z')):
        tar_xf(src_path, config.work_dir)
    elif src_path.lower().endswith('.zip'):
        unzip(src_path, config.work_dir)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy_into(src_path, config.work_dir, config.timeout)
예제 #15
0
def unpack(meta, config):
    ''' Uncompress a downloaded source. '''
    src_path = download_to_cache(meta, config)

    if not isdir(config.work_dir):
        os.makedirs(config.work_dir)
    if config.verbose:
        print("Extracting download")
    if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
            '.tar', 'tar.z')):
        tar_xf(src_path, config.work_dir)
    elif src_path.lower().endswith('.zip'):
        unzip(src_path, config.work_dir)
    else:
        # In this case, the build script will need to deal with unpacking the source
        print("Warning: Unrecognized source format. Source file will be copied to the SRC_DIR")
        copy_into(src_path, config.work_dir, config.timeout, locking=config.locking)