Exemple #1
0
def get_pkginfo(package, filename, pypiurl, digest, python_version,
                extra_specs, config, setup_options):
    # Unfortunately, two important pieces of metadata are only stored in
    # the package itself: the dependencies, and the entry points (if the
    # package uses distribute).  Our strategy is to download the package
    # and "fake" distribute/setuptools's setup() function to get this
    # information from setup.py. If this sounds evil, keep in mind that
    # distribute itself already works by monkeypatching distutils.
    tempdir = mkdtemp('conda_skeleton_' + filename)

    if not isdir(config.src_cache):
        makedirs(config.src_cache)

    hash_type = digest[0]
    hash_value = digest[1]
    try:
        # Download it to the build source cache. That way, you have
        # it.
        download_path = join(config.src_cache, filename)
        if not isfile(download_path) or \
                hashsum_file(download_path, hash_type) != hash_value:
            download(pypiurl, join(config.src_cache, filename))
            if hashsum_file(download_path, hash_type) != hash_value:
                raise RuntimeError(
                    ' Download of {} failed'
                    ' checksum type {} expected value {}. Please'
                    ' try again.'.format(package, hash_type, hash_value))
        else:
            print("Using cached download")
        # Calculate the preferred hash type here if necessary.
        # Needs to be done in this block because this is where we have
        # access to the source file.
        if hash_type != 'sha256':
            new_hash_value = hashsum_file(download_path, 'sha256')
        else:
            new_hash_value = ''

        print("Unpacking %s..." % package)
        unpack(join(config.src_cache, filename), tempdir)
        print("done")
        print("working in %s" % tempdir)
        src_dir = get_dir(tempdir)
        # TODO: find args parameters needed by run_setuppy
        run_setuppy(src_dir,
                    tempdir,
                    python_version,
                    extra_specs=extra_specs,
                    config=config,
                    setup_options=setup_options)
        try:
            with open(join(tempdir, 'pkginfo.yaml')) as fn:
                pkg_info = yaml.safe_load(fn)
        except IOError:
            pkg_info = pkginfo.SDist(download_path).__dict__
        if new_hash_value:
            pkg_info['new_hash_value'] = ('sha256', new_hash_value)
    finally:
        rm_rf(tempdir)

    return pkg_info
Exemple #2
0
def get_pkginfo(package, filename, pypiurl, md5, python_version, config, setup_options):
    # Unfortunately, two important pieces of metadata are only stored in
    # the package itself: the dependencies, and the entry points (if the
    # package uses distribute).  Our strategy is to download the package
    # and "fake" distribute/setuptools's setup() function to get this
    # information from setup.py. If this sounds evil, keep in mind that
    # distribute itself already works by monkeypatching distutils.
    tempdir = mkdtemp('conda_skeleton_' + filename)

    if not isdir(config.src_cache):
        makedirs(config.src_cache)

    try:
        # Download it to the build source cache. That way, you have
        # it.
        download_path = join(config.src_cache, filename)
        if not isfile(download_path) or \
                hashsum_file(download_path, 'md5') != md5:
            download(pypiurl, join(config.src_cache, filename))
        else:
            print("Using cached download")
        print("Unpacking %s..." % package)
        unpack(join(config.src_cache, filename), tempdir)
        print("done")
        print("working in %s" % tempdir)
        src_dir = get_dir(tempdir)
        # TODO: find args parameters needed by run_setuppy
        run_setuppy(src_dir, tempdir, python_version, config=config, setup_options=setup_options)
        with open(join(tempdir, 'pkginfo.yaml')) as fn:
            pkginfo = yaml.load(fn)
    finally:
        rm_rf(tempdir)

    return pkginfo
def test_renaming_executables(testing_workdir, base_platform, package):
    """Test that the files in /bin are properly renamed.

    When converting the bin/ directory to Scripts/, only scripts
    need to be changed. Sometimes the /bin directory contains other
    files that are not Python scripts such as post-link.sh scripts.
    This test converts a packaege that contains a post-link.sh script
    in the bin/ directory and checks to see that its filename remains
    the same.
    """
    package_name, example_file = package
    subdir = '{}-64'.format(base_platform)
    f = 'http://repo.anaconda.com/pkgs/free/{}/{}-py27_0.tar.bz2'.format(subdir,
                                                                         package_name)
    fn = "{}-py27_0.tar.bz2".format(package_name)
    download(f, fn)
    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', quiet=False, verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        if subdir != platform:
            package = os.path.join(platform, fn)

            if expected_paths_json:
                assert package_has_file(package, 'info/paths.json')
                assert_package_paths_matches_files(package)
def test_skip_conversion(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package
    source_plat_arch = '{}-64'.format(base_platform)

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-np112py36_0.tar.bz2'.format(
        base_platform, package_name)
    fn = "{}-np112py36_0.tar.bz2".format(package_name)
    download(f, fn)

    api.convert(fn,
                platforms=source_plat_arch,
                dependencies=None,
                quiet=False,
                verbose=False)

    output, error = capfd.readouterr()

    skip_message = (
        "Source platform '{}' and target platform '{}' are identical. "
        "Skipping conversion.\n".format(source_plat_arch, source_plat_arch))

    package = os.path.join(source_plat_arch, fn)

    assert skip_message in output
    assert not os.path.exists(package)
def test_convert_no_dependencies(testing_workdir, base_platform, package):
    package_name, example_file = package
    subdir = '{}-64'.format(base_platform)
    f = 'http://repo.anaconda.com/pkgs/free/{}/{}-np112py36_0.tar.bz2'.format(subdir,
                                                                              package_name)
    fn = "{}-np112py36_0.tar.bz2".format(package_name)
    download(f, fn)

    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', dependencies=None, quiet=False, verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        if platform != subdir:
            python_folder = 'lib/python3.6' if not platform.startswith('win') else 'Lib'
            package = os.path.join(platform, fn)
            assert package_has_file(package,
                                    '{}/{}'.format(python_folder, example_file))

            with tarfile.open(package) as t:
                info = json.loads(t.extractfile('info/index.json').read().decode('utf-8'))

                assert 'numpy 1.12.1 py36_0' in info['depends']
                assert 'cryptography 1.8.1 py36_0' in info['depends']

            if expected_paths_json:
                assert package_has_file(package, 'info/paths.json')
                assert_package_paths_matches_files(package)
Exemple #6
0
    def __enter__(self):
        if '://' not in self.url:
            # if we provide the file itself, no tmp dir is created
            self.tmp_dir = None
            return self.url
        else:
            if 'CHECKSUMS' in self.url:
                turl = self.url.split('id/')
                filename = turl[1]
            else:
                filename = basename(self.url)

            filename = filename.replace('::', '-')

            self.tmp_dir = tempfile.mkdtemp()

            home = os.path.expanduser('~')
            base_dir = join(home, '.conda-build', 'cpan',
                            basename(self.url).replace('::', '-'))
            dst = join(base_dir, filename)
            dst = dst.replace('::', '-')
            base_dir = dirname(dst)

            if not exists(base_dir):
                makedirs(base_dir)
            dst = get_pickle_file_path(cache_dir=base_dir,
                                       filename_prefix=filename,
                                       other_hashed=(self.url, ))
            if not exists(os.path.dirname(dst)):
                makedirs(os.path.dirname(dst))
            if not exists(dst):
                download(self.url, dst)

            return dst
def test_show_imports(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64' .format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        with pytest.raises(SystemExit):
            api.convert(fn, platforms=platform, show_imports=True)

        output, error = capfd.readouterr()

        # there will be four duplicate outputs since we're converting to four platforms
        assert 'import cryptography.hazmat.bindings._constant_time' in output
        assert 'import cryptography.hazmat.bindings._openssl' in output
        assert 'import cryptography.hazmat.bindings._padding' in output
def test_convert_platform_to_others(testing_workdir, base_platform, package):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64' .format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py27_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py27_0.tar.bz2".format(package_name)
    download(f, fn)
    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', quiet=False, verbose=False)
    for platform in platforms:
        python_folder = 'lib/python2.7' if not platform.startswith('win') else 'Lib'
        package = os.path.join(platform, fn)
        assert package_has_file(package,
                                '{}/site-packages/{}'.format(python_folder, example_file))

        if expected_paths_json:
            assert package_has_file(package, 'info/paths.json')
            assert_package_paths_matches_files(package)
def test_convert_no_dependencies(testing_workdir, base_platform, package):
    package_name, example_file = package
    subdir = '{}-64'.format(base_platform)
    f = 'http://repo.continuum.io/pkgs/free/{}/{}-np112py36_0.tar.bz2'.format(
        subdir, package_name)
    fn = "{}-np112py36_0.tar.bz2".format(package_name)
    download(f, fn)

    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn,
                platforms='all',
                dependencies=None,
                quiet=False,
                verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        if platform != subdir:
            python_folder = 'lib/python3.6' if not platform.startswith(
                'win') else 'Lib'
            package = os.path.join(platform, fn)
            assert package_has_file(
                package, '{}/{}'.format(python_folder, example_file))

            with tarfile.open(package) as t:
                info = json.loads(
                    t.extractfile('info/index.json').read().decode('utf-8'))

                assert 'numpy 1.12.1 py36_0' in info['depends']
                assert 'cryptography 1.8.1 py36_0' in info['depends']

            if expected_paths_json:
                assert package_has_file(package, 'info/paths.json')
                assert_package_paths_matches_files(package)
Exemple #10
0
def test_renaming_executables(testing_workdir, base_platform, package):
    """Test that the files in /bin are properly renamed.

    When converting the bin/ directory to Scripts/, only scripts
    need to be changed. Sometimes the /bin directory contains other
    files that are not Python scripts such as post-link.sh scripts.
    This test converts a packaege that contains a post-link.sh script
    in the bin/ directory and checks to see that its filename remains
    the same.
    """
    package_name, example_file = package
    subdir = '{}-64'.format(base_platform)
    f = 'http://repo.anaconda.com/pkgs/free/{}/{}-py27_0.tar.bz2'.format(
        subdir, package_name)
    fn = "{}-py27_0.tar.bz2".format(package_name)
    download(f, fn)
    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', quiet=False, verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        if subdir != platform:
            package = os.path.join(platform, fn)

            if expected_paths_json:
                assert package_has_file(package, 'info/paths.json')
                assert_package_paths_matches_files(package)
def test_show_imports(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64'.format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(
        base_platform, package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        with pytest.raises(SystemExit):
            api.convert(fn, platforms=platform, show_imports=True)

        output, error = capfd.readouterr()

        # there will be four duplicate outputs since we're converting to four platforms
        assert 'import cryptography.hazmat.bindings._constant_time' in output
        assert 'import cryptography.hazmat.bindings._openssl' in output
        assert 'import cryptography.hazmat.bindings._padding' in output
Exemple #12
0
    def __enter__(self):
        if '://' not in self.url:
            # if we provide the file itself, no tmp dir is created
            self.tmp_dir = None
            return self.url
        else:
            if 'CHECKSUMS' in self.url:
                turl = self.url.split('id/')
                filename = turl[1]
            else:
                filename = basename(self.url)

            filename.replace('::', '-')

            self.tmp_dir = tempfile.mkdtemp()

            home = os.path.expanduser('~')
            base_dir = join(home, '.conda-build', 'cpan',
                            basename(self.url).replace('::', '-'))
            dst = join(base_dir, filename)
            dst = dst.replace('::', '-')
            base_dir = dirname(dst)

            if not exists(base_dir):
                makedirs(base_dir)
            if not exists(dst):
                download(self.url, dst)

            return dst
Exemple #13
0
def test_convert_platform_to_others(testing_workdir, base_platform):
    f = 'http://repo.continuum.io/pkgs/free/{}-64/itsdangerous-0.24-py27_0.tar.bz2'.format(base_platform)
    fn = "itsdangerous-0.24-py27_0.tar.bz2"
    download(f, fn)
    convert(fn, platforms='all', quiet=False, verbose=True)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        python_folder = 'lib/python2.7' if not platform.startswith('win') else 'Lib'
        assert package_has_file(os.path.join(platform, fn),
                                '{}/site-packages/itsdangerous.py'.format(python_folder))
Exemple #14
0
 def __enter__(self):
     if '://' not in self.url:
         # if we provide the file itself, no tmp dir is created
         self.tmp_dir = None
         return self.url
     else:
         self.tmp_dir = tempfile.mkdtemp()
         dst = join(self.tmp_dir, basename(self.url).replace('::', '-'))
         download(self.url, dst)
         return dst
Exemple #15
0
 def __enter__(self):
     if '://' not in self.url:
         # if we provide the file itself, no tmp dir is created
         self.tmp_dir = None
         return self.url
     else:
         self.tmp_dir = tempfile.mkdtemp()
         dst = join(self.tmp_dir, basename(self.url).replace('::', '-'))
         download(self.url, dst)
         return dst
Exemple #16
0
def get_pkginfo(package, filename, pypiurl, digest, python_version, extra_specs, config,
                setup_options):
    # Unfortunately, two important pieces of metadata are only stored in
    # the package itself: the dependencies, and the entry points (if the
    # package uses distribute).  Our strategy is to download the package
    # and "fake" distribute/setuptools's setup() function to get this
    # information from setup.py. If this sounds evil, keep in mind that
    # distribute itself already works by monkeypatching distutils.
    tempdir = mkdtemp('conda_skeleton_' + filename)

    if not isdir(config.src_cache):
        makedirs(config.src_cache)

    hash_type = digest[0]
    hash_value = digest[1]
    try:
        # Download it to the build source cache. That way, you have
        # it.
        download_path = join(config.src_cache, filename)
        if not isfile(download_path) or \
                hashsum_file(download_path, hash_type) != hash_value:
            download(pypiurl, join(config.src_cache, filename))
            if hashsum_file(download_path, hash_type) != hash_value:
                raise RuntimeError(' Download of {} failed'
                                   ' checksum type {} expected value {}. Please'
                                   ' try again.'.format(package, hash_type, hash_value))
        else:
            print("Using cached download")
        # Calculate the preferred hash type here if necessary.
        # Needs to be done in this block because this is where we have
        # access to the source file.
        if hash_type != POSSIBLE_DIGESTS[0]:
            new_hash_value = hashsum_file(download_path, POSSIBLE_DIGESTS[0])
        else:
            new_hash_value = ''

        print("Unpacking %s..." % package)
        unpack(join(config.src_cache, filename), tempdir)
        print("done")
        print("working in %s" % tempdir)
        src_dir = get_dir(tempdir)
        # TODO: find args parameters needed by run_setuppy
        run_setuppy(src_dir, tempdir, python_version, extra_specs=extra_specs, config=config,
                    setup_options=setup_options)
        try:
            with open(join(tempdir, 'pkginfo.yaml')) as fn:
                pkg_info = yaml.safe_load(fn)
        except IOError:
            pkg_info = pkginfo.SDist(download_path).__dict__
        if new_hash_value:
            pkg_info['new_hash_value'] = (POSSIBLE_DIGESTS[0], new_hash_value)
    finally:
        rm_rf(tempdir)

    return pkg_info
def test_no_platform(testing_workdir, base_platform, package):
    package_name, example_file = package

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    with pytest.raises(SystemExit) as e:
        api.convert(fn, platforms=None)

    assert 'Error: --platform option required for conda package conversion.' in str(e.value)
Exemple #18
0
def test_no_platform(testing_workdir, base_platform, package):
    package_name, example_file = package

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    with pytest.raises(SystemExit) as e:
        api.convert(fn, platforms=None)

    assert 'Error: --platform option required for conda package conversion.' in str(e.value)
Exemple #19
0
def test_no_imports_found(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    with pytest.raises(SystemExit):
        api.convert(fn, platforms=None, show_imports=True)

    output, error = capfd.readouterr()
    assert 'No imports found.' in output
def test_no_imports_found(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(
        base_platform, package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    with pytest.raises(SystemExit):
        api.convert(fn, platforms=None, show_imports=True)

    output, error = capfd.readouterr()
    assert 'No imports found.' in output
Exemple #21
0
def test_develop(testing_env):
    f = "https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz"
    download(f, "conda_version_test.tar.gz")
    tar_xf("conda_version_test.tar.gz", testing_env)
    extract_folder = 'conda_version_test-0.1.0-1'
    cwd = os.getcwd()
    args = ['-p', testing_env, extract_folder]
    main_develop.execute(args)
    py_ver = '.'.join((str(sys.version_info.major), str(sys.version_info.minor)))
    assert cwd in open(os.path.join(get_site_packages(testing_env, py_ver), 'conda.pth')).read()
    args = ['--uninstall', '-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert (cwd not in open(os.path.join(get_site_packages(testing_env, py_ver),
                                         'conda.pth')).read())
Exemple #22
0
def test_develop(testing_env):
    f = "https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz"
    download(f, "conda_version_test.tar.gz")
    tar_xf("conda_version_test.tar.gz", testing_env)
    extract_folder = 'conda_version_test-0.1.0-1'
    cwd = os.getcwd()
    args = ['-p', testing_env, extract_folder]
    main_develop.execute(args)
    py_ver = '.'.join((str(sys.version_info.major), str(sys.version_info.minor)))
    assert cwd in open(os.path.join(get_site_packages(testing_env, py_ver), 'conda.pth')).read()
    args = ['--uninstall', '-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert (cwd not in open(os.path.join(get_site_packages(testing_env, py_ver),
                                         'conda.pth')).read())
Exemple #23
0
def test_develop(testing_env):
    f = "https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz"
    download(f, "conda_version_test.tar.gz")
    from conda_build.utils import tar_xf
    tar_xf("conda_version_test.tar.gz", testing_env)
    extract_folder = 'conda_version_test-0.1.0-1'
    cwd = os.getcwd()
    args = ['-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert cwd in open(os.path.join(get_site_packages(testing_env), 'conda.pth')).read()

    args = ['--uninstall', '-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert (cwd not in open(os.path.join(get_site_packages(testing_env), 'conda.pth')).read())
Exemple #24
0
def release_module_dict(cpan_url, cache_dir, module):
    if 'Regexp-Common' in module:
        print("debug")
    rel_dict = release_module_dict_direct(cpan_url, cache_dir, module)
    if not rel_dict:
        # In this case, the module may be a submodule of another dist, let's try something else.
        # An example of this is Dist::Zilla::Plugin::Git::Check.
        pickled = get_pickle_file_path(cache_dir, module + '.dl_url')
        url = f'{cpan_url}/download_url/{module}'
        try:
            os.makedirs(os.path.dirname(pickled))
        except:
            pass
        download(url, pickled)
        with open(pickled, 'rb') as dl_url_json:
            output = dl_url_json.read()
        if hasattr(output, "decode"):
            output = output.decode('utf-8-sig')
        dl_url_dict = json.loads(output)
        if dl_url_dict['release'].endswith(dl_url_dict['version']):
            # Easy case.
            print(f"Up to date: {module}")
            dist = dl_url_dict['release'].replace('-' + dl_url_dict['version'],
                                                  '')
        else:
            # Difficult case.
            print(f"Not up to date: {module}")
            # cpan -D Time::Zone
            # Time::Zone
            # -------------------------------------------------------------------------
            # 	(no description)
            # 	A/AT/ATOOMIC/TimeDate-2.33.tar.gz
            # 	(no installation file)
            # 	Installed: not installed
            # 	CPAN:      2.24  Not up to date
            # 	icolas . (ATOOMIC)
            # 	[email protected]
            #
            # .. there is no field that lists a version of '2.33' in the data. We need
            #    to inspect the tarball.
            dst = os.path.join(cache_dir,
                               basename(dl_url_dict['download_url']))
            download(dl_url_dict['download_url'], dst)
            with gzip.open(dst) as dist_json_file:
                output = dist_json_file.read()
            # (base) Rays-Mac-Pro:Volumes rdonnelly$ cpan -D Time::Zone
            rel_dict = release_module_dict_direct(cpan_url, cache_dir, dist)

    return rel_dict
Exemple #25
0
def test_convert(testing_workdir):
    # download a sample py2.7 package
    f = "https://repo.continuum.io/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2"
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    # convert it to all platforms
    args = ["-o", "converted", "--platform", "all", pkg_name]
    main_convert.execute(args)
    platforms = ["osx-64", "win-32", "win-64", "linux-64", "linux-32"]
    for platform in platforms:
        dirname = os.path.join("converted", platform)
        assert os.path.isdir(dirname)
        assert pkg_name in os.listdir(dirname)
        with TarCheck(os.path.join(dirname, pkg_name)) as tar:
            tar.correct_subdir(platform)
Exemple #26
0
def test_convert(testing_workdir):
    # download a sample py2.7 package
    f = 'https://repo.continuum.io/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    # convert it to all platforms
    args = ['-o', 'converted', '--platform', 'all', pkg_name]
    main_convert.execute(args)
    platforms = ['osx-64', 'win-32', 'win-64', 'linux-64', 'linux-32']
    for platform in platforms:
        dirname = os.path.join('converted', platform)
        assert os.path.isdir(dirname)
        assert pkg_name in os.listdir(dirname)
        with TarCheck(os.path.join(dirname, pkg_name)) as tar:
            tar.correct_subdir(platform)
Exemple #27
0
def test_convert(testing_workdir):
    # download a sample py2.7 package
    f = 'https://repo.continuum.io/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    # convert it to all platforms
    args = ['-o', 'converted', '--platform', 'all', pkg_name]
    main_convert.execute(args)
    platforms = ['osx-64', 'win-32', 'win-64', 'linux-64', 'linux-32']
    for platform in platforms:
        dirname = os.path.join('converted', platform)
        assert os.path.isdir(dirname)
        assert pkg_name in os.listdir(dirname)
        with TarCheck(os.path.join(dirname, pkg_name)) as tar:
            tar.correct_subdir(platform)
Exemple #28
0
def test_develop(testing_env):
    f = "https://pypi.io/packages/source/c/conda_version_test/conda_version_test-0.1.0-1.tar.gz"
    download(f, "conda_version_test.tar.gz")
    from conda_build.utils import tar_xf
    tar_xf("conda_version_test.tar.gz", testing_env)
    extract_folder = 'conda_version_test-0.1.0-1'
    cwd = os.getcwd()
    args = ['-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert cwd in open(
        os.path.join(get_site_packages(testing_env), 'conda.pth')).read()

    args = ['--uninstall', '-p', testing_env, extract_folder]
    main_develop.execute(args)
    assert (cwd not in open(
        os.path.join(get_site_packages(testing_env), 'conda.pth')).read())
def test_convert_platform_to_others(testing_workdir, base_platform, package):
    package_name, example_file = package
    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py27_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py27_0.tar.bz2".format(package_name)
    download(f, fn)
    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', quiet=False, verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        python_folder = 'lib/python2.7' if not platform.startswith('win') else 'Lib'
        package = os.path.join(platform, fn)
        assert package_has_file(package,
                                '{}/site-packages/{}'.format(python_folder, example_file))

        if expected_paths_json:
            assert package_has_file(package, 'info/paths.json')
            assert_package_paths_matches_files(package)
Exemple #30
0
def test_c_extension_conversion(testing_workdir, base_platform, package):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64' .format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        api.convert(fn, platforms=platform, force=True)

        assert os.path.exists('{}/{}' .format(platform, fn))
Exemple #31
0
def test_convert(testing_workdir, testing_config):
    # download a sample py2.7 package
    f = 'https://repo.anaconda.com/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    # convert it to all platforms
    args = ['-o', 'converted', '--platform', 'all', pkg_name]
    main_convert.execute(args)
    platforms = ['osx-64', 'win-32', 'linux-64', 'linux-32']
    for platform in platforms:
        dirname = os.path.join('converted', platform)
        if platform != 'win-64':
            assert os.path.isdir(dirname)
            assert pkg_name in os.listdir(dirname)
            testing_config.host_subdir = platform
            with TarCheck(os.path.join(dirname, pkg_name), config=testing_config) as tar:
                tar.correct_subdir()
        else:
            assert not os.path.isdir(dirname)
Exemple #32
0
def test_convert_platform_to_others(testing_workdir, base_platform, package):
    package_name, example_file = package
    subdir = '{}-64'.format(base_platform)
    f = 'http://repo.anaconda.com/pkgs/free/{}/{}-py27_0.tar.bz2'.format(subdir,
                                                                         package_name)
    fn = "{}-py27_0.tar.bz2".format(package_name)
    download(f, fn)
    expected_paths_json = package_has_file(fn, 'info/paths.json')
    api.convert(fn, platforms='all', quiet=False, verbose=False)
    for platform in ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']:
        if subdir != platform:
            python_folder = 'lib/python2.7' if not platform.startswith('win') else 'Lib'
            package = os.path.join(platform, fn)
            assert package_has_file(package,
                                    '{}/site-packages/{}'.format(python_folder, example_file))

            if expected_paths_json:
                assert package_has_file(package, 'info/paths.json')
                assert_package_paths_matches_files(package)
def test_c_extension_conversion(testing_workdir, base_platform, package):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64'.format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(
        base_platform, package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        api.convert(fn, platforms=platform, force=True)

        assert os.path.exists('{}/{}'.format(platform, fn))
Exemple #34
0
def test_convert(testing_workdir, testing_config):
    # download a sample py2.7 package
    f = 'https://repo.anaconda.com/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    # convert it to all platforms
    args = ['-o', 'converted', '--platform', 'all', pkg_name]
    main_convert.execute(args)
    platforms = ['osx-64', 'win-32', 'linux-64', 'linux-32']
    for platform in platforms:
        dirname = os.path.join('converted', platform)
        if platform != 'win-64':
            assert os.path.isdir(dirname)
            assert pkg_name in os.listdir(dirname)
            testing_config.host_subdir = platform
            with TarCheck(os.path.join(dirname, pkg_name), config=testing_config) as tar:
                tar.correct_subdir()
        else:
            assert not os.path.isdir(dirname)
def test_c_extension_error(testing_workdir, base_platform, package):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64'.format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.continuum.io/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(
        base_platform, package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        with pytest.raises(SystemExit) as e:
            api.convert(fn, platforms=platform)

    assert ('WARNING: Package {} contains C extensions; skipping conversion. '
            'Use -f to force conversion.'.format(fn)) in str(e.value)
Exemple #36
0
def test_c_extension_error(testing_workdir, base_platform, package):
    package_name, example_file = package
    platforms = ['osx-64', 'win-64', 'win-32', 'linux-64', 'linux-32']

    # skip building on the same platform as the source platform
    for platform in platforms:
        source_platform = '{}-64' .format(base_platform)
        if platform == source_platform:
            platforms.remove(platform)

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-py36_0.tar.bz2".format(package_name)
    download(f, fn)

    for platform in platforms:
        with pytest.raises(SystemExit) as e:
            api.convert(fn, platforms=platform)

    assert ('WARNING: Package {} contains C extensions; skipping conversion. '
            'Use -f to force conversion.' .format(fn)) in str(e.value)
Exemple #37
0
def test_skip_conversion(testing_workdir, base_platform, package, capfd):
    package_name, example_file = package
    source_plat_arch = '{}-64' .format(base_platform)

    f = 'http://repo.anaconda.com/pkgs/free/{}-64/{}-np112py36_0.tar.bz2'.format(base_platform,
                                                                            package_name)
    fn = "{}-np112py36_0.tar.bz2".format(package_name)
    download(f, fn)

    api.convert(fn, platforms=source_plat_arch, dependencies=None, quiet=False, verbose=False)

    output, error = capfd.readouterr()

    skip_message = ("Source platform '{}' and target platform '{}' are identical. "
                    "Skipping conversion.\n"
                    .format(source_plat_arch, source_plat_arch))

    package = os.path.join(source_plat_arch, fn)

    assert skip_message in output
    assert not os.path.exists(package)
Exemple #38
0
def test_sign(testing_workdir):
    # test keygen
    args = ['-k', 'testkey']
    main_sign.execute(args)
    keypath = os.path.expanduser("~/.conda/keys/testkey")
    assert os.path.isfile(keypath)
    assert os.path.isfile(keypath + '.pub')

    # test signing
    # download a test package
    f = 'https://repo.continuum.io/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    args = [pkg_name]
    main_sign.execute(args)
    assert os.path.isfile(pkg_name + '.sig')

    # test verification
    args = ['-v', pkg_name]
    main_sign.execute(args)
    os.remove(keypath)
    os.remove(keypath + '.pub')
Exemple #39
0
def test_sign(testing_workdir):
    # test keygen
    args = ['-k', 'testkey']
    main_sign.execute(args)
    keypath = os.path.expanduser("~/.conda/keys/testkey")
    assert os.path.isfile(keypath)
    assert os.path.isfile(keypath + '.pub')

    # test signing
    # download a test package
    f = 'https://repo.continuum.io/pkgs/free/win-64/affine-2.0.0-py27_0.tar.bz2'
    pkg_name = "affine-2.0.0-py27_0.tar.bz2"
    download(f, pkg_name)
    args = [pkg_name]
    main_sign.execute(args)
    assert os.path.isfile(pkg_name + '.sig')

    # test verification
    args = ['-v', pkg_name]
    main_sign.execute(args)
    os.remove(keypath)
    os.remove(keypath + '.pub')