Skip to content

Commit

Permalink
Merge branch 'master' into pipenv-run-in-hint
Browse files Browse the repository at this point in the history
  • Loading branch information
techalchemy authored Jun 14, 2018
2 parents fcc4dc5 + 42f9c02 commit 3c2c295
Show file tree
Hide file tree
Showing 16 changed files with 389 additions and 122 deletions.
2 changes: 2 additions & 0 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,8 @@ def do_install(
# Don't search for requirements.txt files if the user provides one
if requirements or package_name or project.pipfile_exists:
skip_requirements = True
else:
skip_requirements = False
concurrent = (not sequential)
# Ensure that virtualenv is available.
ensure_project(
Expand Down
10 changes: 9 additions & 1 deletion pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@
def _normalized(p):
if p is None:
return None
return normalize_drive(str(Path(p).resolve()))
loc = Path(p)
if loc.is_absolute():
return normalize_drive(str(loc))
else:
try:
loc = loc.resolve()
except OSError:
loc = loc.absolute()
return normalize_drive(str(loc))


DEFAULT_NEWLINES = u'\n'
Expand Down
16 changes: 9 additions & 7 deletions pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
new_sys_argv.append(v)
sys.argv = new_sys_argv

import pipenv.core
from pipenv.utils import create_mirror_source, resolve_deps, replace_pypi_sources

if is_verbose:
logging.getLogger('notpip').setLevel(logging.INFO)
Expand All @@ -48,12 +48,10 @@ def main():
for i, package in enumerate(packages):
if package.startswith('--'):
del packages[i]
pypi_mirror_source = pipenv.utils.create_mirror_source(os.environ['PIPENV_PYPI_MIRROR']) if 'PIPENV_PYPI_MIRROR' in os.environ else None
project = pipenv.core.project
pypi_mirror_source = create_mirror_source(os.environ['PIPENV_PYPI_MIRROR']) if 'PIPENV_PYPI_MIRROR' in os.environ else None

def resolve(packages, pre, sources, verbose, clear, system):
import pipenv.utils
return pipenv.utils.resolve_deps(
def resolve(packages, pre, project, sources, verbose, clear, system):
return resolve_deps(
packages,
which,
project=project,
Expand All @@ -64,10 +62,14 @@ def resolve(packages, pre, sources, verbose, clear, system):
allow_global=system,
)

from pipenv.core import project
sources = replace_pypi_sources(project.pipfile_sources, pypi_mirror_source) if pypi_mirror_source else project.pipfile_sources
print('using sources: %s' % sources)
results = resolve(
packages,
pre=do_pre,
sources = pipenv.utils.replace_pypi_sources(project.pipfile_sources, pypi_mirror_source) if pypi_mirror_source else project.pipfile_sources,
project=project,
sources=sources,
verbose=is_verbose,
clear=do_clear,
system=system,
Expand Down
4 changes: 2 additions & 2 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class PipCommand(basecommand.Command):
# req.as_line() is theoratically the same as dep, but is guaranteed to
# be normalized. This is safer than passing in dep.
# TODO: Stop passing dep lines around; just use requirement objects.
constraints.append(req.as_line(sources=None))
constraints.append(req.constraint_line)
# extra_constraints = []

if url:
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def clean_resolved_dep(dep, is_top_level=False, pipfile_entry=None):
lockfile = {
'version': '=={0}'.format(dep['version']),
}
for key in ['hashes', 'index']:
for key in ['hashes', 'index', 'extras']:
if key in dep:
lockfile[key] = dep[key]
# In case we lock a uri or a file when the user supplied a path
Expand Down
8 changes: 7 additions & 1 deletion pipenv/vendor/requirementslib/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

class FileNotFoundError(IOError):
pass


else:

class FileNotFoundError(FileNotFoundError):
pass

Expand Down Expand Up @@ -57,4 +60,7 @@ def do_import(module_path, subimport=None, old_path=None):
is_installable_file = do_import("utils.misc", "is_installable_file", old_path="utils")
is_installable_dir = do_import("utils.misc", "is_installable_dir", old_path="utils")
PyPI = do_import("models.index", "PyPI")
make_abstract_dist = do_import("operations.prepare", "make_abstract_dist", old_path="req.req_set")
make_abstract_dist = do_import(
"operations.prepare", "make_abstract_dist", old_path="req.req_set"
)
VcsSupport = do_import("vcs", "VcsSupport")
4 changes: 1 addition & 3 deletions pipenv/vendor/requirementslib/models/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import attr
import json
from .requirements import Requirement
from .utils import (
optional_instance_of,
)
from .utils import optional_instance_of
from .._compat import Path, FileNotFoundError


Expand Down
12 changes: 9 additions & 3 deletions pipenv/vendor/requirementslib/models/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
class PipenvMarkers(BaseRequirement):
"""System-level requirements - see PEP508 for more detail"""

os_name = attr.ib(default=None, validator=attr.validators.optional(validate_markers))
sys_platform = attr.ib(default=None, validator=attr.validators.optional(validate_markers))
os_name = attr.ib(
default=None, validator=attr.validators.optional(validate_markers)
)
sys_platform = attr.ib(
default=None, validator=attr.validators.optional(validate_markers)
)
platform_machine = attr.ib(
default=None, validator=attr.validators.optional(validate_markers)
)
Expand Down Expand Up @@ -59,7 +63,9 @@ def make_marker(cls, marker_string):
try:
marker = Marker(marker_string)
except InvalidMarker:
raise RequirementError("Invalid requirement: Invalid marker %r" % marker_string)
raise RequirementError(
"Invalid requirement: Invalid marker %r" % marker_string
)
marker_dict = {}
for m in marker._markers:
if isinstance(m, six.string_types):
Expand Down
34 changes: 16 additions & 18 deletions pipenv/vendor/requirementslib/models/pipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class Source(object):
#: URL to PyPI instance
url = attr.ib(default="pypi")
#: If False, skip SSL checks
verify_ssl = attr.ib(
default=True, validator=optional_instance_of(bool)
)
verify_ssl = attr.ib(default=True, validator=optional_instance_of(bool))
#: human name to refer to this source (can be referenced in packages or dev-packages)
name = attr.ib(default="")

Expand All @@ -27,13 +25,13 @@ def get_dict(self):
@property
def expanded(self):
source_dict = attr.asdict(self).copy()
source_dict['url'] = os.path.expandvars(source_dict.get('url'))
source_dict["url"] = os.path.expandvars(source_dict.get("url"))
return source_dict


@attr.s
class Section(object):
ALLOWED_NAMES = ('packages', 'dev-packages',)
ALLOWED_NAMES = ("packages", "dev-packages")
#: Name of the pipfile section
name = attr.ib(default="packages")
#: A list of requirements that are contained by the section
Expand Down Expand Up @@ -63,7 +61,7 @@ def get_dict(self):
requires = attr.asdict(self, filter=filter_none)
if not requires:
return {}
return {'requires': requires}
return {"requires": requires}


@attr.s
Expand All @@ -72,7 +70,7 @@ class PipenvSection(object):

def get_dict(self):
if self.allow_prereleases:
return {'pipenv': attr.asdict(self)}
return {"pipenv": attr.asdict(self)}
return {}


Expand Down Expand Up @@ -111,7 +109,7 @@ def get_sources(self):
_dict = {}
for src in self.sources:
_dict.update(src.get_dict())
return {'source': _dict} if _dict else {}
return {"source": _dict} if _dict else {}

def get_sections(self):
"""Return a dictionary with both pipfile sections and requirements"""
Expand All @@ -131,7 +129,7 @@ def get_requires(self):

def get_dict(self):
_dict = attr.asdict(self, recurse=False)
for k in ['path', 'pipfile_hash', 'sources', 'sections', 'requires', 'pipenv']:
for k in ["path", "pipfile_hash", "sources", "sections", "requires", "pipenv"]:
if k in _dict:
_dict.pop(k)
return _dict
Expand All @@ -153,25 +151,25 @@ def dump(self, to_dict=False):
def load(cls, path):
if not isinstance(path, Path):
path = Path(path)
pipfile_path = path / 'Pipfile'
pipfile_path = path / "Pipfile"
if not path.exists():
raise FileNotFoundError("%s is not a valid project path!" % path)
elif not pipfile_path.exists() or not pipfile_path.is_file():
raise RequirementError("%s is not a valid Pipfile" % pipfile_path)
pipfile_dict = toml.load(pipfile_path.as_posix())
sections = [cls.get_section(pipfile_dict, s) for s in Section.ALLOWED_NAMES]
pipenv = pipfile_dict.get('pipenv', {})
requires = pipfile_dict.get('requires', {})
pipenv = pipfile_dict.get("pipenv", {})
requires = pipfile_dict.get("requires", {})
creation_dict = {
'path': pipfile_path,
'sources': [Source(**src) for src in pipfile_dict.get('source', [])],
'sections': sections,
'scripts': pipfile_dict.get('scripts')
"path": pipfile_path,
"sources": [Source(**src) for src in pipfile_dict.get("source", [])],
"sections": sections,
"scripts": pipfile_dict.get("scripts"),
}
if requires:
creation_dict['requires'] = RequiresSection(**requires)
creation_dict["requires"] = RequiresSection(**requires)
if pipenv:
creation_dict['pipenv'] = PipenvSection(**pipenv)
creation_dict["pipenv"] = PipenvSection(**pipenv)
return cls(**creation_dict)

@staticmethod
Expand Down
Loading

0 comments on commit 3c2c295

Please sign in to comment.