コード例 #1
0
ファイル: pypi.py プロジェクト: srossross/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")
コード例 #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
ファイル: test_utils.py プロジェクト: nehaljwani/conda-build
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
ファイル: source.py プロジェクト: johngergely/conda-build
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
ファイル: test_utils.py プロジェクト: jjhelmus/conda-build
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
ファイル: source.py プロジェクト: filmor/conda-build
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
ファイル: source.py プロジェクト: bioconda/conda-build
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
ファイル: source.py プロジェクト: patricksnape/conda-build
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)