Exemplo n.º 1
0
def test_link_and_ireq():
    url = "git+https://github.com/requests/[email protected]#egg=requests"
    link = Link(url)
    ireq = InstallRequirement.from_editable(url)
    if install_req_from_editable:
        ireq2 = install_req_from_editable(url)
        assert ireq2.link == link
    assert ireq.link == link
Exemplo n.º 2
0
def test_wheelbuilder(tmpdir, PipCommand):
    output_dir = tmpdir.join("output")
    output_dir.mkdir()
    pip_command = PipCommand()
    pip_command.parser.add_option_group(
        make_option_group(index_group, pip_command.parser)
    )
    pip_options, _ = pip_command.parser.parse_args([])
    CACHE_DIR = tmpdir.mkdir("CACHE_DIR")
    pip_options.cache_dir = CACHE_DIR.strpath
    session = pip_command._build_session(pip_options)
    if parse_version(pip_version) > parse_version("19.1.1"):
        index_urls = [pip_options.index_url] + pip_options.extra_index_urls
        search_scope = SearchScope.create(
            find_links=pip_options.find_links, index_urls=index_urls
        )
        selection_prefs = SelectionPreferences(
            True,
            allow_all_prereleases=False,
            format_control=None,
            prefer_binary=False,
            ignore_requires_python=False,
        )
        target_python = TargetPython()
        candidate_prefs = CandidatePreferences(
            prefer_binary=selection_prefs.prefer_binary,
            allow_all_prereleases=selection_prefs.allow_all_prereleases,
        )
        if parse_version(pip_version) > parse_version("19.2.3"):
            link_collector = LinkCollector(session=session, search_scope=search_scope)
            finder_args = {"link_collector": link_collector}
        else:
            finder_args = {"search_scope": search_scope, "session": session}
        finder_args.update(
            {
                "candidate_prefs": candidate_prefs,
                "target_python": target_python,
                "allow_yanked": selection_prefs.allow_yanked,
                "format_control": selection_prefs.format_control,
                "ignore_requires_python": selection_prefs.ignore_requires_python,
            }
        )
    else:
        finder_args = {
            "find_links": pip_options.find_links,
            "index_urls": [pip_options.index_url] + pip_options.extra_index_urls,
            "trusted_hosts": pip_options.trusted_hosts,
            "session": session,
            "allow_all_prereleases": False,
        }
        # finder_args["allow_all_prereleases"] = False
    finder = PackageFinder(**finder_args)
    build_dir = tmpdir.mkdir("build_dir")
    source_dir = tmpdir.mkdir("source_dir")
    download_dir = tmpdir.mkdir("download_dir")
    wheel_download_dir = CACHE_DIR.mkdir("wheels")
    with wheel_cache(USER_CACHE_DIR, FormatControl(None, None)) as wheelcache:
        kwargs = {
            "build_dir": build_dir.strpath,
            "src_dir": source_dir.strpath,
            "download_dir": download_dir.strpath,
            "wheel_download_dir": wheel_download_dir.strpath,
            "finder": finder,
            "require_hashes": False,
            "use_user_site": False,
            "progress_bar": "off",
            "build_isolation": False,
        }
        ireq = InstallRequirement.from_editable(
            "git+https://github.com/urllib3/[email protected]#egg=urllib3"
        )
        if parse_version(pip_version) <= parse_version("20.0.9999999"):
            ireq.populate_link(finder, False, False)
        ireq.ensure_has_source_dir(kwargs["src_dir"])
        # Ensure the remote artifact is downloaded locally. For wheels, it is
        # enough to just download because we'll use them directly. For an sdist,
        # we need to unpack so we can build it.
        unpack_kwargs = {
            "session": session,
            "hashes": ireq.hashes(True),
            "link": ireq.link,
            "location": ireq.source_dir,
            "download_dir": kwargs["download_dir"],
        }
        if parse_version(pip_version) < parse_version("19.2.0"):
            unpack_kwargs["only_download"] = ireq.is_wheel
        if parse_version(pip_version) >= parse_version("10"):
            unpack_kwargs["progress_bar"] = "off"
        if not is_file_url(ireq.link):
            shim_unpack(**unpack_kwargs)
        output_file = None
        ireq.is_direct = True
        build_args = {
            "req": ireq,
            "output_dir": output_dir.strpath,
            "verify": False,
            "build_options": [],
            "global_options": [],
            "editable": False,
        }
        output_file = call_function_with_correct_args(build_one, **build_args)
    # XXX: skipping to here is functionally the same and should pass all tests
    # output_file = build_wheel(**build_wheel_kwargs)
    assert output_file, output_file
Exemplo n.º 3
0
def test_abstract_dist():
    ireq = InstallRequirement.from_editable(
        "git+https://github.com/requests/[email protected]#egg=requests"
    )
    abs_dist = make_abstract_dist(ireq)
    assert abs_dist.__class__.__name__ == SourceDistribution.__name__
Exemplo n.º 4
0
def test_get_editable_from_index():
    r = InstallRequirement.from_editable(
        "git+https://github.com/requests/requests.git#egg=requests[security]")
    deps = get_dependencies_from_index(r)
    assert len(deps) > 0
Exemplo n.º 5
0
def ireq_from_editable(ireq):
    from pip_shims import InstallRequirement
    return InstallRequirement.from_editable(ireq)