未验证 提交 5e7da05f 编写于 作者: F frostming

get pypi source url from pip.conf

Fix #3

PS. functools32 is a malformed package that will fail when trying to build a wheel on it. The current solution is to get metadata from pypi json api,but for private registries, it will still fail.
上级 153efa7c
...@@ -90,6 +90,7 @@ def do_lock( ...@@ -90,6 +90,7 @@ def do_lock(
flat_reqs = list( flat_reqs = list(
itertools.chain(*[deps.values() for _, deps in requirements.items()]) itertools.chain(*[deps.values() for _, deps in requirements.items()])
) )
# TODO: switch reporter at io level.
with halo.Halo(text="Resolving dependencies", spinner="dots") as spin: with halo.Halo(text="Resolving dependencies", spinner="dots") as spin:
reporter = SpinnerReporter(flat_reqs, spin) reporter = SpinnerReporter(flat_reqs, spin)
mapping, dependencies, summaries = resolve( mapping, dependencies, summaries = resolve(
......
...@@ -14,7 +14,7 @@ from pdm.models.requirements import ( ...@@ -14,7 +14,7 @@ from pdm.models.requirements import (
) )
from pdm.models.specifiers import PySpecSet, SpecifierSet from pdm.models.specifiers import PySpecSet, SpecifierSet
from pdm._types import CandidateInfo, Source from pdm._types import CandidateInfo, Source
from pdm.utils import _allow_all_wheels from pdm.utils import _allow_all_wheels, get_pypi_source
if TYPE_CHECKING: if TYPE_CHECKING:
from pdm.models.environment import Environment from pdm.models.environment import Environment
...@@ -34,7 +34,7 @@ def cache_result( ...@@ -34,7 +34,7 @@ def cache_result(
class BaseRepository: class BaseRepository:
def __init__(self, sources: List[Source], environment: Environment) -> None: def __init__(self, sources: List[Source], environment: Environment) -> None:
self.sources = sources self.sources = [get_pypi_source()] + sources
self.environment = environment self.environment = environment
self._candidate_info_cache = context.make_candidate_info_cache() self._candidate_info_cache = context.make_candidate_info_cache()
self._hash_cache = context.make_hash_cache() self._hash_cache = context.make_hash_cache()
......
...@@ -209,6 +209,18 @@ def prepare_pip_source_args( ...@@ -209,6 +209,18 @@ def prepare_pip_source_args(
return pip_args return pip_args
def get_pypi_source():
"""Get what is defined in pip.conf as the index-url."""
install_cmd = InstallCommand()
options, _ = install_cmd.parser.parse_args([])
index_url = options.index_url
parsed = parse.urlparse(index_url)
verify_ssl = parsed.scheme == "https"
if any(parsed.hostname.startswith(host) for host in options.trusted_hosts):
verify_ssl = False
return {"url": index_url, "name": "pypi", "verify_ssl": verify_ssl}
def get_finder( def get_finder(
sources: List[Source], sources: List[Source],
cache_dir: Optional[str] = None, cache_dir: Optional[str] = None,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册