-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/better resolver #2267
Feature/better resolver #2267
Changes from 1 commit
7abc2fd
bba2f38
84c0b09
f532b2e
f91371a
1d54a32
892be46
eae8ac9
9e66151
8548fbb
a4d8389
6737ab8
cc68b36
e993ee8
311c90d
824f822
a5e69e4
b605481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
import errno | ||
import logging | ||
import os | ||
import re | ||
import hashlib | ||
import tempfile | ||
import sys | ||
import shutil | ||
import logging | ||
import sys | ||
|
||
import crayons | ||
import parse | ||
import six | ||
import stat | ||
import warnings | ||
from click import echo as click_echo | ||
|
||
from click import echo as click_echo | ||
from first import first | ||
|
||
try: | ||
from weakref import finalize | ||
except ImportError: | ||
|
@@ -28,9 +28,10 @@ def __init__(self, *args, **kwargs): | |
def detach(self): | ||
return False | ||
|
||
logging.basicConfig(level=logging.ERROR) | ||
|
||
from time import time | ||
|
||
logging.basicConfig(level=logging.ERROR) | ||
try: | ||
from urllib.parse import urlparse | ||
except ImportError: | ||
|
@@ -48,7 +49,7 @@ def detach(self): | |
from .environments import ( | ||
PIPENV_MAX_ROUNDS, | ||
PIPENV_CACHE_DIR, | ||
PIPENV_MAX_RETRIES | ||
PIPENV_MAX_RETRIES, | ||
) | ||
|
||
try: | ||
|
@@ -221,8 +222,6 @@ def actually_resolve_reps( | |
): | ||
from .patched.notpip._internal import basecommand | ||
from .patched.notpip._internal.req import parse_requirements | ||
from .patched.notpip._internal.req.req_install import InstallRequirement | ||
from .patched.notpip._vendor import requests as pip_requests | ||
from .patched.notpip._internal.exceptions import DistributionNotFound | ||
from .patched.notpip._vendor.requests.exceptions import HTTPError | ||
from pipenv.patched.piptools.resolver import Resolver | ||
|
@@ -242,18 +241,18 @@ class PipCommand(basecommand.Command): | |
req_dir = TemporaryDirectory(suffix='-requirements', prefix='pipenv-') | ||
cleanup_req_dir = True | ||
for dep in deps: | ||
if dep: | ||
url = None | ||
if ' -i ' in dep: | ||
dep, url = dep.split(' -i ') | ||
req = Requirement.from_line(dep) | ||
_line = req.as_line() | ||
constraints.append(_line) | ||
# extra_constraints = [] | ||
if url: | ||
index_lookup[req.name] = project.get_source(url=url).get('name') | ||
if req.markers: | ||
markers_lookup[req.name] = req.markers.replace('"', "'") | ||
if not dep: | ||
continue | ||
url = None | ||
if ' -i ' in dep: | ||
dep, url = dep.split(' -i ') | ||
req = Requirement.from_line(dep) | ||
constraints.append(req.as_line()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The short answer is no, the long answer is 'a lot of things happen here'. The line we pass in could be anything, but the intermediary step ensures that, for example, if it is a local path, we tell pip to name it properly, or if it is a wheel, we do the same. This step also ensures that we format the line in the proper filesystem-appropriate format, we supply the formatted markers correctly, it essentially offers us an extra layer of sanity checking and validation. At some point we can stop passing 'deps' around at all and just pass requirement objects, I just haven't done the code cleanup for that. |
||
# extra_constraints = [] | ||
if url: | ||
index_lookup[req.name] = project.get_source(url=url).get('name') | ||
if req.markers: | ||
markers_lookup[req.name] = req.markers.replace('"', "'") | ||
constraints_file = None | ||
pip_command = get_pip_command() | ||
pip_args = [] | ||
|
@@ -274,9 +273,11 @@ class PipCommand(basecommand.Command): | |
logging.log.verbose = True | ||
piptools_logging.log.verbose = True | ||
resolved_tree = set() | ||
piptools_constraints = [c for c in parse_requirements(constraints_file, finder=pypi.finder, session=pypi.session, options=pip_options)] | ||
resolver = Resolver( | ||
constraints=piptools_constraints, | ||
constraints=parse_requirements( | ||
constraints_file, | ||
finder=pypi.finder, session=pypi.session, options=pip_options, | ||
), | ||
repository=pypi, | ||
clear_caches=clear, | ||
prereleases=pre, | ||
|
@@ -1119,7 +1120,7 @@ def extract_uri_from_vcs_dep(dep): | |
return None | ||
|
||
|
||
def install_or_update_vcs(vcs_obj, src_dir, name, rev=None): | ||
def install_or_update_vcs(vcs_obj, src_dir, name, rev=None): | ||
target_dir = os.path.join(src_dir, name) | ||
target_rev = vcs_obj.make_rev_options(rev) | ||
if not os.path.exists(target_dir): | ||
|
@@ -1128,7 +1129,9 @@ def install_or_update_vcs(vcs_obj, src_dir, name, rev=None): | |
return vcs_obj.get_revision(target_dir) | ||
|
||
|
||
def get_vcs_deps(project, pip_freeze=None, which=None, verbose=False, clear=False, pre=False, allow_global=False, dev=False): | ||
def get_vcs_deps( | ||
project, pip_freeze=None, which=None, verbose=False, clear=False, | ||
pre=False, allow_global=False, dev=False): | ||
from .patched.notpip._internal.vcs import VcsSupport | ||
section = 'vcs_dev_packages' if dev else 'vcs_packages' | ||
lines = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for cleaning this garbage up, seriously this was so horrible to look at