Skip to content

Commit

Permalink
Fix pep508 direct URL depedencies
Browse files Browse the repository at this point in the history
- Fixes #3148

Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Jan 27, 2019
1 parent 23ee483 commit eae3958
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 106 deletions.
68 changes: 36 additions & 32 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,24 +722,25 @@ def batch_install(deps_list, procs, failed_deps_queue,
os.environ["PIP_USER"] = vistir.compat.fs_str("0")
if "PYTHONHOME" in os.environ:
del os.environ["PYTHONHOME"]
if no_deps:
if not needs_deps:
link = getattr(dep.req, "link", None)
is_wheel = False
if link:
is_wheel = link.is_wheel
is_non_editable_vcs = (dep.is_vcs and not dep.editable)
no_deps = not (dep.is_file_or_url and not (is_wheel or dep.editable))
needs_deps = dep.is_file_or_url and not (is_wheel or dep.editable)
c = pip_install(
dep,
ignore_hashes=any([ignore_hashes, dep.editable, dep.is_vcs]),
allow_global=allow_global,
no_deps=no_deps,
no_deps=not needs_deps,
block=any([dep.editable, dep.is_vcs, blocking]),
index=index,
requirements_dir=requirements_dir,
pypi_mirror=pypi_mirror,
trusted_hosts=trusted_hosts,
extra_indexes=extra_indexes
extra_indexes=extra_indexes,
use_pep517=not retry,
)
if dep.is_vcs or dep.editable:
c.block()
Expand Down Expand Up @@ -822,33 +823,33 @@ def do_install_dependencies(
else:
install_kwargs["nprocs"] = 1

with project.environment.activated():
batch_install(
deps_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
)
# with project.environment.activated():
batch_install(
deps_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
)

if not procs.empty():
_cleanup_procs(procs, concurrent, failed_deps_queue)
if not procs.empty():
_cleanup_procs(procs, concurrent, failed_deps_queue)

# Iterate over the hopefully-poorly-packaged dependencies…
if not failed_deps_queue.empty():
click.echo(
crayons.normal(fix_utf8("Installing initially failed dependencies…"), bold=True)
)
retry_list = []
while not failed_deps_queue.empty():
failed_dep = failed_deps_queue.get()
retry_list.append(failed_dep)
install_kwargs.update({
"nprocs": 1,
"retry": False,
"blocking": True,
})
batch_install(
retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
)
if not procs.empty():
_cleanup_procs(procs, False, failed_deps_queue, retry=False)
# Iterate over the hopefully-poorly-packaged dependencies…
if not failed_deps_queue.empty():
click.echo(
crayons.normal(fix_utf8("Installing initially failed dependencies…"), bold=True)
)
retry_list = []
while not failed_deps_queue.empty():
failed_dep = failed_deps_queue.get()
retry_list.append(failed_dep)
install_kwargs.update({
"nprocs": 1,
"retry": False,
"blocking": True,
})
batch_install(
retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
)
if not procs.empty():
_cleanup_procs(procs, False, failed_deps_queue, retry=False)


def convert_three_to_python(three, python):
Expand Down Expand Up @@ -1266,7 +1267,8 @@ def pip_install(
requirements_dir=None,
extra_indexes=None,
pypi_mirror=None,
trusted_hosts=None
trusted_hosts=None,
use_pep517=True
):
from pipenv.patched.notpip._internal import logger as piplogger
from .utils import Mapping
Expand Down Expand Up @@ -1450,6 +1452,8 @@ def pip_install(
if not ignore_hashes:
pip_command.append("--require-hashes")
pip_command.append("--no-build-isolation")
if not use_pep517:
pip_command.append("--no-use-pep517")
if environments.is_verbose():
click.echo("$ {0}".format(pip_command), err=True)
cache_dir = vistir.compat.Path(PIPENV_CACHE_DIR)
Expand All @@ -1469,8 +1473,8 @@ def pip_install(
cmd = Script.parse(pip_command)
pip_command = cmd.cmdify()
c = None
with project.environment.activated():
c = delegator.run(pip_command, block=block, env=pip_config)
# with project.environment.activated():
c = delegator.run(pip_command, block=block, env=pip_config)
return c


Expand Down
7 changes: 3 additions & 4 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,8 @@ def activated(self, include_extras=True, extra_dists=None):
os.environ["PYTHONDONTWRITEBYTECODE"] = vistir.compat.fs_str("1")
from .environments import PIPENV_USE_SYSTEM
if self.is_venv:
if not PIPENV_USE_SYSTEM:
os.environ["PYTHONPATH"] = self.base_paths["PYTHONPATH"]
os.environ["VIRTUAL_ENV"] = vistir.compat.fs_str(prefix)
os.environ["PYTHONPATH"] = self.base_paths["PYTHONPATH"]
os.environ["VIRTUAL_ENV"] = vistir.compat.fs_str(prefix)
else:
if not PIPENV_USE_SYSTEM and not os.environ.get("VIRTUAL_ENV"):
os.environ["PYTHONPATH"] = self.base_paths["PYTHONPATH"]
Expand All @@ -502,7 +501,7 @@ def activated(self, include_extras=True, extra_dists=None):
pep517_dir = os.path.join(os.path.dirname(pip_vendor.__file__), "pep517")
site.addsitedir(pep517_dir)
os.environ["PYTHONPATH"] = os.pathsep.join([
os.environ["PYTHONPATH"], pep517_dir
os.environ.get("PYTHONPATH", self.base_paths["PYTHONPATH"]), pep517_dir
])
if include_extras:
site.addsitedir(parent_path)
Expand Down
11 changes: 11 additions & 0 deletions pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,14 @@ def is_in_virtualenv():
PIPENV_SPINNER_FAIL_TEXT = fix_utf8(u"✘ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")

PIPENV_SPINNER_OK_TEXT = fix_utf8(u"✔ {0}") if not PIPENV_HIDE_EMOJIS else ("{0}")


def is_type_checking():
try:
from typing import TYPE_CHECKING
except ImportError:
return False
return TYPE_CHECKING


MYPY_RUNNING = is_type_checking()
Loading

0 comments on commit eae3958

Please sign in to comment.