mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #4754 from pypa/drop-delegator
Switch from delegator to subprocess
This commit is contained in:
@@ -43,10 +43,11 @@ steps:
|
||||
parameters:
|
||||
python_version: ${{ parameters.python_version }}
|
||||
|
||||
- script: |
|
||||
- powershell: |
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
pipenv run pytest -ra -n 4 -v --junit-xml=junit/test-results.xml tests/
|
||||
$venv = (pipenv --venv)[0]
|
||||
& $venv/Scripts/pytest.exe -ra -n 4 -v --junit-xml=junit/test-results.xml tests/
|
||||
failOnStderr: false
|
||||
displayName: Run integration tests
|
||||
env:
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from .__version__ import __version__ # noqa
|
||||
from pipenv.__version__ import __version__ # noqa
|
||||
|
||||
|
||||
PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
from .cli import cli
|
||||
from pipenv.cli import cli
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import warnings
|
||||
|
||||
import vistir
|
||||
|
||||
from .vendor.vistir.compat import (
|
||||
from pipenv.vendor.vistir.compat import (
|
||||
NamedTemporaryFile, Path, ResourceWarning, TemporaryDirectory
|
||||
)
|
||||
|
||||
|
||||
+13
-14
@@ -5,12 +5,13 @@ from click import (
|
||||
argument, echo, edit, group, option, pass_context, secho, types, version_option, Choice
|
||||
)
|
||||
|
||||
from ..__version__ import __version__
|
||||
from .._compat import fix_utf8
|
||||
from ..exceptions import PipenvOptionsError
|
||||
from ..patched import crayons
|
||||
from ..vendor import click_completion, delegator
|
||||
from .options import (
|
||||
from pipenv.__version__ import __version__
|
||||
from pipenv._compat import fix_utf8
|
||||
from pipenv.exceptions import PipenvOptionsError
|
||||
from pipenv.patched import crayons
|
||||
from pipenv.vendor import click_completion
|
||||
from pipenv.utils import subprocess_run
|
||||
from pipenv.cli.options import (
|
||||
CONTEXT_SETTINGS, PipenvGroup, code_option, common_options, deploy_option,
|
||||
general_options, install_options, lock_options, pass_state,
|
||||
pypi_mirror_option, python_option, site_packages_option, skip_lock_option,
|
||||
@@ -641,18 +642,16 @@ def run_open(state, module, *args, **kwargs):
|
||||
three=state.three, python=state.python,
|
||||
validate=False, pypi_mirror=state.pypi_mirror,
|
||||
)
|
||||
c = delegator.run(
|
||||
'{0} -c "import {1}; print({1}.__file__);"'.format(which("python"), module)
|
||||
c = subprocess_run(
|
||||
which("python"), "-c", "import {0}; print({0}.__file__)".format(module)
|
||||
)
|
||||
try:
|
||||
assert c.return_code == 0
|
||||
except AssertionError:
|
||||
if c.returncode:
|
||||
echo(crayons.red("Module not found!"))
|
||||
sys.exit(1)
|
||||
if "__init__.py" in c.out:
|
||||
p = os.path.dirname(c.out.strip().rstrip("cdo"))
|
||||
if "__init__.py" in c.stdout:
|
||||
p = os.path.dirname(c.stdout.strip().rstrip("cdo"))
|
||||
else:
|
||||
p = c.out.strip().rstrip("cdo")
|
||||
p = c.stdout.strip().rstrip("cdo")
|
||||
echo(crayons.normal(f"Opening {p!r} in your EDITOR.", bold=True))
|
||||
inline_activate_virtual_environment()
|
||||
edit(filename=p)
|
||||
|
||||
@@ -43,6 +43,10 @@ class Script(object):
|
||||
def args(self):
|
||||
return self._parts[1:]
|
||||
|
||||
@property
|
||||
def cmd_args(self):
|
||||
return self._parts
|
||||
|
||||
def extend(self, extra_args):
|
||||
self._parts.extend(extra_args)
|
||||
|
||||
|
||||
+109
-109
@@ -7,38 +7,35 @@ import time
|
||||
import warnings
|
||||
|
||||
import click
|
||||
|
||||
import delegator
|
||||
import dotenv
|
||||
import pipfile
|
||||
import vistir
|
||||
|
||||
from click_completion import init as init_completion
|
||||
|
||||
from . import environments, exceptions, pep508checker, progress
|
||||
from ._compat import decode_for_output, fix_utf8
|
||||
from .cmdparse import Script
|
||||
from .environments import (
|
||||
from pipenv import environments, exceptions, pep508checker, progress
|
||||
from pipenv._compat import decode_for_output, fix_utf8
|
||||
from pipenv.environments import (
|
||||
PIP_EXISTS_ACTION, PIPENV_CACHE_DIR, PIPENV_COLORBLIND,
|
||||
PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_DONT_USE_PYENV, PIPENV_DONT_USE_ASDF,
|
||||
PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_DONT_USE_ASDF, PIPENV_DONT_USE_PYENV,
|
||||
PIPENV_HIDE_EMOJIS, PIPENV_MAX_SUBPROCESS, PIPENV_PYUP_API_KEY,
|
||||
PIPENV_RESOLVE_VCS, PIPENV_SHELL_FANCY, PIPENV_SKIP_VALIDATION, PIPENV_YES,
|
||||
SESSION_IS_INTERACTIVE, is_type_checking
|
||||
)
|
||||
from .patched import crayons
|
||||
from .project import Project
|
||||
from .utils import (
|
||||
convert_deps_to_pip, create_spinner, download_file,
|
||||
escape_grouped_arguments, find_python, find_windows_executable,
|
||||
get_canonical_names, get_source_list, interrupt_handled_subprocess,
|
||||
is_pinned, is_python_command, is_required_version, is_star, is_valid_url,
|
||||
from pipenv.patched import crayons
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils import (
|
||||
convert_deps_to_pip, create_spinner, download_file, find_python,
|
||||
find_windows_executable, get_canonical_names, get_source_list, is_pinned,
|
||||
is_python_command, is_required_version, is_star, is_valid_url,
|
||||
parse_indexes, pep423_name, prepare_pip_source_args, proper_case,
|
||||
python_version, run_command, venv_resolve_deps
|
||||
python_version, run_command, subprocess_run, venv_resolve_deps
|
||||
)
|
||||
|
||||
|
||||
if is_type_checking():
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from pipenv.vendor.requirementslib.models.requirements import Requirement
|
||||
TSourceDict = Dict[str, Union[str, bool]]
|
||||
|
||||
@@ -396,7 +393,7 @@ def ensure_python(three=None, python=None):
|
||||
err=True,
|
||||
)
|
||||
# check for python installers
|
||||
from .installers import Pyenv, Asdf, InstallerError, InstallerNotFound
|
||||
from .installers import Asdf, InstallerError, InstallerNotFound, Pyenv
|
||||
|
||||
# prefer pyenv if both pyenv and asdf are installed as it's
|
||||
# dedicated to python installs so probably the preferred
|
||||
@@ -454,7 +451,7 @@ def ensure_python(three=None, python=None):
|
||||
else:
|
||||
sp.ok(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
|
||||
# Print the results, in a beautiful blue...
|
||||
click.echo(crayons.cyan(c.out), err=True)
|
||||
click.echo(crayons.cyan(c.stdout), err=True)
|
||||
# Clear the pythonfinder caches
|
||||
from .vendor.pythonfinder import Finder
|
||||
finder = Finder(system=False, global_search=True)
|
||||
@@ -661,21 +658,21 @@ def do_where(virtualenv=False, bare=True):
|
||||
def _cleanup_procs(procs, failed_deps_queue, retry=True):
|
||||
while not procs.empty():
|
||||
c = procs.get()
|
||||
if not c.blocking:
|
||||
c.block()
|
||||
failed = False
|
||||
if c.return_code != 0:
|
||||
failed = True
|
||||
if "Ignoring" in c.out:
|
||||
click.echo(crayons.yellow(c.out.strip()))
|
||||
try:
|
||||
out, err = c.communicate()
|
||||
except AttributeError:
|
||||
out, err = c.stdout, c.stderr
|
||||
failed = c.returncode != 0
|
||||
if "Ignoring" in out:
|
||||
click.echo(crayons.yellow(out.strip()))
|
||||
elif environments.is_verbose():
|
||||
click.echo(crayons.cyan(c.out.strip() or c.err.strip()))
|
||||
click.echo(crayons.cyan(out.strip() or err.strip()))
|
||||
# The Installation failed...
|
||||
if failed:
|
||||
# If there is a mismatch in installed locations or the install fails
|
||||
# due to wrongful disabling of pep517, we should allow for
|
||||
# additional passes at installation
|
||||
if "does not match installed location" in c.err:
|
||||
if "does not match installed location" in err:
|
||||
project.environment.expand_egg_links()
|
||||
click.echo("{}".format(
|
||||
crayons.yellow(
|
||||
@@ -686,14 +683,14 @@ def _cleanup_procs(procs, failed_deps_queue, retry=True):
|
||||
))
|
||||
dep = c.dep.copy()
|
||||
dep.use_pep517 = True
|
||||
elif "Disabling PEP 517 processing is invalid" in c.err:
|
||||
elif "Disabling PEP 517 processing is invalid" in err:
|
||||
dep = c.dep.copy()
|
||||
dep.use_pep517 = True
|
||||
elif not retry:
|
||||
# The Installation failed...
|
||||
# We echo both c.out and c.err because pip returns error details on out.
|
||||
err = c.err.strip().splitlines() if c.err else []
|
||||
out = c.out.strip().splitlines() if c.out else []
|
||||
# We echo both c.stdout and c.stderr because pip returns error details on out.
|
||||
err = err.strip().splitlines() if err else []
|
||||
out = out.strip().splitlines() if out else []
|
||||
err_lines = [line for message in [out, err] for line in message]
|
||||
# Return the subprocess' return code.
|
||||
raise exceptions.InstallError(c.dep.name, extra=err_lines)
|
||||
@@ -715,7 +712,9 @@ def batch_install(deps_list, procs, failed_deps_queue,
|
||||
requirements_dir, no_deps=True, ignore_hashes=False,
|
||||
allow_global=False, blocking=False, pypi_mirror=None,
|
||||
retry=True, sequential_deps=None):
|
||||
from .vendor.requirementslib.models.utils import strip_extras_markers_from_requirement
|
||||
from .vendor.requirementslib.models.utils import (
|
||||
strip_extras_markers_from_requirement
|
||||
)
|
||||
if sequential_deps is None:
|
||||
sequential_deps = []
|
||||
failed = (not retry)
|
||||
@@ -768,12 +767,14 @@ def batch_install(deps_list, procs, failed_deps_queue,
|
||||
if failed and not dep.is_vcs:
|
||||
use_pep517 = getattr(dep, "use_pep517", False)
|
||||
|
||||
is_sequential = sequential_deps and dep.name in sequential_dep_names
|
||||
is_blocking = any([dep.editable, dep.is_vcs, blocking, is_sequential])
|
||||
c = pip_install(
|
||||
dep,
|
||||
ignore_hashes=any([ignore_hashes, dep.editable, dep.is_vcs]),
|
||||
allow_global=allow_global,
|
||||
no_deps=not install_deps,
|
||||
block=any([dep.editable, dep.is_vcs, blocking]),
|
||||
block=is_blocking,
|
||||
index=dep.index,
|
||||
requirements_dir=requirements_dir,
|
||||
pypi_mirror=pypi_mirror,
|
||||
@@ -782,10 +783,6 @@ def batch_install(deps_list, procs, failed_deps_queue,
|
||||
use_pep517=use_pep517,
|
||||
)
|
||||
c.dep = dep
|
||||
# if dep.is_vcs or dep.editable:
|
||||
is_sequential = sequential_deps and dep.name in sequential_dep_names
|
||||
if is_sequential:
|
||||
c.block()
|
||||
|
||||
procs.put(c)
|
||||
if procs.full() or procs.qsize() == len(deps_list) or is_sequential:
|
||||
@@ -964,13 +961,13 @@ def do_create_virtualenv(python=None, site_packages=None, pypi_mirror=None):
|
||||
# Actually create the virtualenv.
|
||||
error = None
|
||||
with create_spinner("Creating virtual environment...") as sp:
|
||||
with interrupt_handled_subprocess(cmd, combine_stderr=False, env=pip_config) as c:
|
||||
click.echo(crayons.cyan(f"{c.out}"), err=True)
|
||||
if c.returncode != 0:
|
||||
error = c.err if environments.is_verbose() else exceptions.prettify_exc(c.err)
|
||||
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed creating virtual environment"))
|
||||
else:
|
||||
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format("Successfully created virtual environment!"))
|
||||
c = subprocess_run(cmd, env=pip_config)
|
||||
click.echo(crayons.cyan(f"{c.stdout}"), err=True)
|
||||
if c.returncode != 0:
|
||||
error = c.stderr if environments.is_verbose() else exceptions.prettify_exc(c.stderr)
|
||||
sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed creating virtual environment"))
|
||||
else:
|
||||
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format("Successfully created virtual environment!"))
|
||||
if error is not None:
|
||||
raise exceptions.VirtualenvCreationException(
|
||||
extra=crayons.red(f"{error}")
|
||||
@@ -1022,12 +1019,13 @@ def get_downloads_info(names_map, section):
|
||||
# Get the version info from the filenames.
|
||||
version = parse_download_fname(fname, name)
|
||||
# Get the hash of each file.
|
||||
cmd = '{} hash "{}"'.format(
|
||||
escape_grouped_arguments(which_pip()),
|
||||
cmd = [
|
||||
which_pip(),
|
||||
"hash",
|
||||
os.sep.join([project.download_location, fname]),
|
||||
)
|
||||
c = delegator.run(cmd)
|
||||
hash = c.out.split("--hash=")[1].strip()
|
||||
]
|
||||
c = subprocess_run(cmd)
|
||||
hash = c.stdout.split("--hash=")[1].strip()
|
||||
# Verify we're adding the correct version from Pipfile
|
||||
# and not one from a dependency.
|
||||
specified_version = p[section].get(name, "")
|
||||
@@ -1177,17 +1175,17 @@ def do_purge(bare=False, downloads=False, allow_global=False):
|
||||
fix_utf8(f"Found {len(to_remove)} installed package(s), purging...")
|
||||
)
|
||||
|
||||
command = "{} uninstall {} -y".format(
|
||||
escape_grouped_arguments(which_pip(allow_global=allow_global)),
|
||||
" ".join(to_remove),
|
||||
)
|
||||
command = [
|
||||
which_pip(allow_global=allow_global),
|
||||
"uninstall", "-y",
|
||||
] + list(to_remove)
|
||||
if environments.is_verbose():
|
||||
click.echo(f"$ {command}")
|
||||
c = delegator.run(command)
|
||||
if c.return_code != 0:
|
||||
raise exceptions.UninstallError(installed, command, c.out + c.err, c.return_code)
|
||||
click.echo(f"$ {' '.join(command)}")
|
||||
c = subprocess_run(command)
|
||||
if c.returncode != 0:
|
||||
raise exceptions.UninstallError(installed, ' '.join(command), c.stdout + c.stderr, c.returncode)
|
||||
if not bare:
|
||||
click.echo(crayons.cyan(c.out))
|
||||
click.echo(crayons.cyan(c.stdout))
|
||||
click.echo(crayons.green("Environment now purged and fresh!"))
|
||||
return installed
|
||||
|
||||
@@ -1209,7 +1207,8 @@ def do_init(
|
||||
):
|
||||
"""Executes the init functionality."""
|
||||
from .environments import (
|
||||
PIPENV_VIRTUALENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_PYTHON, PIPENV_USE_SYSTEM
|
||||
PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_PYTHON, PIPENV_USE_SYSTEM,
|
||||
PIPENV_VIRTUALENV
|
||||
)
|
||||
python = None
|
||||
if PIPENV_PYTHON is not None:
|
||||
@@ -1485,7 +1484,7 @@ def pip_install(
|
||||
err=True,
|
||||
)
|
||||
|
||||
pip_command = [which_pip(allow_global=allow_global), "install"]
|
||||
pip_command = [which("python", allow_global=allow_global), "-m", "pip", "install"]
|
||||
pip_args = get_pip_args(
|
||||
pre=pre, verbose=environments.is_verbose(), upgrade=True,
|
||||
selective_upgrade=selective_upgrade, no_use_pep517=not use_pep517,
|
||||
@@ -1498,7 +1497,7 @@ def pip_install(
|
||||
pip_command.extend(line)
|
||||
pip_command.extend(prepare_pip_source_args(sources))
|
||||
if environments.is_verbose():
|
||||
click.echo(f"$ {pip_command}", err=True)
|
||||
click.echo(f"$ {' '.join(pip_command)}", err=True)
|
||||
cache_dir = vistir.compat.Path(PIPENV_CACHE_DIR)
|
||||
DEFAULT_EXISTS_ACTION = "w"
|
||||
if selective_upgrade:
|
||||
@@ -1519,10 +1518,7 @@ def pip_install(
|
||||
pip_config.update(
|
||||
{"PIP_SRC": vistir.misc.fs_str(src_dir)}
|
||||
)
|
||||
cmd = Script.parse(pip_command)
|
||||
pip_command = cmd.cmdify()
|
||||
c = None
|
||||
c = delegator.run(pip_command, block=block, env=pip_config)
|
||||
c = subprocess_run(pip_command, block=block, env=pip_config)
|
||||
c.env = pip_config
|
||||
return c
|
||||
|
||||
@@ -1537,14 +1533,15 @@ def pip_download(package_name):
|
||||
),
|
||||
}
|
||||
for source in project.sources:
|
||||
cmd = '{} download "{}" -i {} -d {}'.format(
|
||||
escape_grouped_arguments(which_pip()),
|
||||
cmd = [
|
||||
which_pip(),
|
||||
"download",
|
||||
package_name,
|
||||
source["url"],
|
||||
project.download_location,
|
||||
)
|
||||
c = delegator.run(cmd, env=pip_config)
|
||||
if c.return_code == 0:
|
||||
"-i", source["url"],
|
||||
"-d", project.download_location,
|
||||
]
|
||||
c = subprocess_run(cmd, env=pip_config)
|
||||
if c.returncode == 0:
|
||||
break
|
||||
|
||||
return c
|
||||
@@ -1616,10 +1613,10 @@ def system_which(command, mult=False):
|
||||
})
|
||||
result = None
|
||||
try:
|
||||
c = delegator.run(f"{_which} {command}")
|
||||
c = subprocess_run(f"{_which} {command}", shell=True)
|
||||
try:
|
||||
# Which Not found...
|
||||
if c.return_code == 127:
|
||||
if c.returncode == 127:
|
||||
click.echo(
|
||||
"{}: the {} system utility is required for Pipenv to find Python installations properly."
|
||||
"\n Please install it.".format(
|
||||
@@ -1627,7 +1624,7 @@ def system_which(command, mult=False):
|
||||
),
|
||||
err=True,
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
except AssertionError:
|
||||
result = fallback_which(command, allow_global=True)
|
||||
except TypeError:
|
||||
@@ -1635,7 +1632,7 @@ def system_which(command, mult=False):
|
||||
result = fallback_which(command, allow_global=True)
|
||||
else:
|
||||
if not result:
|
||||
result = next(iter([c.out, c.err]), "").split("\n")
|
||||
result = next(iter([c.stdout, c.stderr]), "").split("\n")
|
||||
result = next(iter(result)) if not mult else result
|
||||
return result
|
||||
if not result:
|
||||
@@ -1796,11 +1793,12 @@ def do_py(system=False):
|
||||
|
||||
def do_outdated(pypi_mirror=None, pre=False, clear=False):
|
||||
# TODO: Allow --skip-lock here?
|
||||
from collections import namedtuple
|
||||
|
||||
from .vendor.packaging.utils import canonicalize_name
|
||||
from .vendor.requirementslib.models.requirements import Requirement
|
||||
from .vendor.requirementslib.models.utils import get_version
|
||||
from .vendor.packaging.utils import canonicalize_name
|
||||
from .vendor.vistir.compat import Mapping
|
||||
from collections import namedtuple
|
||||
|
||||
packages = {}
|
||||
package_info = namedtuple("PackageInfo", ["name", "installed", "available"])
|
||||
@@ -1893,7 +1891,7 @@ def do_install(
|
||||
selective_upgrade=False,
|
||||
site_packages=None,
|
||||
):
|
||||
from .environments import PIPENV_VIRTUALENV, PIPENV_USE_SYSTEM
|
||||
from .environments import PIPENV_USE_SYSTEM, PIPENV_VIRTUALENV
|
||||
from .vendor.pip_shims.shims import PipError
|
||||
|
||||
requirements_directory = vistir.path.create_tracked_tempdir(
|
||||
@@ -2116,19 +2114,19 @@ def do_install(
|
||||
extra_indexes=extra_index_url,
|
||||
pypi_mirror=pypi_mirror,
|
||||
)
|
||||
if not c.ok:
|
||||
if c.returncode:
|
||||
sp.write_err(
|
||||
"{} An error occurred while installing {}!".format(
|
||||
crayons.red("Error: ", bold=True), crayons.green(pkg_line)
|
||||
),
|
||||
)
|
||||
sp.write_err(
|
||||
vistir.compat.fs_str(f"Error text: {c.out}")
|
||||
vistir.compat.fs_str(f"Error text: {c.stdout}")
|
||||
)
|
||||
sp.write_err(crayons.cyan(vistir.compat.fs_str(format_pip_error(c.err))))
|
||||
sp.write_err(crayons.cyan(vistir.compat.fs_str(format_pip_error(c.stderr))))
|
||||
if environments.is_verbose():
|
||||
sp.write_err(crayons.cyan(vistir.compat.fs_str(format_pip_output(c.out))))
|
||||
if "setup.py egg_info" in c.err:
|
||||
sp.write_err(crayons.cyan(vistir.compat.fs_str(format_pip_output(c.stdout))))
|
||||
if "setup.py egg_info" in c.stderr:
|
||||
sp.write_err(vistir.compat.fs_str(
|
||||
"This is likely caused by a bug in {}. "
|
||||
"Report this to its maintainers.".format(
|
||||
@@ -2212,8 +2210,8 @@ def do_uninstall(
|
||||
ctx=None
|
||||
):
|
||||
from .environments import PIPENV_USE_SYSTEM
|
||||
from .vendor.requirementslib.models.requirements import Requirement
|
||||
from .vendor.packaging.utils import canonicalize_name
|
||||
from .vendor.requirementslib.models.requirements import Requirement
|
||||
|
||||
# Automatically use an activated virtualenv.
|
||||
if PIPENV_USE_SYSTEM:
|
||||
@@ -2301,8 +2299,8 @@ def do_uninstall(
|
||||
pip_path = which_pip(allow_global=system)
|
||||
cmd = [pip_path, "uninstall", package_name, "-y"]
|
||||
c = run_command(cmd)
|
||||
click.echo(crayons.cyan(c.out))
|
||||
if c.return_code != 0:
|
||||
click.echo(crayons.cyan(c.stdout))
|
||||
if c.returncode != 0:
|
||||
failure = True
|
||||
if not failure and pipfile_remove:
|
||||
in_packages = project.get_package_name_in_pipfile(package_name, dev=False)
|
||||
@@ -2560,8 +2558,8 @@ def do_check(
|
||||
args=None,
|
||||
pypi_mirror=None
|
||||
):
|
||||
from pipenv.vendor.vistir.compat import JSONDecodeError
|
||||
from pipenv.vendor.first import first
|
||||
from pipenv.vendor.vistir.compat import JSONDecodeError
|
||||
|
||||
if not system:
|
||||
# Ensure that virtualenv is available.
|
||||
@@ -2611,14 +2609,14 @@ def do_check(
|
||||
# Run the PEP 508 checker in the virtualenv.
|
||||
cmd = _cmd + [vistir.compat.Path(pep508checker_path).as_posix()]
|
||||
c = run_command(cmd)
|
||||
if c.return_code is not None:
|
||||
if c.returncode is not None:
|
||||
try:
|
||||
results = simplejson.loads(c.out.strip())
|
||||
results = simplejson.loads(c.stdout.strip())
|
||||
except JSONDecodeError:
|
||||
click.echo("{}\n{}\n{}".format(
|
||||
crayons.white(decode_for_output("Failed parsing pep508 results: "), bold=True),
|
||||
c.out.strip(),
|
||||
c.err.strip()
|
||||
c.stdout.strip(),
|
||||
c.stderr.strip()
|
||||
))
|
||||
sys.exit(1)
|
||||
# Load the pipfile.
|
||||
@@ -2681,11 +2679,11 @@ def do_check(
|
||||
c = run_command(cmd, catch_exceptions=False)
|
||||
if output == "default":
|
||||
try:
|
||||
results = simplejson.loads(c.out)
|
||||
results = simplejson.loads(c.stdout)
|
||||
except (ValueError, JSONDecodeError):
|
||||
raise exceptions.JSONParseError(c.out, c.err)
|
||||
raise exceptions.JSONParseError(c.stdout, c.stderr)
|
||||
except Exception:
|
||||
raise exceptions.PipenvCmdError(c.cmd, c.out, c.err, c.return_code)
|
||||
raise exceptions.PipenvCmdError(' '.join(c.args), c.stdout, c.stderr, c.returncode)
|
||||
for (package, resolved, installed, description, vuln) in results:
|
||||
click.echo(
|
||||
"{}: {} {} resolved ({} installed)!".format(
|
||||
@@ -2697,19 +2695,19 @@ def do_check(
|
||||
)
|
||||
click.echo(f"{description}")
|
||||
click.echo()
|
||||
if c.ok:
|
||||
if c.returncode == 0:
|
||||
click.echo(crayons.green("All good!"))
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
else:
|
||||
click.echo(c.out)
|
||||
sys.exit(c.return_code)
|
||||
click.echo(c.stdout)
|
||||
sys.exit(c.returncode)
|
||||
|
||||
|
||||
def do_graph(bare=False, json=False, json_tree=False, reverse=False):
|
||||
from pipenv.vendor.vistir.compat import JSONDecodeError
|
||||
from pipenv.vendor import pipdeptree
|
||||
from pipenv.vendor.vistir.compat import JSONDecodeError
|
||||
pipdeptree_path = pipdeptree.__file__.rstrip("cdo")
|
||||
try:
|
||||
python_path = which("python")
|
||||
@@ -2779,16 +2777,18 @@ def do_graph(bare=False, json=False, json_tree=False, reverse=False):
|
||||
err=True,
|
||||
)
|
||||
sys.exit(1)
|
||||
cmd_args = [python_path, pipdeptree_path, flag, "-l"]
|
||||
cmd_args = [python_path, pipdeptree_path, "-l"]
|
||||
if flag:
|
||||
cmd_args.append(flag)
|
||||
c = run_command(cmd_args)
|
||||
# Run dep-tree.
|
||||
if not bare:
|
||||
if json:
|
||||
data = []
|
||||
try:
|
||||
parsed = simplejson.loads(c.out.strip())
|
||||
parsed = simplejson.loads(c.stdout.strip())
|
||||
except JSONDecodeError:
|
||||
raise exceptions.JSONParseError(c.out, c.err)
|
||||
raise exceptions.JSONParseError(c.stdout, c.stderr)
|
||||
else:
|
||||
for d in parsed:
|
||||
if d["package"]["key"] not in BAD_PACKAGES:
|
||||
@@ -2809,15 +2809,15 @@ def do_graph(bare=False, json=False, json_tree=False, reverse=False):
|
||||
return obj
|
||||
|
||||
try:
|
||||
parsed = simplejson.loads(c.out.strip())
|
||||
parsed = simplejson.loads(c.stdout.strip())
|
||||
except JSONDecodeError:
|
||||
raise exceptions.JSONParseError(c.out, c.err)
|
||||
raise exceptions.JSONParseError(c.stdout, c.stderr)
|
||||
else:
|
||||
data = traverse(parsed)
|
||||
click.echo(simplejson.dumps(data, indent=4))
|
||||
sys.exit(0)
|
||||
else:
|
||||
for line in c.out.strip().split("\n"):
|
||||
for line in c.stdout.strip().split("\n"):
|
||||
# Ignore bad packages as top level.
|
||||
# TODO: This should probably be a "==" in + line.partition
|
||||
if line.split("==")[0] in BAD_PACKAGES and not reverse:
|
||||
@@ -2830,17 +2830,17 @@ def do_graph(bare=False, json=False, json_tree=False, reverse=False):
|
||||
else:
|
||||
click.echo(crayons.normal(line, bold=False))
|
||||
else:
|
||||
click.echo(c.out)
|
||||
if c.return_code != 0:
|
||||
click.echo(c.stdout)
|
||||
if c.returncode != 0:
|
||||
click.echo(
|
||||
"{} {}".format(
|
||||
crayons.red("ERROR: ", bold=True),
|
||||
crayons.white(f"{c.err}"),
|
||||
crayons.white(f"{c.stderr}"),
|
||||
),
|
||||
err=True,
|
||||
)
|
||||
# Return its return code.
|
||||
sys.exit(c.return_code)
|
||||
sys.exit(c.returncode)
|
||||
|
||||
|
||||
def do_sync(
|
||||
@@ -2928,6 +2928,6 @@ def do_clean(
|
||||
# Uninstall the package.
|
||||
cmd = [which_pip(), "uninstall", apparent_bad_package, "-y"]
|
||||
c = run_command(cmd)
|
||||
if c.return_code != 0:
|
||||
if c.returncode != 0:
|
||||
failure = True
|
||||
sys.exit(int(failure))
|
||||
|
||||
+17
-23
@@ -13,11 +13,11 @@ import pkg_resources
|
||||
|
||||
import pipenv
|
||||
|
||||
from .vendor.cached_property import cached_property
|
||||
from .vendor.packaging.utils import canonicalize_name
|
||||
from .vendor import vistir
|
||||
from pipenv.vendor.cached_property import cached_property
|
||||
from pipenv.vendor.packaging.utils import canonicalize_name
|
||||
from pipenv.vendor import vistir
|
||||
|
||||
from .utils import normalize_path, make_posix
|
||||
from pipenv.utils import normalize_path, make_posix, subprocess_run
|
||||
|
||||
|
||||
if False:
|
||||
@@ -25,8 +25,8 @@ if False:
|
||||
import tomlkit
|
||||
from typing import ContextManager, Dict, Generator, List, Optional, Set, Union
|
||||
from types import ModuleType
|
||||
from .project import TSource, TPipfile, Project
|
||||
from .vendor.packaging.version import Version
|
||||
from pipenv.project import TSource, TPipfile, Project
|
||||
from pipenv.vendor.packaging.version import Version
|
||||
|
||||
BASE_WORKING_SET = pkg_resources.WorkingSet(sys.path)
|
||||
# TODO: Unittests for this class
|
||||
@@ -361,9 +361,7 @@ class Environment:
|
||||
tmpfile_path = make_posix(tmpfile.name)
|
||||
py_command = self.build_command(python_lib=True, python_inc=True, scripts=True, py_version=True)
|
||||
command = [self.python, "-c", py_command.format(tmpfile_path)]
|
||||
c = vistir.misc.run(
|
||||
command, return_object=True, block=True, nospin=True, write_to_stdout=False
|
||||
)
|
||||
c = subprocess_run(command)
|
||||
if c.returncode == 0:
|
||||
paths = {}
|
||||
with open(tmpfile_path, "r", encoding="utf-8") as fh:
|
||||
@@ -375,8 +373,8 @@ class Environment:
|
||||
paths[key] = make_posix(paths[key])
|
||||
return paths
|
||||
else:
|
||||
vistir.misc.echo(f"Failed to load paths: {c.err}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.out}", fg="yellow")
|
||||
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
|
||||
return None
|
||||
|
||||
def get_lib_paths(self):
|
||||
@@ -391,9 +389,7 @@ class Environment:
|
||||
tmpfile_path = make_posix(tmpfile.name)
|
||||
py_command = self.build_command(python_lib=True)
|
||||
command = [self.python, "-c", py_command.format(tmpfile_path)]
|
||||
c = vistir.misc.run(
|
||||
command, return_object=True, block=True, nospin=True, write_to_stdout=False
|
||||
)
|
||||
c = subprocess_run(command)
|
||||
paths = None
|
||||
if c.returncode == 0:
|
||||
paths = {}
|
||||
@@ -406,8 +402,8 @@ class Environment:
|
||||
paths[key] = make_posix(paths[key])
|
||||
return paths
|
||||
else:
|
||||
vistir.misc.echo(f"Failed to load paths: {c.err}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.out}", fg="yellow")
|
||||
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
|
||||
if not paths:
|
||||
if not self.prefix.joinpath("lib").exists():
|
||||
return {}
|
||||
@@ -445,9 +441,7 @@ class Environment:
|
||||
"fh = io.open('{0}', 'w'); fh.write(value); fh.close()"
|
||||
)
|
||||
command = [self.python, "-c", py_command.format(tmpfile_path)]
|
||||
c = vistir.misc.run(
|
||||
command, return_object=True, block=True, nospin=True, write_to_stdout=False
|
||||
)
|
||||
c = subprocess_run(command)
|
||||
if c.returncode == 0:
|
||||
paths = []
|
||||
with open(tmpfile_path, "r", encoding="utf-8") as fh:
|
||||
@@ -457,8 +451,8 @@ class Environment:
|
||||
paths[key] = make_posix(paths[key])
|
||||
return paths
|
||||
else:
|
||||
vistir.misc.echo(f"Failed to load paths: {c.err}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.out}", fg="yellow")
|
||||
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
|
||||
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
@@ -472,8 +466,8 @@ class Environment:
|
||||
"""
|
||||
|
||||
command = [self.python, "-c", "import sys; print(sys.prefix)"]
|
||||
c = vistir.misc.run(command, return_object=True, block=True, nospin=True, write_to_stdout=False)
|
||||
sys_prefix = vistir.compat.Path(vistir.misc.to_text(c.out).strip()).as_posix()
|
||||
c = subprocess_run(command)
|
||||
sys_prefix = vistir.compat.Path(c.stdout.strip()).as_posix()
|
||||
return sys_prefix
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -3,8 +3,8 @@ import sys
|
||||
|
||||
from appdirs import user_cache_dir
|
||||
|
||||
from ._compat import fix_utf8
|
||||
from .vendor.vistir.misc import _isatty, fs_str
|
||||
from pipenv._compat import fix_utf8
|
||||
from pipenv.vendor.vistir.misc import _isatty, fs_str
|
||||
|
||||
|
||||
# HACK: avoid resolver.py uses the wrong byte code files.
|
||||
|
||||
@@ -5,14 +5,14 @@ import sys
|
||||
from collections import namedtuple
|
||||
from traceback import format_tb
|
||||
|
||||
from . import environments
|
||||
from ._compat import decode_for_output
|
||||
from .patched import crayons
|
||||
from .vendor.click.exceptions import (
|
||||
from pipenv import environments
|
||||
from pipenv._compat import decode_for_output
|
||||
from pipenv.patched import crayons
|
||||
from pipenv.vendor.click.exceptions import (
|
||||
ClickException, FileError, UsageError
|
||||
)
|
||||
from .vendor.vistir.misc import echo as click_echo
|
||||
import vistir
|
||||
from pipenv.vendor.vistir.misc import echo as click_echo
|
||||
from pipenv.vendor import vistir
|
||||
|
||||
ANSI_REMOVAL_RE = re.compile(r"\033\[((?:\d|;)*)([a-zA-Z])", re.MULTILINE)
|
||||
STRING_TYPES = ((str,), crayons.ColoredString)
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ import sys
|
||||
|
||||
import pipenv
|
||||
|
||||
from .core import project
|
||||
from .pep508checker import lookup
|
||||
from .vendor import pythonfinder
|
||||
from pipenv.core import project
|
||||
from pipenv.pep508checker import lookup
|
||||
from pipenv.vendor import pythonfinder
|
||||
|
||||
|
||||
def print_utf(line):
|
||||
|
||||
+9
-10
@@ -4,9 +4,9 @@ import re
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
|
||||
from .environments import PIPENV_INSTALL_TIMEOUT
|
||||
from .vendor import attr, delegator
|
||||
from .utils import find_windows_executable
|
||||
from pipenv.environments import PIPENV_INSTALL_TIMEOUT
|
||||
from pipenv.vendor import attr
|
||||
from pipenv.utils import find_windows_executable, subprocess_run
|
||||
|
||||
|
||||
@attr.s
|
||||
@@ -59,8 +59,8 @@ class InstallerNotFound(RuntimeError):
|
||||
class InstallerError(RuntimeError):
|
||||
def __init__(self, desc, c):
|
||||
super().__init__(desc)
|
||||
self.out = c.out
|
||||
self.err = c.err
|
||||
self.out = c.stdout
|
||||
self.err = c.stderr
|
||||
|
||||
|
||||
class Installer(metaclass=ABCMeta):
|
||||
@@ -114,14 +114,13 @@ class Installer(metaclass=ABCMeta):
|
||||
raise InstallerNotFound()
|
||||
|
||||
def _run(self, *args, **kwargs):
|
||||
timeout = kwargs.pop('timeout', delegator.TIMEOUT)
|
||||
timeout = kwargs.pop('timeout', 30)
|
||||
if kwargs:
|
||||
k = list(kwargs.keys())[0]
|
||||
raise TypeError(f'unexpected keyword argument {k!r}')
|
||||
args = (self.cmd,) + tuple(args)
|
||||
c = delegator.run(args, block=False, timeout=timeout)
|
||||
c.block()
|
||||
if c.return_code != 0:
|
||||
c = subprocess_run(args, timeout=timeout)
|
||||
if c.returncode != 0:
|
||||
raise InstallerError(f'failed to run {args}', c)
|
||||
return c
|
||||
|
||||
@@ -201,7 +200,7 @@ class Asdf(Installer):
|
||||
def iter_installable_versions(self):
|
||||
"""Iterate through CPython versions available for asdf to install.
|
||||
"""
|
||||
for name in self._run('list-all', 'python').out.splitlines():
|
||||
for name in self._run('list-all', 'python').stdout.splitlines():
|
||||
try:
|
||||
version = Version.parse(name.strip())
|
||||
except ValueError:
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import os
|
||||
import subprocess
|
||||
import threading
|
||||
from time import monotonic as _time
|
||||
|
||||
from pipenv._compat import DEFAULT_ENCODING
|
||||
from pipenv.cmdparse import Script
|
||||
|
||||
|
||||
class PopenProcess:
|
||||
"""A wrapper of subprocess.Popen that
|
||||
doesn't need to worry about the Pipe buffer exceeding the limit.
|
||||
"""
|
||||
def __init__(
|
||||
self, args, *, block=True, encoding=DEFAULT_ENCODING, env=None, timeout=None, **other_kwargs
|
||||
):
|
||||
self.blocking = block
|
||||
self.env = env
|
||||
self.script = Script.parse(args)
|
||||
if env is not None:
|
||||
env = dict(os.environ, **env)
|
||||
other_kwargs['env'] = env
|
||||
other_kwargs['stdout'] = subprocess.PIPE
|
||||
other_kwargs['stderr'] = subprocess.PIPE
|
||||
self._process = subprocess.Popen(args, universal_newlines=True, encoding=encoding, **other_kwargs)
|
||||
self._endtime = None
|
||||
if timeout is not None:
|
||||
self._endtime = _time() + timeout
|
||||
self.out_buffer = []
|
||||
self.err_buffer = []
|
||||
self._start_polling()
|
||||
|
||||
def wait(self):
|
||||
try:
|
||||
self._process.wait(self._remaining_time())
|
||||
except subprocess.TimeoutExpired:
|
||||
self._process.kill()
|
||||
raise
|
||||
finally:
|
||||
self.out_reader.join()
|
||||
self.err_reader.join()
|
||||
|
||||
@property
|
||||
def return_code(self):
|
||||
return self._process.returncode
|
||||
|
||||
@property
|
||||
def out(self):
|
||||
return "".join(self.out_buffer)
|
||||
|
||||
@property
|
||||
def err(self):
|
||||
return "".join(self.err_buffer)
|
||||
|
||||
def _remaining_time(self):
|
||||
if self._endtime is None:
|
||||
return None
|
||||
return self._endtime - _time()
|
||||
|
||||
def _pipe_output(self):
|
||||
for line in iter(self._process.stdout.readline, ""):
|
||||
self.out_buffer.append(line)
|
||||
|
||||
def _pipe_err(self):
|
||||
for line in iter(self._process.stderr.readline, ""):
|
||||
self.err_buffer.append(line)
|
||||
|
||||
def _start_polling(self):
|
||||
self.out_reader = threading.Thread(target=self._pipe_output)
|
||||
self.err_reader = threading.Thread(target=self._pipe_err)
|
||||
self.out_reader.start()
|
||||
self.err_reader.start()
|
||||
+1
-1
@@ -13,7 +13,7 @@ import time
|
||||
|
||||
import crayons
|
||||
|
||||
from .environments import PIPENV_COLORBLIND, PIPENV_HIDE_EMOJIS
|
||||
from pipenv.environments import PIPENV_COLORBLIND, PIPENV_HIDE_EMOJIS
|
||||
|
||||
|
||||
STREAM = sys.stderr
|
||||
|
||||
+8
-7
@@ -18,17 +18,17 @@ import vistir
|
||||
import pipfile
|
||||
import pipfile.api
|
||||
|
||||
from .vendor.cached_property import cached_property
|
||||
from pipenv.vendor.cached_property import cached_property
|
||||
|
||||
from .cmdparse import Script
|
||||
from .environment import Environment
|
||||
from .environments import (
|
||||
from pipenv.cmdparse import Script
|
||||
from pipenv.environment import Environment
|
||||
from pipenv.environments import (
|
||||
PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_IGNORE_VIRTUALENVS, PIPENV_MAX_DEPTH,
|
||||
PIPENV_PIPFILE, PIPENV_PYTHON, PIPENV_TEST_INDEX, PIPENV_VENV_IN_PROJECT,
|
||||
PIPENV_USE_SYSTEM, is_in_virtualenv, is_type_checking, is_using_venv
|
||||
)
|
||||
from .vendor.requirementslib.models.utils import get_default_pyproject_backend
|
||||
from .utils import (
|
||||
from pipenv.vendor.requirementslib.models.utils import get_default_pyproject_backend
|
||||
from pipenv.utils import (
|
||||
cleanup_toml, convert_toml_outline_tables, find_requirements,
|
||||
get_canonical_names, get_url_name, get_workon_home, is_editable,
|
||||
is_installable_file, is_star, is_valid_url, is_virtual_environment,
|
||||
@@ -350,7 +350,8 @@ class Project(object):
|
||||
def get_environment(self, allow_global=False):
|
||||
# type: (bool) -> Environment
|
||||
is_venv = is_in_virtualenv() or is_using_venv()
|
||||
if allow_global and not is_venv:
|
||||
use_system = os.getenv('PIPENV_USE_SYSTEM') == '1'
|
||||
if use_system or allow_global and not is_venv:
|
||||
prefix = sys.prefix
|
||||
python = sys.executable
|
||||
else:
|
||||
|
||||
+4
-4
@@ -6,10 +6,10 @@ import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .environments import PIPENV_EMULATOR, PIPENV_SHELL, PIPENV_SHELL_EXPLICIT
|
||||
from .vendor import shellingham
|
||||
from .vendor.vistir.compat import Path, get_terminal_size
|
||||
from .vendor.vistir.contextmanagers import temp_environ
|
||||
from pipenv.environments import PIPENV_EMULATOR, PIPENV_SHELL, PIPENV_SHELL_EXPLICIT
|
||||
from pipenv.vendor import shellingham
|
||||
from pipenv.vendor.vistir.compat import Path, get_terminal_size
|
||||
from pipenv.vendor.vistir.contextmanagers import temp_environ
|
||||
|
||||
|
||||
ShellDetectionFailure = shellingham.ShellDetectionFailure
|
||||
|
||||
+74
-101
@@ -1,3 +1,4 @@
|
||||
import subprocess
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
@@ -20,19 +21,20 @@ import crayons
|
||||
import parse
|
||||
import tomlkit
|
||||
|
||||
from . import environments
|
||||
from .exceptions import PipenvCmdError, PipenvUsageError, RequirementError, ResolutionFailure
|
||||
from .pep508checker import lookup
|
||||
from .vendor.packaging.markers import Marker
|
||||
from .vendor.urllib3 import util as urllib3_util
|
||||
from .vendor.vistir.compat import Mapping, ResourceWarning, Sequence, Set, lru_cache
|
||||
from .vendor.vistir.misc import fs_str, run
|
||||
from pipenv import environments
|
||||
from pipenv._compat import DEFAULT_ENCODING
|
||||
from pipenv.exceptions import PipenvCmdError, PipenvUsageError, RequirementError, ResolutionFailure
|
||||
from pipenv.pep508checker import lookup
|
||||
from pipenv.vendor.packaging.markers import Marker
|
||||
from pipenv.vendor.urllib3 import util as urllib3_util
|
||||
from pipenv.vendor.vistir.compat import Mapping, ResourceWarning, Sequence, Set, lru_cache
|
||||
from pipenv.vendor.vistir.misc import fs_str, run
|
||||
|
||||
if environments.MYPY_RUNNING:
|
||||
from typing import Tuple, Dict, Any, List, Union, Optional, Text
|
||||
from .vendor.requirementslib.models.requirements import Requirement, Line
|
||||
from .vendor.requirementslib.models.pipfile import Pipfile
|
||||
from .project import Project, TSource
|
||||
from pipenv.vendor.requirementslib.models.requirements import Requirement, Line
|
||||
from pipenv.vendor.requirementslib.models.pipfile import Pipfile
|
||||
from pipenv.project import Project, TSource
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
@@ -129,7 +131,6 @@ def run_command(cmd, *args, **kwargs):
|
||||
:raises: exceptions.PipenvCmdError
|
||||
"""
|
||||
|
||||
from pipenv.vendor import delegator
|
||||
from ._compat import decode_for_output
|
||||
from .cmdparse import Script
|
||||
catch_exceptions = kwargs.pop("catch_exceptions", True)
|
||||
@@ -140,21 +141,16 @@ def run_command(cmd, *args, **kwargs):
|
||||
if "env" not in kwargs:
|
||||
kwargs["env"] = os.environ.copy()
|
||||
kwargs["env"]["PYTHONIOENCODING"] = "UTF-8"
|
||||
try:
|
||||
cmd_string = cmd.cmdify()
|
||||
except TypeError:
|
||||
click_echo(f"Error turning command into string: {cmd}", err=True)
|
||||
sys.exit(1)
|
||||
command = [cmd.command, *cmd.args]
|
||||
if environments.is_verbose():
|
||||
click_echo(f"Running command: $ {cmd_string}")
|
||||
c = delegator.run(cmd_string, *args, **kwargs)
|
||||
return_code = c.return_code
|
||||
click_echo(f"Running command: $ {cmd.cmdify()}")
|
||||
c = subprocess_run(command, *args, **kwargs)
|
||||
if environments.is_verbose():
|
||||
click_echo("Command output: {}".format(
|
||||
crayons.cyan(decode_for_output(c.out))
|
||||
crayons.cyan(decode_for_output(c.stdout))
|
||||
), err=True)
|
||||
if not c.ok and catch_exceptions:
|
||||
raise PipenvCmdError(cmd_string, c.out, c.err, return_code)
|
||||
if c.returncode and catch_exceptions:
|
||||
raise PipenvCmdError(cmd.cmdify(), c.stdout, c.stderr, c.returncode)
|
||||
return c
|
||||
|
||||
|
||||
@@ -1131,50 +1127,30 @@ def create_spinner(text, nospin=None, spinner_name=None):
|
||||
|
||||
def resolve(cmd, sp):
|
||||
from .cmdparse import Script
|
||||
from .vendor import delegator
|
||||
from .vendor.pexpect.exceptions import EOF, TIMEOUT
|
||||
from .vendor.vistir.compat import to_native_string
|
||||
from .vendor.vistir.misc import echo
|
||||
EOF.__module__ = "pexpect.exceptions"
|
||||
from ._compat import decode_output
|
||||
c = delegator.run(Script.parse(cmd).cmdify(), block=False, env=os.environ.copy())
|
||||
if environments.is_verbose():
|
||||
c.subprocess.logfile = sys.stderr
|
||||
_out = decode_output("")
|
||||
result = None
|
||||
out = to_native_string("")
|
||||
while True:
|
||||
result = None
|
||||
try:
|
||||
result = c.expect("\n", timeout=environments.PIPENV_INSTALL_TIMEOUT)
|
||||
except TIMEOUT:
|
||||
pass
|
||||
except EOF:
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
c.kill()
|
||||
break
|
||||
if result:
|
||||
_out = c.subprocess.before
|
||||
_out = decode_output(f"{_out}")
|
||||
out += _out
|
||||
# sp.text = to_native_string("{0}".format(_out[:100]))
|
||||
if environments.is_verbose():
|
||||
sp.hide_and_write(out.splitlines()[-1].rstrip())
|
||||
else:
|
||||
break
|
||||
c.block()
|
||||
if c.return_code != 0:
|
||||
c = subprocess_run(Script.parse(cmd).cmd_args, block=False, env=os.environ.copy())
|
||||
err = ""
|
||||
for line in iter(c.stderr.readline, ""):
|
||||
line = decode_output(line)
|
||||
err += line
|
||||
if environments.is_verbose() and line.rstrip():
|
||||
sp.hide_and_write(line.rstrip())
|
||||
|
||||
c.wait()
|
||||
returncode = c.poll()
|
||||
out = c.stdout.read()
|
||||
if returncode != 0:
|
||||
sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(
|
||||
"Locking Failed!"
|
||||
))
|
||||
echo(c.out.strip(), err=True)
|
||||
echo(out.strip(), err=True)
|
||||
if not environments.is_verbose():
|
||||
echo(out, err=True)
|
||||
sys.exit(c.return_code)
|
||||
echo(err, err=True)
|
||||
sys.exit(returncode)
|
||||
if environments.is_verbose():
|
||||
echo(c.err.strip(), err=True)
|
||||
return c
|
||||
echo(out.strip(), err=True)
|
||||
return subprocess.CompletedProcess(c.args, returncode, out, err)
|
||||
|
||||
|
||||
def get_locked_dep(dep, pipfile_section, prefer_pipfile=True):
|
||||
@@ -1334,21 +1310,21 @@ def venv_resolve_deps(
|
||||
os.environ["PIPENV_PACKAGES"] = str("\n".join(constraints))
|
||||
sp.write(decode_for_output("Resolving dependencies..."))
|
||||
c = resolve(cmd, sp)
|
||||
results = c.out.strip()
|
||||
if c.ok:
|
||||
results = c.stdout.strip()
|
||||
if c.returncode == 0:
|
||||
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
|
||||
if not environments.is_verbose() and c.out.strip():
|
||||
click_echo(crayons.yellow(f"Warning: {c.out.strip()}"), err=True)
|
||||
if not environments.is_verbose() and c.stderr.strip():
|
||||
click_echo(crayons.yellow(f"Warning: {c.stderr.strip()}"), err=True)
|
||||
else:
|
||||
sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!"))
|
||||
click_echo(f"Output: {c.out.strip()}", err=True)
|
||||
click_echo(f"Error: {c.err.strip()}", err=True)
|
||||
click_echo(f"Output: {c.stdout.strip()}", err=True)
|
||||
click_echo(f"Error: {c.stderr.strip()}", err=True)
|
||||
try:
|
||||
with open(target_file.name) as fh:
|
||||
results = json.load(fh)
|
||||
except (IndexError, JSONDecodeError):
|
||||
click_echo(c.out.strip(), err=True)
|
||||
click_echo(c.err.strip(), err=True)
|
||||
click_echo(c.stdout.strip(), err=True)
|
||||
click_echo(c.stderr.strip(), err=True)
|
||||
if os.path.exists(target_file.name):
|
||||
os.unlink(target_file.name)
|
||||
raise RuntimeError("There was a problem with locking.")
|
||||
@@ -1723,14 +1699,13 @@ def temp_path():
|
||||
|
||||
|
||||
def load_path(python):
|
||||
from ._compat import Path
|
||||
import delegator
|
||||
from pathlib import Path
|
||||
import json
|
||||
python = Path(python).as_posix()
|
||||
json_dump_commmand = '"import json, sys; print(json.dumps(sys.path));"'
|
||||
c = delegator.run(f'"{python}" -c {json_dump_commmand}')
|
||||
if c.return_code == 0:
|
||||
return json.loads(c.out.strip())
|
||||
c = subprocess_run([python, "-c", json_dump_commmand])
|
||||
if c.returncode == 0:
|
||||
return json.loads(c.stdout.strip())
|
||||
else:
|
||||
return []
|
||||
|
||||
@@ -2248,35 +2223,6 @@ def is_python_command(line):
|
||||
return False
|
||||
|
||||
|
||||
# def make_marker_from_specifier(spec):
|
||||
# # type: (str) -> Optional[Marker]
|
||||
# """Given a python version specifier, create a marker
|
||||
|
||||
# :param spec: A specifier
|
||||
# :type spec: str
|
||||
# :return: A new marker
|
||||
# :rtype: Optional[:class:`packaging.marker.Marker`]
|
||||
# """
|
||||
# from .vendor.packaging.markers import Marker
|
||||
# from .vendor.packaging.specifiers import SpecifierSet, Specifier
|
||||
# from .vendor.requirementslib.models.markers import cleanup_pyspecs, format_pyversion
|
||||
# if not any(spec.startswith(k) for k in Specifier._operators.keys()):
|
||||
# if spec.strip().lower() in ["any", "<any>", "*"]:
|
||||
# return None
|
||||
# spec = "=={0}".format(spec)
|
||||
# elif spec.startswith("==") and spec.count("=") > 3:
|
||||
# spec = "=={0}".format(spec.lstrip("="))
|
||||
# if not spec:
|
||||
# return None
|
||||
# marker_segments = []
|
||||
# print(spec)
|
||||
# for marker_segment in cleanup_pyspecs(spec):
|
||||
# print(marker_segment)
|
||||
# marker_segments.append(format_pyversion(marker_segment))
|
||||
# marker_str = " and ".join(marker_segments)
|
||||
# return Marker(marker_str)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def interrupt_handled_subprocess(
|
||||
cmd, verbose=False, return_object=True, write_to_stdout=False, combine_stderr=True,
|
||||
@@ -2312,3 +2258,30 @@ def interrupt_handled_subprocess(
|
||||
os.kill(obj.pid, signal.SIGINT)
|
||||
obj.wait()
|
||||
raise
|
||||
|
||||
|
||||
def subprocess_run(
|
||||
args, *, block=True, text=True, capture_output=True,
|
||||
encoding=DEFAULT_ENCODING, env=None, **other_kwargs
|
||||
):
|
||||
"""A backward compatible version of subprocess.run().
|
||||
|
||||
It outputs text with default encoding, and store all outputs in the returned object instead of
|
||||
printing onto stdout.
|
||||
"""
|
||||
if env is not None:
|
||||
env = dict(os.environ, **env)
|
||||
other_kwargs['env'] = env
|
||||
if capture_output:
|
||||
other_kwargs['stdout'] = subprocess.PIPE
|
||||
other_kwargs['stderr'] = subprocess.PIPE
|
||||
if block:
|
||||
return subprocess.run(
|
||||
args, universal_newlines=text,
|
||||
encoding=encoding, **other_kwargs
|
||||
)
|
||||
else:
|
||||
return subprocess.Popen(
|
||||
args, universal_newlines=text,
|
||||
encoding=encoding, **other_kwargs
|
||||
)
|
||||
|
||||
Vendored
-341
@@ -1,341 +0,0 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shlex
|
||||
import signal
|
||||
import sys
|
||||
import locale
|
||||
import errno
|
||||
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
import pexpect
|
||||
pexpect.EOF.__module__ = "pexpect.exceptions"
|
||||
|
||||
# Include `unicode` in STR_TYPES for Python 2.X
|
||||
try:
|
||||
STR_TYPES = (str, unicode)
|
||||
except NameError:
|
||||
STR_TYPES = (str,)
|
||||
|
||||
TIMEOUT = 30
|
||||
|
||||
|
||||
def pid_exists(pid):
|
||||
"""Check whether pid exists in the current process table."""
|
||||
if pid == 0:
|
||||
# According to "man 2 kill" PID 0 has a special meaning:
|
||||
# it refers to <<every process in the process group of the
|
||||
# calling process>> so we don't want to go any further.
|
||||
# If we get here it means this UNIX platform *does* have
|
||||
# a process with id 0.
|
||||
return True
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError as err:
|
||||
if err.errno == errno.ESRCH:
|
||||
# ESRCH == No such process
|
||||
return False
|
||||
elif err.errno == errno.EPERM:
|
||||
# EPERM clearly means there's a process to deny access to
|
||||
return True
|
||||
else:
|
||||
# According to "man 2 kill" possible error values are
|
||||
# (EINVAL, EPERM, ESRCH) therefore we should never get
|
||||
# here. If we do let's be explicit in considering this
|
||||
# an error.
|
||||
raise err
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
class Command(object):
|
||||
def __init__(self, cmd, timeout=TIMEOUT):
|
||||
super(Command, self).__init__()
|
||||
self.cmd = cmd
|
||||
self.timeout = timeout
|
||||
self.subprocess = None
|
||||
self.blocking = None
|
||||
self.was_run = False
|
||||
self.__out = None
|
||||
self.__err = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<Command {!r}>".format(self.cmd)
|
||||
|
||||
@property
|
||||
def _popen_args(self):
|
||||
return self.cmd
|
||||
|
||||
@property
|
||||
def _default_popen_kwargs(self):
|
||||
return {
|
||||
"env": os.environ.copy(),
|
||||
"stdin": subprocess.PIPE,
|
||||
"stdout": subprocess.PIPE,
|
||||
"stderr": subprocess.PIPE,
|
||||
"shell": True,
|
||||
"universal_newlines": True,
|
||||
"bufsize": 0,
|
||||
}
|
||||
|
||||
@property
|
||||
def _default_pexpect_kwargs(self):
|
||||
encoding = "utf-8"
|
||||
if sys.platform == "win32":
|
||||
default_encoding = locale.getdefaultlocale()[1]
|
||||
if default_encoding is not None:
|
||||
encoding = default_encoding
|
||||
return {"env": os.environ.copy(), "encoding": encoding, "timeout": self.timeout}
|
||||
|
||||
@property
|
||||
def _uses_subprocess(self):
|
||||
return isinstance(self.subprocess, subprocess.Popen)
|
||||
|
||||
@property
|
||||
def _uses_pexpect(self):
|
||||
return isinstance(self.subprocess, PopenSpawn)
|
||||
|
||||
@property
|
||||
def std_out(self):
|
||||
return self.subprocess.stdout
|
||||
|
||||
@property
|
||||
def ok(self):
|
||||
return self.return_code == 0
|
||||
|
||||
@property
|
||||
def _pexpect_out(self):
|
||||
if self.subprocess.encoding:
|
||||
result = ""
|
||||
else:
|
||||
result = b""
|
||||
|
||||
if self.subprocess.before:
|
||||
result += self.subprocess.before
|
||||
|
||||
if self.subprocess.after and self.subprocess.after not in (pexpect.EOF, pexpect.TIMEOUT):
|
||||
try:
|
||||
result += self.subprocess.after
|
||||
except (pexpect.EOF, pexpect.TIMEOUT):
|
||||
pass
|
||||
|
||||
result += self.subprocess.read()
|
||||
return result
|
||||
|
||||
@property
|
||||
def out(self):
|
||||
"""Std/out output (cached)"""
|
||||
if self.__out is not None:
|
||||
return self.__out
|
||||
|
||||
if self._uses_subprocess:
|
||||
self.__out = self.std_out.read()
|
||||
else:
|
||||
self.__out = self._pexpect_out
|
||||
|
||||
return self.__out
|
||||
|
||||
@property
|
||||
def std_err(self):
|
||||
return self.subprocess.stderr
|
||||
|
||||
@property
|
||||
def err(self):
|
||||
"""Std/err output (cached)"""
|
||||
if self.__err is not None:
|
||||
return self.__err
|
||||
|
||||
if self._uses_subprocess:
|
||||
self.__err = self.std_err.read()
|
||||
return self.__err
|
||||
else:
|
||||
return self._pexpect_out
|
||||
|
||||
@property
|
||||
def pid(self):
|
||||
"""The process' PID."""
|
||||
# Support for pexpect's functionality.
|
||||
if hasattr(self.subprocess, "proc"):
|
||||
return self.subprocess.proc.pid
|
||||
# Standard subprocess method.
|
||||
return self.subprocess.pid
|
||||
|
||||
@property
|
||||
def is_alive(self):
|
||||
"""Is the process alive?"""
|
||||
return pid_exists(self.pid)
|
||||
|
||||
@property
|
||||
def return_code(self):
|
||||
# Support for pexpect's functionality.
|
||||
if self._uses_pexpect:
|
||||
return self.subprocess.exitstatus
|
||||
# Standard subprocess method.
|
||||
return self.subprocess.returncode
|
||||
|
||||
@property
|
||||
def std_in(self):
|
||||
return self.subprocess.stdin
|
||||
|
||||
def run(self, block=True, binary=False, cwd=None, env=None):
|
||||
"""Runs the given command, with or without pexpect functionality enabled."""
|
||||
self.blocking = block
|
||||
|
||||
# Use subprocess.
|
||||
if self.blocking:
|
||||
popen_kwargs = self._default_popen_kwargs.copy()
|
||||
del popen_kwargs["stdin"]
|
||||
popen_kwargs["universal_newlines"] = not binary
|
||||
if cwd:
|
||||
popen_kwargs["cwd"] = cwd
|
||||
if env:
|
||||
popen_kwargs["env"].update(env)
|
||||
s = subprocess.Popen(self._popen_args, **popen_kwargs)
|
||||
# Otherwise, use pexpect.
|
||||
else:
|
||||
pexpect_kwargs = self._default_pexpect_kwargs.copy()
|
||||
if binary:
|
||||
pexpect_kwargs["encoding"] = None
|
||||
if cwd:
|
||||
pexpect_kwargs["cwd"] = cwd
|
||||
if env:
|
||||
pexpect_kwargs["env"].update(env)
|
||||
# Enable Python subprocesses to work with expect functionality.
|
||||
pexpect_kwargs["env"]["PYTHONUNBUFFERED"] = "1"
|
||||
s = PopenSpawn(self._popen_args, **pexpect_kwargs)
|
||||
self.subprocess = s
|
||||
self.was_run = True
|
||||
|
||||
def expect(self, pattern, timeout=-1):
|
||||
"""Waits on the given pattern to appear in std_out"""
|
||||
|
||||
if self.blocking:
|
||||
raise RuntimeError("expect can only be used on non-blocking commands.")
|
||||
|
||||
try:
|
||||
self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
except pexpect.EOF:
|
||||
pass
|
||||
|
||||
def send(self, s, end=os.linesep, signal=False):
|
||||
"""Sends the given string or signal to std_in."""
|
||||
|
||||
if self.blocking:
|
||||
raise RuntimeError("send can only be used on non-blocking commands.")
|
||||
|
||||
if not signal:
|
||||
if self._uses_subprocess:
|
||||
return self.subprocess.communicate(s + end)
|
||||
else:
|
||||
return self.subprocess.send(s + end)
|
||||
else:
|
||||
self.subprocess.send_signal(s)
|
||||
|
||||
def terminate(self):
|
||||
self.subprocess.terminate()
|
||||
|
||||
def kill(self):
|
||||
if self._uses_pexpect:
|
||||
self.subprocess.kill(signal.SIGINT)
|
||||
else:
|
||||
self.subprocess.send_signal(signal.SIGINT)
|
||||
|
||||
def block(self):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
# consume stdout and stderr
|
||||
if self.blocking:
|
||||
try:
|
||||
stdout, stderr = self.subprocess.communicate()
|
||||
self.__out = stdout
|
||||
self.__err = stderr
|
||||
except ValueError:
|
||||
pass # Don't read from finished subprocesses.
|
||||
else:
|
||||
self.subprocess.stdin.close()
|
||||
self.std_out.close()
|
||||
self.std_err.close()
|
||||
self.subprocess.wait()
|
||||
else:
|
||||
self.subprocess.sendeof()
|
||||
try:
|
||||
self.subprocess.wait()
|
||||
finally:
|
||||
if self.subprocess.proc.stdout:
|
||||
self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
given process.
|
||||
"""
|
||||
if not timeout:
|
||||
timeout = self.timeout
|
||||
|
||||
if not self.was_run:
|
||||
self.run(block=False, cwd=cwd)
|
||||
|
||||
data = self.out
|
||||
|
||||
if timeout:
|
||||
c = Command(command, timeout)
|
||||
else:
|
||||
c = Command(command)
|
||||
|
||||
c.run(block=False, cwd=cwd)
|
||||
if data:
|
||||
c.send(data)
|
||||
c.block()
|
||||
return c
|
||||
|
||||
|
||||
def _expand_args(command):
|
||||
"""Parses command strings and returns a Popen-ready list."""
|
||||
|
||||
# Prepare arguments.
|
||||
if isinstance(command, STR_TYPES):
|
||||
if sys.version_info[0] == 2:
|
||||
splitter = shlex.shlex(command.encode("utf-8"))
|
||||
elif sys.version_info[0] == 3:
|
||||
splitter = shlex.shlex(command)
|
||||
else:
|
||||
splitter = shlex.shlex(command.encode("utf-8"))
|
||||
splitter.whitespace = "|"
|
||||
splitter.whitespace_split = True
|
||||
command = []
|
||||
|
||||
while True:
|
||||
token = splitter.get_token()
|
||||
if token:
|
||||
command.append(token)
|
||||
else:
|
||||
break
|
||||
|
||||
command = list(map(shlex.split, command))
|
||||
|
||||
return command
|
||||
|
||||
|
||||
def chain(command, timeout=TIMEOUT, cwd=None, env=None):
|
||||
commands = _expand_args(command)
|
||||
data = None
|
||||
|
||||
for command in commands:
|
||||
|
||||
c = run(command, block=False, timeout=timeout, cwd=cwd, env=env)
|
||||
|
||||
if data:
|
||||
c.send(data)
|
||||
c.subprocess.sendeof()
|
||||
|
||||
data = c.out
|
||||
|
||||
return c
|
||||
|
||||
|
||||
def run(command, block=True, binary=False, timeout=TIMEOUT, cwd=None, env=None):
|
||||
c = Command(command, timeout=timeout)
|
||||
c.run(block=block, binary=binary, cwd=cwd, env=env)
|
||||
|
||||
if block:
|
||||
c.block()
|
||||
|
||||
return c
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2018 Kenneth Reitz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
-1
@@ -9,7 +9,6 @@ click-completion==0.5.2
|
||||
click-didyoumean==0.0.3
|
||||
click==8.0.1
|
||||
colorama==0.4.4
|
||||
delegator.py==0.1.1
|
||||
distlib==0.3.2
|
||||
docopt==0.6.2
|
||||
dparse==0.5.1
|
||||
|
||||
@@ -32,11 +32,9 @@ lines_after_imports=2
|
||||
lines_between_types=1
|
||||
multi_line_output=5
|
||||
line_length=80
|
||||
not_skip=__init__.py
|
||||
known_first_party =
|
||||
pipenv
|
||||
tests
|
||||
ignore_trailing_comma=true
|
||||
|
||||
[mypy]
|
||||
ignore_missing_imports=true
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
diff --git a/pipenv/vendor/delegator.py b/pipenv/vendor/delegator.py
|
||||
index d15aeb97..cf6f91c8 100644
|
||||
--- a/pipenv/vendor/delegator.py
|
||||
+++ b/pipenv/vendor/delegator.py
|
||||
@@ -7,6 +7,8 @@ import locale
|
||||
import errno
|
||||
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
+import pexpect
|
||||
+pexpect.EOF.__module__ = "pexpect.exceptions"
|
||||
|
||||
# Include `unicode` in STR_TYPES for Python 2.X
|
||||
try:
|
||||
@@ -110,8 +112,11 @@ class Command(object):
|
||||
if self.subprocess.before:
|
||||
result += self.subprocess.before
|
||||
|
||||
- if self.subprocess.after:
|
||||
- result += self.subprocess.after
|
||||
+ if self.subprocess.after and self.subprocess.after not in (pexpect.EOF, pexpect.TIMEOUT):
|
||||
+ try:
|
||||
+ result += self.subprocess.after
|
||||
+ except (pexpect.EOF, pexpect.TIMEOUT):
|
||||
+ pass
|
||||
|
||||
result += self.subprocess.read()
|
||||
return result
|
||||
@@ -178,6 +183,7 @@ class Command(object):
|
||||
# Use subprocess.
|
||||
if self.blocking:
|
||||
popen_kwargs = self._default_popen_kwargs.copy()
|
||||
+ del popen_kwargs["stdin"]
|
||||
popen_kwargs["universal_newlines"] = not binary
|
||||
if cwd:
|
||||
popen_kwargs["cwd"] = cwd
|
||||
@@ -205,7 +211,10 @@ class Command(object):
|
||||
if self.blocking:
|
||||
raise RuntimeError("expect can only be used on non-blocking commands.")
|
||||
|
||||
- self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ try:
|
||||
+ self.subprocess.expect(pattern=pattern, timeout=timeout)
|
||||
+ except pexpect.EOF:
|
||||
+ pass
|
||||
|
||||
def send(self, s, end=os.linesep, signal=False):
|
||||
"""Sends the given string or signal to std_in."""
|
||||
@@ -234,14 +243,25 @@ class Command(object):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
# consume stdout and stderr
|
||||
- try:
|
||||
- stdout, stderr = self.subprocess.communicate()
|
||||
- self.__out = stdout
|
||||
- self.__err = stderr
|
||||
- except ValueError:
|
||||
- pass # Don't read from finished subprocesses.
|
||||
+ if self.blocking:
|
||||
+ try:
|
||||
+ stdout, stderr = self.subprocess.communicate()
|
||||
+ self.__out = stdout
|
||||
+ self.__err = stderr
|
||||
+ except ValueError:
|
||||
+ pass # Don't read from finished subprocesses.
|
||||
+ else:
|
||||
+ self.subprocess.stdin.close()
|
||||
+ self.std_out.close()
|
||||
+ self.std_err.close()
|
||||
+ self.subprocess.wait()
|
||||
else:
|
||||
- self.subprocess.wait()
|
||||
+ self.subprocess.sendeof()
|
||||
+ try:
|
||||
+ self.subprocess.wait()
|
||||
+ finally:
|
||||
+ if self.subprocess.proc.stdout:
|
||||
+ self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
@@ -263,7 +283,6 @@ class Command(object):
|
||||
c.run(block=False, cwd=cwd)
|
||||
if data:
|
||||
c.send(data)
|
||||
- c.subprocess.sendeof()
|
||||
c.block()
|
||||
return c
|
||||
|
||||
@@ -2,6 +2,7 @@ import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pipenv.utils import subprocess_run
|
||||
import shutil
|
||||
import sys
|
||||
import warnings
|
||||
@@ -13,7 +14,7 @@ import requests
|
||||
|
||||
from pipenv._compat import Path
|
||||
from pipenv.exceptions import VirtualenvActivationException
|
||||
from pipenv.vendor import delegator, toml, tomlkit
|
||||
from pipenv.vendor import toml, tomlkit
|
||||
from pipenv.vendor.vistir.compat import (
|
||||
FileNotFoundError, PermissionError, ResourceWarning, TemporaryDirectory,
|
||||
fs_encode, fs_str
|
||||
@@ -66,8 +67,8 @@ def check_github_ssh():
|
||||
# GitHub does not provide shell access.' if ssh keys are available and
|
||||
# registered with GitHub. Otherwise, the command will fail with
|
||||
# return_code=255 and say 'Permission denied (publickey).'
|
||||
c = delegator.run('ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -T git@github.com', timeout=30)
|
||||
res = True if c.return_code == 1 else False
|
||||
c = subprocess_run('ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -T git@github.com', timeout=30, shell=True)
|
||||
res = True if c.returncode == 1 else False
|
||||
except KeyboardInterrupt:
|
||||
warnings.warn(
|
||||
"KeyboardInterrupt while checking GitHub ssh access", RuntimeWarning
|
||||
@@ -87,11 +88,8 @@ def check_github_ssh():
|
||||
|
||||
|
||||
def check_for_mercurial():
|
||||
c = delegator.run("hg --help")
|
||||
if c.return_code != 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
c = subprocess_run("hg --help", shell=True)
|
||||
return c.returncode == 0
|
||||
|
||||
|
||||
TESTS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -385,8 +383,8 @@ class _PipenvInstance:
|
||||
|
||||
with TemporaryDirectory(prefix='pipenv-', suffix='-cache') as tempdir:
|
||||
os.environ['PIPENV_CACHE_DIR'] = fs_str(tempdir.name)
|
||||
c = delegator.run(
|
||||
f'pipenv {cmd}', block=block,
|
||||
c = subprocess_run(
|
||||
f'pipenv {cmd}', block=block, shell=True,
|
||||
cwd=os.path.abspath(self.path), env=os.environ.copy()
|
||||
)
|
||||
if 'PIPENV_CACHE_DIR' in os.environ:
|
||||
@@ -398,9 +396,9 @@ class _PipenvInstance:
|
||||
# Pretty output for failing tests.
|
||||
if block:
|
||||
print(f'$ pipenv {cmd}')
|
||||
print(c.out)
|
||||
print(c.err, file=sys.stderr)
|
||||
if c.return_code != 0:
|
||||
print(c.stdout)
|
||||
print(c.stderr, file=sys.stderr)
|
||||
if c.returncode != 0:
|
||||
print("Command failed...")
|
||||
|
||||
# Where the action happens.
|
||||
|
||||
@@ -15,18 +15,18 @@ from pipenv.utils import normalize_drive
|
||||
def test_pipenv_where(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("--where")
|
||||
assert c.ok
|
||||
assert normalize_drive(p.path) in c.out
|
||||
assert c.returncode == 0
|
||||
assert normalize_drive(p.path) in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_venv(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--python python')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('--venv')
|
||||
assert c.ok
|
||||
venv_path = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
venv_path = c.stdout.strip()
|
||||
assert os.path.isdir(venv_path)
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ def test_pipenv_venv(PipenvInstance):
|
||||
def test_pipenv_py(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--python python')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('--py')
|
||||
assert c.ok
|
||||
python = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
python = c.stdout.strip()
|
||||
assert os.path.basename(python).startswith('python')
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ def test_pipenv_py(PipenvInstance):
|
||||
def test_pipenv_site_packages(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--python python --site-packages')
|
||||
assert c.return_code == 0
|
||||
assert 'Making site-packages available' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Making site-packages available' in c.stderr
|
||||
|
||||
# no-global-site-packages.txt under stdlib dir should not exist.
|
||||
c = p.pipenv('run python -c "import sysconfig; print(sysconfig.get_path(\'stdlib\'))"')
|
||||
assert c.return_code == 0
|
||||
stdlib_path = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
stdlib_path = c.stdout.strip()
|
||||
assert not os.path.isfile(os.path.join(stdlib_path, 'no-global-site-packages.txt'))
|
||||
|
||||
|
||||
@@ -59,23 +59,23 @@ def test_pipenv_site_packages(PipenvInstance):
|
||||
def test_pipenv_support(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--support')
|
||||
assert c.ok
|
||||
assert c.out
|
||||
assert c.returncode == 0
|
||||
assert c.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_rm(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--python python')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('--venv')
|
||||
assert c.ok
|
||||
venv_path = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
venv_path = c.stdout.strip()
|
||||
assert os.path.isdir(venv_path)
|
||||
|
||||
c = p.pipenv('--rm')
|
||||
assert c.ok
|
||||
assert c.out
|
||||
assert c.returncode == 0
|
||||
assert c.stdout
|
||||
assert not os.path.isdir(venv_path)
|
||||
|
||||
|
||||
@@ -83,30 +83,30 @@ def test_pipenv_rm(PipenvInstance):
|
||||
def test_pipenv_graph(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('install tablib')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
graph = p.pipenv("graph")
|
||||
assert graph.ok
|
||||
assert "tablib" in graph.out
|
||||
assert graph.returncode == 0
|
||||
assert "tablib" in graph.stdout
|
||||
graph_json = p.pipenv("graph --json")
|
||||
assert graph_json.ok
|
||||
assert "tablib" in graph_json.out
|
||||
assert graph_json.returncode == 0
|
||||
assert "tablib" in graph_json.stdout
|
||||
graph_json_tree = p.pipenv("graph --json-tree")
|
||||
assert graph_json_tree.ok
|
||||
assert "tablib" in graph_json_tree.out
|
||||
assert graph_json_tree.returncode == 0
|
||||
assert "tablib" in graph_json_tree.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_graph_reverse(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('install tablib==0.13.0')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('graph --reverse')
|
||||
assert c.ok
|
||||
output = c.out
|
||||
assert c.returncode == 0
|
||||
output = c.stdout
|
||||
|
||||
c = p.pipenv('graph --reverse --json')
|
||||
assert c.return_code == 1
|
||||
assert 'Warning: Using both --reverse and --json together is not supported.' in c.err
|
||||
assert c.returncode == 1
|
||||
assert 'Warning: Using both --reverse and --json together is not supported.' in c.stderr
|
||||
|
||||
requests_dependency = [
|
||||
('backports.csv', 'backports.csv'),
|
||||
@@ -144,15 +144,15 @@ def test_pipenv_check(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
p.pipenv('install requests==1.0.0')
|
||||
c = p.pipenv('check')
|
||||
assert c.return_code != 0
|
||||
assert 'requests' in c.out
|
||||
assert c.returncode != 0
|
||||
assert 'requests' in c.stdout
|
||||
c = p.pipenv('uninstall requests')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('install six')
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('check --ignore 35015')
|
||||
assert c.return_code == 0
|
||||
assert 'Ignoring' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Ignoring' in c.stderr
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
@@ -161,12 +161,12 @@ def test_pipenv_clean_pip_no_warnings(PipenvInstance):
|
||||
with open('setup.py', 'w') as f:
|
||||
f.write('from setuptools import setup; setup(name="empty")')
|
||||
c = p.pipenv('install -e .')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv(f'run pip install -i {p.index_url} pytz')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('clean')
|
||||
assert c.return_code == 0
|
||||
assert c.out, f"{c.out} -- STDERR: {c.err}"
|
||||
assert c.returncode == 0
|
||||
assert c.stdout, f"{c.stdout} -- STDERR: {c.stderr}"
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
@@ -177,22 +177,22 @@ def test_pipenv_clean_pip_warnings(PipenvInstance):
|
||||
# create a fake git repo to trigger a pip freeze warning
|
||||
os.mkdir('.git')
|
||||
c = p.pipenv(f"run pip install -i {p.index_url} -e .")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('clean')
|
||||
assert c.return_code == 0
|
||||
assert c.err
|
||||
assert c.returncode == 0
|
||||
assert c.stderr
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_venv_envs(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
assert p.pipenv('--envs').out
|
||||
assert p.pipenv('--envs').stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_bare_output(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
assert p.pipenv('').out
|
||||
assert p.pipenv('').stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
@@ -205,21 +205,21 @@ pyver = "which python"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('scripts')
|
||||
assert 'pyver' in c.out
|
||||
assert 'which python' in c.out
|
||||
assert 'pyver' in c.stdout
|
||||
assert 'which python' in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_help(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
assert p.pipenv('--help').out
|
||||
assert p.pipenv('--help').stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_man(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--man')
|
||||
assert c.return_code == 0 or c.err
|
||||
assert c.returncode == 0, c.stderr
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
@@ -236,7 +236,7 @@ def test_install_parse_error(PipenvInstance):
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install requests u/\\/p@r\\$34b13+pkg')
|
||||
assert c.return_code != 0
|
||||
assert c.returncode != 0
|
||||
assert 'u/\\/p@r$34b13+pkg' not in p.pipfile['packages']
|
||||
|
||||
|
||||
@@ -259,24 +259,24 @@ import flask
|
||||
assert all(pkg in p.pipfile['packages'] for pkg in ['requests', 'click', 'flask']), p.pipfile["packages"]
|
||||
|
||||
c = p.pipenv('check --unused .')
|
||||
assert 'click' not in c.out
|
||||
assert 'flask' not in c.out
|
||||
assert 'click' not in c.stdout
|
||||
assert 'flask' not in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_clear(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--clear')
|
||||
assert c.return_code == 0
|
||||
assert 'Clearing caches' in c.out
|
||||
assert c.returncode == 0
|
||||
assert 'Clearing caches' in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_three(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('--three')
|
||||
assert c.return_code == 0
|
||||
assert 'Successfully created virtual environment' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Successfully created virtual environment' in c.stderr
|
||||
|
||||
|
||||
@pytest.mark.outdated
|
||||
@@ -289,4 +289,4 @@ sqlalchemy = "<=1.2.3"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('update --pre --outdated')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
@@ -14,8 +14,8 @@ def test_venv_in_project(PipenvInstance):
|
||||
os.environ['PIPENV_VENV_IN_PROJECT'] = '1'
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('install requests')
|
||||
assert c.return_code == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').out
|
||||
assert c.returncode == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
|
||||
|
||||
|
||||
@pytest.mark.dotvenv
|
||||
@@ -24,13 +24,13 @@ def test_venv_at_project_root(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
os.environ['PIPENV_VENV_IN_PROJECT'] = '1'
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').out
|
||||
assert c.returncode == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
|
||||
del os.environ['PIPENV_VENV_IN_PROJECT']
|
||||
os.mkdir('subdir')
|
||||
os.chdir('subdir')
|
||||
# should still detect installed
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').out
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
|
||||
|
||||
|
||||
@pytest.mark.dotvenv
|
||||
@@ -38,8 +38,8 @@ def test_reuse_previous_venv(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
os.mkdir('.venv')
|
||||
c = p.pipenv('install requests')
|
||||
assert c.return_code == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').out
|
||||
assert c.returncode == 0
|
||||
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
|
||||
|
||||
|
||||
@pytest.mark.dotvenv
|
||||
@@ -61,11 +61,11 @@ def test_venv_file(venv_name, PipenvInstance):
|
||||
del os.environ['PIPENV_VENV_IN_PROJECT']
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('--venv')
|
||||
assert c.return_code == 0
|
||||
venv_loc = Path(c.out.strip()).absolute()
|
||||
assert c.returncode == 0
|
||||
venv_loc = Path(c.stdout.strip()).absolute()
|
||||
assert venv_loc.exists()
|
||||
assert venv_loc.joinpath('.project').exists()
|
||||
venv_path = normalize_drive(venv_loc.as_posix())
|
||||
@@ -93,10 +93,10 @@ def test_venv_file_with_path(PipenvInstance):
|
||||
f.write(venv_path.name)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('--venv')
|
||||
assert c.return_code == 0
|
||||
venv_loc = Path(c.out.strip())
|
||||
assert c.returncode == 0
|
||||
venv_loc = Path(c.stdout.strip())
|
||||
|
||||
assert venv_loc.joinpath('.project').exists()
|
||||
assert venv_loc == Path(venv_path.name)
|
||||
|
||||
@@ -5,8 +5,7 @@ import pytest
|
||||
from flaky import flaky
|
||||
|
||||
from pipenv._compat import Path, TemporaryDirectory
|
||||
from pipenv.utils import temp_environ
|
||||
from pipenv.vendor import delegator
|
||||
from pipenv.utils import subprocess_run, temp_environ
|
||||
|
||||
|
||||
@pytest.mark.setup
|
||||
@@ -16,7 +15,7 @@ def test_basic_setup(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
with PipenvInstance(pipfile=False) as p:
|
||||
c = p.pipenv("install requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
assert "requests" in p.lockfile["default"]
|
||||
@@ -33,7 +32,7 @@ def test_basic_setup(PipenvInstance):
|
||||
def test_basic_install(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "chardet" in p.lockfile["default"]
|
||||
@@ -54,7 +53,7 @@ def test_mirror_install(PipenvInstance):
|
||||
# This should sufficiently demonstrate the mirror functionality
|
||||
# since pypi.org is the default when PIPENV_TEST_INDEX is unset.
|
||||
c = p.pipenv(f"install requests --pypi-mirror {mirror_url}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
# Ensure the --pypi-mirror parameter hasn't altered the Pipfile or Pipfile.lock sources
|
||||
assert len(p.pipfile["source"]) == 1
|
||||
assert len(p.lockfile["_meta"]["sources"]) == 1
|
||||
@@ -78,7 +77,7 @@ def test_bad_mirror_install(PipenvInstance):
|
||||
# This demonstrates that the mirror parameter is being used
|
||||
os.environ.pop("PIPENV_TEST_INDEX", None)
|
||||
c = p.pipenv("install requests --pypi-mirror https://pypi.example.org")
|
||||
assert c.return_code != 0
|
||||
assert c.returncode != 0
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -87,7 +86,7 @@ def test_bad_mirror_install(PipenvInstance):
|
||||
def test_complex_lock(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install apscheduler")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "apscheduler" in p.pipfile["packages"]
|
||||
assert "funcsigs" in p.lockfile["default"]
|
||||
assert "futures" in p.lockfile["default"]
|
||||
@@ -99,7 +98,7 @@ def test_complex_lock(PipenvInstance):
|
||||
def test_basic_dev_install(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install requests --dev")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["dev-packages"]
|
||||
assert "requests" in p.lockfile["develop"]
|
||||
assert "chardet" in p.lockfile["develop"]
|
||||
@@ -108,7 +107,7 @@ def test_basic_dev_install(PipenvInstance):
|
||||
assert "certifi" in p.lockfile["develop"]
|
||||
|
||||
c = p.pipenv("run python -m requests.help")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -128,15 +127,15 @@ tablib = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "tablib" in p.pipfile["dev-packages"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert "tablib" in p.lockfile["develop"]
|
||||
c = p.pipenv('run python -c "import tablib"')
|
||||
assert c.return_code != 0
|
||||
assert c.returncode != 0
|
||||
c = p.pipenv('run python -c "import six"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -151,13 +150,13 @@ six = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert p.pipfile.get("dev-packages", {}) == {}
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert p.lockfile["develop"] == {}
|
||||
c = p.pipenv('run python -c "import six"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -167,7 +166,7 @@ six = "*"
|
||||
def test_extras_install(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install requests[socks]")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
assert "extras" in p.pipfile["packages"]["requests"]
|
||||
|
||||
@@ -191,7 +190,7 @@ requests = "==2.19.1"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
assert "requests" in p.lockfile["default"]
|
||||
|
||||
@@ -211,7 +210,7 @@ def test_backup_resolver(PipenvInstance):
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "ibm-db-sa-py3" in p.lockfile["default"]
|
||||
|
||||
|
||||
@@ -228,7 +227,7 @@ requests = {version = "*"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "idna" in p.lockfile["default"]
|
||||
@@ -237,7 +236,7 @@ requests = {version = "*"}
|
||||
assert "chardet" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import requests; import idna; import certifi;"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -253,7 +252,7 @@ version = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "idna" in p.lockfile["default"]
|
||||
@@ -262,7 +261,7 @@ version = "*"
|
||||
assert "chardet" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import requests; import idna; import certifi;"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.bad
|
||||
@@ -271,7 +270,7 @@ version = "*"
|
||||
def test_bad_packages(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install NotAPackage")
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -287,10 +286,10 @@ def test_requirements_to_pipfile(PipenvInstance, pypi):
|
||||
f.write(f"-i {pypi.url}\nrequests[socks]==2.19.1\n")
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
print(c.out)
|
||||
print(c.err)
|
||||
print(delegator.run("ls -l").out)
|
||||
assert c.returncode == 0
|
||||
print(c.stdout)
|
||||
print(c.stderr)
|
||||
print(subprocess_run(["ls", "-l"]).stdout)
|
||||
|
||||
# assert stuff in pipfile
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
@@ -318,7 +317,7 @@ def test_skip_requirements_when_pipfile(PipenvInstance):
|
||||
with open("requirements.txt", "w") as f:
|
||||
f.write("requests==2.18.1\n")
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
with open(p.pipfile_path, "w") as f:
|
||||
contents = """
|
||||
[packages]
|
||||
@@ -327,7 +326,7 @@ fake_package = "<0.12"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert "fake_package" in p.pipfile["packages"]
|
||||
assert "fake-package" in p.lockfile["default"]
|
||||
assert "six" in p.pipfile["packages"]
|
||||
@@ -341,7 +340,7 @@ fake_package = "<0.12"
|
||||
def test_clean_on_empty_venv(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("clean")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.basic
|
||||
@@ -365,13 +364,13 @@ name = 'mockpi'
|
||||
|
||||
# Ensure simple install does not extrapolate.
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.pipfile["source"][0]["url"] == "${PYPI_URL}/simple"
|
||||
assert p.lockfile["_meta"]["sources"][0]["url"] == "${PYPI_URL}/simple"
|
||||
|
||||
# Ensure package install does not extrapolate.
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.pipfile["source"][0]["url"] == "${PYPI_URL}/simple"
|
||||
assert p.lockfile["_meta"]["sources"][0]["url"] == "${PYPI_URL}/simple"
|
||||
|
||||
@@ -383,8 +382,8 @@ name = 'mockpi'
|
||||
def test_editable_no_args(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install -e")
|
||||
assert c.return_code != 0
|
||||
assert "Error: Option '-e' requires an argument" in c.err
|
||||
assert c.returncode != 0
|
||||
assert "Error: Option '-e' requires an argument" in c.stderr
|
||||
|
||||
|
||||
@pytest.mark.basic
|
||||
@@ -402,10 +401,10 @@ def test_install_venv_project_directory(PipenvInstance):
|
||||
del os.environ["PIPENV_VENV_IN_PROJECT"]
|
||||
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
venv_loc = None
|
||||
for line in c.err.splitlines():
|
||||
for line in c.stderr.splitlines():
|
||||
if line.startswith("Virtualenv location:"):
|
||||
venv_loc = Path(line.split(":", 1)[-1].strip())
|
||||
assert venv_loc is not None
|
||||
@@ -418,15 +417,15 @@ def test_install_venv_project_directory(PipenvInstance):
|
||||
def test_system_and_deploy_work(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install tablib")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("--rm")
|
||||
assert c.return_code == 0
|
||||
c = delegator.run("virtualenv .venv")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = subprocess_run(["virtualenv", ".venv"])
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("install --system --deploy")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("--rm")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
Path(p.pipfile_path).write_text(
|
||||
"""
|
||||
[packages]
|
||||
@@ -434,7 +433,7 @@ tablib = "*"
|
||||
""".strip()
|
||||
)
|
||||
c = p.pipenv("install --system")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.basic
|
||||
@@ -447,7 +446,7 @@ def test_install_creates_pipfile(PipenvInstance):
|
||||
del os.environ["PIPENV_PIPFILE"]
|
||||
assert not os.path.isfile(p.pipfile_path)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert os.path.isfile(p.pipfile_path)
|
||||
|
||||
|
||||
@@ -456,7 +455,7 @@ def test_install_creates_pipfile(PipenvInstance):
|
||||
def test_install_non_exist_dep(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install dateutil")
|
||||
assert not c.ok
|
||||
assert c.returncode
|
||||
assert "dateutil" not in p.pipfile["packages"]
|
||||
|
||||
|
||||
@@ -465,7 +464,7 @@ def test_install_non_exist_dep(PipenvInstance):
|
||||
def test_install_package_with_dots(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install backports.html")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert "backports.html" in p.pipfile["packages"]
|
||||
|
||||
|
||||
@@ -484,7 +483,7 @@ extras = ["socks"]
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install flask")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
with open(p.pipfile_path) as f:
|
||||
contents = f.read()
|
||||
assert "[packages.requests]" not in contents
|
||||
|
||||
@@ -23,12 +23,12 @@ fake_package = {version = "*", markers="os_name=='splashwear'"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert 'Ignoring' in c.out
|
||||
assert c.returncode == 0
|
||||
assert 'Ignoring' in c.stdout
|
||||
assert 'markers' in p.lockfile['default']['fake-package'], p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import fake_package;"')
|
||||
assert c.return_code == 1
|
||||
assert c.returncode == 1
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -46,7 +46,7 @@ depends-on-marked-package = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# depends-on-marked-package has an install_requires of
|
||||
# 'pytz; platform_python_implementation=="CPython"'
|
||||
@@ -71,13 +71,13 @@ fake-package = {version = "*", os_name = "== 'splashwear'"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert 'Ignoring' in c.out
|
||||
assert 'Ignoring' in c.stdout
|
||||
assert 'markers' in p.lockfile['default']['fake-package']
|
||||
|
||||
c = p.pipenv('run python -c "import fake_package;"')
|
||||
assert c.return_code == 1
|
||||
assert c.returncode == 1
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -95,7 +95,7 @@ funcsigs = {version = "*", os_name = "== 'splashwear'"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "markers" in p.lockfile['default']['funcsigs'], p.lockfile['default']['funcsigs']
|
||||
assert p.lockfile['default']['funcsigs']['markers'] == "os_name == 'splashwear'", p.lockfile['default']['funcsigs']
|
||||
|
||||
@@ -120,7 +120,7 @@ funcsigs = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert p.lockfile['default']['funcsigs'].get('markers', '') == ''
|
||||
|
||||
@@ -140,9 +140,9 @@ def test_resolver_unique_markers(PipenvInstance):
|
||||
"""
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('install vcrpy==2.0.1')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'yarl' in p.lockfile['default']
|
||||
yarl = p.lockfile['default']['yarl']
|
||||
assert 'markers' in yarl
|
||||
@@ -177,14 +177,14 @@ six = "*"
|
||||
assert project.get_lockfile_hash() is None
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lock_hash = project.get_lockfile_hash()
|
||||
assert lock_hash is not None
|
||||
assert lock_hash == project.calculate_pipfile_hash()
|
||||
|
||||
# sanity check on pytest
|
||||
assert 'PYPI_USERNAME' not in str(pipfile.load(p.pipfile_path))
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert project.get_lockfile_hash() == project.calculate_pipfile_hash()
|
||||
|
||||
os.environ['PYPI_PASSWORD'] = 'pass2'
|
||||
|
||||
@@ -8,7 +8,6 @@ from flaky import flaky
|
||||
|
||||
from pipenv._compat import Path
|
||||
from pipenv.utils import mkdir_p, temp_environ
|
||||
from pipenv.vendor import delegator
|
||||
|
||||
|
||||
@pytest.mark.extras
|
||||
@@ -46,15 +45,15 @@ testpipenv = {path = ".", editable = true, extras = ["dev"]}
|
||||
""".strip())
|
||||
# project.write_toml({"packages": pipfile, "dev-packages": {}})
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "testpipenv" in p.lockfile["default"]
|
||||
assert p.lockfile["default"]["testpipenv"]["extras"] == ["dev"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
c = p.pipenv("uninstall --all")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
print(f"Current directory: {os.getcwd()}", file=sys.stderr)
|
||||
c = p.pipenv(f"install {line}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "testpipenv" in p.pipfile["packages"]
|
||||
assert p.pipfile["packages"]["testpipenv"]["path"] == "."
|
||||
assert p.pipfile["packages"]["testpipenv"]["extras"] == ["dev"]
|
||||
@@ -93,7 +92,7 @@ setup(
|
||||
def helper_dependency_links_install_test(pipenv_instance, deplink):
|
||||
TestDirectDependencies.helper_dependency_links_install_make_setup(pipenv_instance, deplink)
|
||||
c = pipenv_instance.pipenv("install -v -e .")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "test-private-dependency" in pipenv_instance.lockfile["default"]
|
||||
|
||||
def test_https_dependency_links_install(self, PipenvInstance):
|
||||
@@ -126,7 +125,7 @@ def test_e_dot(PipenvInstance, pip_src_dir):
|
||||
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
c = p.pipenv(f"install -e '{path}' --dev")
|
||||
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
key = [k for k in p.pipfile["dev-packages"].keys()][0]
|
||||
assert "path" in p.pipfile["dev-packages"][key]
|
||||
@@ -150,14 +149,14 @@ urllib3 = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "pytz" in p.lockfile["default"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import six; import pytz; import urllib3;"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@@ -176,14 +175,14 @@ pytz = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install --sequential")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert "pytz" in p.lockfile["default"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import six; import urllib3; import pytz;"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.run
|
||||
@@ -199,17 +198,17 @@ Requests = "==2.14.0" # Inline comment
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("install requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" not in p.pipfile["packages"]
|
||||
assert p.pipfile["packages"]["Requests"] == "==2.14.0"
|
||||
c = p.pipenv("install requests==2.18.4")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.pipfile["packages"]["Requests"] == "==2.18.4"
|
||||
c = p.pipenv("install python_DateUtil")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "python-dateutil" in p.pipfile["packages"]
|
||||
with open(p.pipfile_path) as f:
|
||||
contents = f.read()
|
||||
@@ -238,7 +237,7 @@ def test_local_package(PipenvInstance, pip_src_dir, testsroot):
|
||||
with tarfile.open(copy_to, "r:gz") as tgz:
|
||||
tgz.extractall(path=p.path)
|
||||
c = p.pipenv(f"install -e {package}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert all(
|
||||
pkg in p.lockfile["default"]
|
||||
for pkg in ["urllib3", "idna", "certifi", "chardet"]
|
||||
@@ -258,12 +257,12 @@ def test_local_zipfiles(PipenvInstance, testsroot):
|
||||
shutil.copy(source_path, os.path.join(p.path, file_name))
|
||||
|
||||
c = p.pipenv(f"install {file_name}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
key = [k for k in p.pipfile["packages"].keys()][0]
|
||||
dep = p.pipfile["packages"][key]
|
||||
|
||||
assert "file" in dep or "path" in dep
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# This now gets resolved to its name correctly
|
||||
dep = p.lockfile["default"]["requests"]
|
||||
@@ -285,13 +284,13 @@ def test_relative_paths(PipenvInstance, testsroot):
|
||||
shutil.copy(source_path, os.path.join(artifact_path, file_name))
|
||||
# Test installing a relative path in a subdirectory
|
||||
c = p.pipenv(f"install {artifact_dir}/{file_name}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
key = next(k for k in p.pipfile["packages"].keys())
|
||||
dep = p.pipfile["packages"][key]
|
||||
|
||||
assert "path" in dep
|
||||
assert Path(".", artifact_dir, file_name) == Path(dep["path"])
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@@ -305,7 +304,7 @@ def test_install_local_file_collision(PipenvInstance):
|
||||
with open(fake_file, "w") as f:
|
||||
f.write("")
|
||||
c = p.pipenv(f"install {target_package}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert target_package in p.pipfile["packages"]
|
||||
assert p.pipfile["packages"][target_package] == "*"
|
||||
assert target_package in p.lockfile["default"]
|
||||
@@ -331,7 +330,7 @@ six = {{path = "./artifacts/{}"}}
|
||||
)
|
||||
f.write(contents.strip())
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.lockfile["default"]
|
||||
|
||||
|
||||
@@ -366,10 +365,10 @@ def test_multiple_editable_packages_should_not_race(PipenvInstance, testsroot):
|
||||
f.write(pipfile_string.strip())
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('run python -c "import requests, flask, six, jinja2"')
|
||||
assert c.return_code == 0, c.err
|
||||
assert c.returncode == 0, c.stderr
|
||||
|
||||
|
||||
@pytest.mark.outdated
|
||||
@@ -377,11 +376,11 @@ def test_multiple_editable_packages_should_not_race(PipenvInstance, testsroot):
|
||||
def test_outdated_should_compare_postreleases_without_failing(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install ibm-db-sa-py3==0.3.0")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("update --outdated")
|
||||
assert c.return_code == 0
|
||||
assert "Skipped Update" in c.err
|
||||
assert c.returncode == 0
|
||||
assert "Skipped Update" in c.stderr
|
||||
p._pipfile.update("ibm-db-sa-py3", "*")
|
||||
c = p.pipenv("update --outdated")
|
||||
assert c.return_code != 0
|
||||
assert "out-of-date" in c.out
|
||||
assert c.returncode != 0
|
||||
assert "out-of-date" in c.stdout
|
||||
|
||||
@@ -5,9 +5,8 @@ import pytest
|
||||
|
||||
from flaky import flaky
|
||||
|
||||
import delegator
|
||||
|
||||
from pipenv._compat import Path
|
||||
from pipenv.utils import subprocess_run
|
||||
|
||||
|
||||
@flaky
|
||||
@@ -17,10 +16,10 @@ from pipenv._compat import Path
|
||||
def test_basic_vcs_install(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install git+https://github.com/benjaminp/six.git@1.11.0#egg=six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
# edge case where normal package starts with VCS name shouldn't be flagged as vcs
|
||||
c = p.pipenv("install gitdb2")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert all(package in p.pipfile["packages"] for package in ["six", "gitdb2"])
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
@@ -37,7 +36,7 @@ def test_basic_vcs_install(PipenvInstance):
|
||||
def test_git_vcs_install(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install git+git://github.com/benjaminp/six.git@1.11.0#egg=six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
@@ -55,7 +54,7 @@ def test_git_vcs_install_with_env_var(PipenvInstance):
|
||||
p._pipfile.add("six", {"git": "git://${GIT_HOST}/benjaminp/six.git", "ref": "1.11.0"})
|
||||
os.environ["GIT_HOST"] = "github.com"
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
@@ -72,7 +71,7 @@ def test_git_vcs_install_with_env_var(PipenvInstance):
|
||||
def test_ssh_vcs_install(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install git+ssh://git@github.com/benjaminp/six.git@1.11.0#egg=six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
@@ -92,7 +91,7 @@ def test_urls_work(PipenvInstance):
|
||||
c = p.pipenv(
|
||||
"install {0}".format(path)
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
dep = list(p.pipfile["packages"].values())[0]
|
||||
assert "file" in dep, p.pipfile
|
||||
@@ -115,7 +114,7 @@ def test_file_urls_work(PipenvInstance, pip_src_dir):
|
||||
whl = whl.absolute()
|
||||
wheel_url = whl.as_uri()
|
||||
c = p.pipenv('install "{0}"'.format(wheel_url))
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "file" in p.pipfile["packages"]["six"]
|
||||
|
||||
@@ -127,13 +126,13 @@ def test_local_vcs_urls_work(PipenvInstance, tmpdir):
|
||||
six_dir = tmpdir.join("six")
|
||||
six_path = Path(six_dir.strpath)
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = delegator.run(
|
||||
"git clone https://github.com/benjaminp/six.git {0}".format(six_dir.strpath)
|
||||
c = subprocess_run(
|
||||
["git", "clone", "https://github.com/benjaminp/six.git", six_dir.strpath]
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("install git+{0}#egg=six".format(six_path.as_uri()))
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
|
||||
|
||||
@@ -147,7 +146,7 @@ def test_editable_vcs_install(PipenvInstance_NoPyPI):
|
||||
c = p.pipenv(
|
||||
"install -e git+https://github.com/kennethreitz/requests.git#egg=requests"
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["requests"]
|
||||
assert "editable" in p.pipfile["packages"]["requests"]
|
||||
@@ -169,7 +168,7 @@ def test_install_editable_git_tag(PipenvInstance_NoPyPI):
|
||||
c = p.pipenv(
|
||||
"install -e git+https://github.com/benjaminp/six.git@1.11.0#egg=six"
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert "git" in p.lockfile["default"]["six"]
|
||||
@@ -205,7 +204,7 @@ six = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv("install pipenv-test-private-package --index testpypi")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@@ -216,10 +215,10 @@ def test_install_local_vcs_not_in_lockfile(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
# six_path = os.path.join(p.path, "six")
|
||||
six_path = p._pipfile.get_fixture_path("git/six/").as_posix()
|
||||
c = delegator.run("git clone {0} ./six".format(six_path))
|
||||
assert c.return_code == 0
|
||||
c = p.pipenv("install -e ./six".format(six_path))
|
||||
assert c.return_code == 0
|
||||
c = subprocess_run(["git", "clone", six_path, "./six"])
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("install -e ./six")
|
||||
assert c.returncode == 0
|
||||
six_key = list(p.pipfile["packages"].keys())[0]
|
||||
# we don't need the rest of the test anymore, this just works on its own
|
||||
assert six_key == "six"
|
||||
@@ -234,7 +233,7 @@ def test_get_vcs_refs(PipenvInstance_NoPyPI):
|
||||
c = p.pipenv(
|
||||
"install -e git+https://github.com/benjaminp/six.git@1.9.0#egg=six"
|
||||
)
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert (
|
||||
@@ -245,7 +244,7 @@ def test_get_vcs_refs(PipenvInstance_NoPyPI):
|
||||
new_content = pipfile.read_text().replace(u"1.9.0", u"1.11.0")
|
||||
pipfile.write_text(new_content)
|
||||
c = p.pipenv("lock")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert (
|
||||
p.lockfile["default"]["six"]["ref"]
|
||||
== "15e31431af97e5e64b80af0a3f598d382bcdd49a"
|
||||
@@ -280,7 +279,7 @@ Jinja2 = {{ref = "2.11.0", git = "{0}"}}
|
||||
""".format(jinja2_uri).strip()
|
||||
)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
installed_packages = ["Flask", "Jinja2"]
|
||||
assert all([k in p.pipfile["packages"] for k in installed_packages])
|
||||
assert all([k.lower() in p.lockfile["default"] for k in installed_packages])
|
||||
@@ -302,6 +301,6 @@ def test_vcs_can_use_markers(PipenvInstance):
|
||||
p._pipfile.install("six", {"git": "{0}".format(path.as_uri()), "markers": "sys_platform == 'linux'"})
|
||||
assert "six" in p.pipfile["packages"]
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.lockfile["default"]
|
||||
assert "git" in p.lockfile["default"]["six"]
|
||||
|
||||
@@ -22,7 +22,7 @@ def test_lock_handle_eggs(PipenvInstance):
|
||||
RandomWords = "*"
|
||||
""")
|
||||
c = p.pipenv('lock --verbose')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'randomwords' in p.lockfile['default']
|
||||
assert p.lockfile['default']['randomwords']['version'] == '==0.2.1'
|
||||
|
||||
@@ -47,14 +47,14 @@ flask = "==0.12.2"
|
||||
|
||||
c = p.pipenv('lock -r')
|
||||
d = p.pipenv('lock -r -d')
|
||||
assert c.return_code == 0
|
||||
assert d.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert d.returncode == 0
|
||||
|
||||
for req in req_list:
|
||||
assert req in c.out
|
||||
assert req in c.stdout
|
||||
|
||||
for req in dev_req_list:
|
||||
assert req in d.out
|
||||
assert req in d.stdout
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -71,7 +71,7 @@ PyTest = "==3.1.0"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lock = p.lockfile
|
||||
assert 'requests' in lock['default']
|
||||
assert lock['default']['requests']['version'] == "==2.14.0"
|
||||
@@ -87,7 +87,7 @@ PyTest = "*"
|
||||
f.write(updated_contents)
|
||||
|
||||
c = p.pipenv('lock --keep-outdated')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lock = p.lockfile
|
||||
assert 'requests' in lock['default']
|
||||
assert lock['default']['requests']['version'] == "==2.18.4"
|
||||
@@ -102,8 +102,8 @@ def test_keep_outdated_doesnt_remove_lockfile_entries(PipenvInstance):
|
||||
p._pipfile.add("requests", "==2.18.4")
|
||||
p._pipfile.add("colorama", {"version": "*", "markers": "os_name=='FakeOS'"})
|
||||
c = p.pipenv("install")
|
||||
assert c.ok
|
||||
assert "doesn't match your environment, its dependencies won't be resolved." in c.err
|
||||
assert c.returncode == 0
|
||||
assert "doesn't match your environment, its dependencies won't be resolved." in c.stderr
|
||||
p._pipfile.add("six", "*")
|
||||
p.pipenv("lock --keep-outdated")
|
||||
assert "colorama" in p.lockfile["default"]
|
||||
@@ -115,11 +115,11 @@ def test_resolve_skip_unmatched_requirements(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
p._pipfile.add("missing-package", {"markers": "os_name=='FakeOS'"})
|
||||
c = p.pipenv("lock")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert (
|
||||
"Could not find a version of missing-package; "
|
||||
"os_name == 'FakeOS' that matches your environment"
|
||||
) in c.err
|
||||
) in c.stderr
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -128,10 +128,10 @@ def test_keep_outdated_doesnt_upgrade_pipfile_pins(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
p._pipfile.add("urllib3", "==1.21.1")
|
||||
c = p.pipenv("install")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
p._pipfile.add("requests", "==2.18.4")
|
||||
c = p.pipenv("lock --keep-outdated")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
assert p.lockfile["default"]["requests"]["version"] == "==2.18.4"
|
||||
@@ -142,7 +142,7 @@ def test_keep_outdated_doesnt_upgrade_pipfile_pins(PipenvInstance):
|
||||
def test_keep_outdated_keeps_markers_not_removed(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install six click")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
lockfile = Path(p.lockfile_path)
|
||||
lockfile_content = lockfile.read_text()
|
||||
lockfile_json = json.loads(lockfile_content)
|
||||
@@ -150,7 +150,7 @@ def test_keep_outdated_keeps_markers_not_removed(PipenvInstance):
|
||||
lockfile_json["default"]["six"]["markers"] = "python_version >= '2.7'"
|
||||
lockfile.write_text(to_text(json.dumps(lockfile_json)))
|
||||
c = p.pipenv("lock --keep-outdated")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile["default"]["six"].get("markers", "") == "python_version >= '2.7'"
|
||||
|
||||
|
||||
@@ -160,17 +160,17 @@ def test_keep_outdated_doesnt_update_satisfied_constraints(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
p._pipfile.add("requests", "==2.18.4")
|
||||
c = p.pipenv("install")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
p._pipfile.add("requests", "*")
|
||||
assert p.pipfile["packages"]["requests"] == "*"
|
||||
c = p.pipenv("lock --keep-outdated")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
# ensure this didn't update requests
|
||||
assert p.lockfile["default"]["requests"]["version"] == "==2.18.4"
|
||||
c = p.pipenv("lock")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile["default"]["requests"]["version"] != "==2.18.4"
|
||||
|
||||
|
||||
@@ -192,16 +192,16 @@ requests = {git = "https://github.com/psf/requests.git"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lock = p.lockfile
|
||||
assert 'requests' in lock['develop']
|
||||
assert 'click' in lock['default']
|
||||
|
||||
c = p.pipenv('run pip install -e git+https://github.com/dateutil/dateutil#egg=python_dateutil')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lock = p.lockfile
|
||||
assert 'requests' in lock['develop']
|
||||
assert 'click' in lock['default']
|
||||
@@ -225,7 +225,7 @@ allow_prereleases = true
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['default']['sqlalchemy']['version'] == '==1.2.0b3'
|
||||
|
||||
|
||||
@@ -245,10 +245,10 @@ maya = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock --verbose')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -263,14 +263,14 @@ requests = {version = "*", extras = ["socks"]}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "pysocks" in p.lockfile["default"]
|
||||
assert "markers" not in p.lockfile["default"]['pysocks']
|
||||
|
||||
c = p.pipenv('lock -r')
|
||||
assert c.return_code == 0
|
||||
assert "extra == 'socks'" not in c.out.strip()
|
||||
assert c.returncode == 0
|
||||
assert "extra == 'socks'" not in c.stdout.strip()
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -291,9 +291,9 @@ records = {extras = ["pandas"], version = "==0.5.2"}
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'tablib' in p.lockfile['default']
|
||||
assert 'pandas' in p.lockfile['default']
|
||||
|
||||
@@ -322,7 +322,7 @@ requests = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install --skip-lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -351,11 +351,11 @@ requests = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('lock -r')
|
||||
assert c.return_code == 0
|
||||
assert '-i https://pypi.org/simple' in c.out.strip()
|
||||
assert '--extra-index-url https://test.pypi.org/simple' in c.out.strip()
|
||||
assert c.returncode == 0
|
||||
assert '-i https://pypi.org/simple' in c.stdout.strip()
|
||||
assert '--extra-index-url https://test.pypi.org/simple' in c.stdout.strip()
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -388,12 +388,12 @@ fake-package = "*"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv(f'install --pypi-mirror {mirror_url}')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv(f'lock -r --pypi-mirror {mirror_url}')
|
||||
assert c.return_code == 0
|
||||
assert f'-i {mirror_url}' in c.out.strip()
|
||||
assert '--extra-index-url https://test.pypi.org/simple' in c.out.strip()
|
||||
assert f'--extra-index-url {mirror_url}' not in c.out.strip()
|
||||
assert c.returncode == 0
|
||||
assert f'-i {mirror_url}' in c.stdout.strip()
|
||||
assert '--extra-index-url https://test.pypi.org/simple' in c.stdout.strip()
|
||||
assert f'--extra-index-url {mirror_url}' not in c.stdout.strip()
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -415,12 +415,12 @@ def test_outdated_setuptools_with_pep517_legacy_build_meta_is_updated(PipenvInst
|
||||
"""
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('run pip install "setuptools<=40.2"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("run python -c 'import setuptools; print(setuptools.__version__)'")
|
||||
assert c.return_code == 0
|
||||
assert c.out.strip() == "40.2.0"
|
||||
assert c.returncode == 0
|
||||
assert c.stdout.strip() == "40.2.0"
|
||||
c = p.pipenv("install legacy-backend-package")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "vistir" in p.lockfile["default"]
|
||||
|
||||
|
||||
@@ -438,12 +438,12 @@ def test_outdated_setuptools_with_pep517_cython_import_in_setuppy(PipenvInstance
|
||||
"""
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('run pip install "setuptools<=40.2"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("run python -c 'import setuptools; print(setuptools.__version__)'")
|
||||
assert c.return_code == 0
|
||||
assert c.out.strip() == "40.2.0"
|
||||
assert c.returncode == 0
|
||||
assert c.stdout.strip() == "40.2.0"
|
||||
c = p.pipenv("install cython-import-package")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "vistir" in p.lockfile["default"]
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ requests = "==2.14.0"
|
||||
with temp_environ():
|
||||
os.environ['MY_ENV_VAR'] = 'simple'
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'requests' in p.lockfile['default']
|
||||
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
@@ -479,7 +479,7 @@ requests = "==2.14.0"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'requests' in p.lockfile['default']
|
||||
|
||||
|
||||
@@ -494,12 +494,12 @@ def test_lock_editable_vcs_without_install(PipenvInstance):
|
||||
requests = {git = "https://github.com/psf/requests.git", ref = "master", editable = true}
|
||||
""".strip())
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'requests' in p.lockfile['default']
|
||||
assert 'idna' in p.lockfile['default']
|
||||
assert 'certifi' in p.lockfile['default']
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@@ -513,11 +513,11 @@ def test_lock_editable_vcs_with_ref_in_git(PipenvInstance):
|
||||
requests = {git = "https://github.com/psf/requests.git@883caaf", editable = true}
|
||||
""".strip())
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['default']['requests']['git'] == 'https://github.com/psf/requests.git'
|
||||
assert p.lockfile['default']['requests']['ref'] == '883caaf145fbe93bd0d208a6b864de9146087312'
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@@ -531,11 +531,11 @@ def test_lock_editable_vcs_with_ref(PipenvInstance):
|
||||
requests = {git = "https://github.com/psf/requests.git", ref = "883caaf", editable = true}
|
||||
""".strip())
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['default']['requests']['git'] == 'https://github.com/psf/requests.git'
|
||||
assert p.lockfile['default']['requests']['ref'] == '883caaf145fbe93bd0d208a6b864de9146087312'
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@@ -550,13 +550,13 @@ def test_lock_editable_vcs_with_extras_without_install(PipenvInstance):
|
||||
requests = {git = "https://github.com/psf/requests.git", editable = true, extras = ["socks"]}
|
||||
""".strip())
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'requests' in p.lockfile['default']
|
||||
assert 'idna' in p.lockfile['default']
|
||||
assert 'certifi' in p.lockfile['default']
|
||||
assert "socks" in p.lockfile["default"]["requests"]["extras"]
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.lockfile["default"]
|
||||
# For backward compatibility we want to make sure not to include the 'version' key
|
||||
assert "version" not in p.lockfile["default"]["requests"]
|
||||
@@ -573,12 +573,12 @@ def test_lock_editable_vcs_with_markers_without_install(PipenvInstance):
|
||||
requests = {git = "https://github.com/psf/requests.git", ref = "master", editable = true, markers = "python_version >= '2.6'"}
|
||||
""".strip())
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert 'requests' in p.lockfile['default']
|
||||
assert 'idna' in p.lockfile['default']
|
||||
assert 'certifi' in p.lockfile['default']
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -591,10 +591,10 @@ def test_lock_respecting_python_version(PipenvInstance):
|
||||
django = "*"
|
||||
""".strip())
|
||||
c = p.pipenv('install ')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('run python --version')
|
||||
assert c.return_code == 0
|
||||
py_version = c.err.splitlines()[-1].strip().split()[-1]
|
||||
assert c.returncode == 0
|
||||
py_version = c.stderr.splitlines()[-1].strip().split()[-1]
|
||||
django_version = '==2.0.6' if py_version.startswith('3') else '==1.11.13'
|
||||
assert py_version == '2.7.14'
|
||||
assert p.lockfile['default']['django']['version'] == django_version
|
||||
@@ -607,8 +607,8 @@ def test_lockfile_corrupted(PipenvInstance):
|
||||
with open(p.lockfile_path, 'w') as f:
|
||||
f.write('{corrupted}')
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert 'Pipfile.lock is corrupted' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Pipfile.lock is corrupted' in c.stderr
|
||||
assert p.lockfile['_meta']
|
||||
|
||||
|
||||
@@ -619,8 +619,8 @@ def test_lockfile_with_empty_dict(PipenvInstance):
|
||||
with open(p.lockfile_path, 'w') as f:
|
||||
f.write('{}')
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert 'Pipfile.lock is corrupted' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Pipfile.lock is corrupted' in c.stderr
|
||||
assert p.lockfile['_meta']
|
||||
|
||||
|
||||
@@ -638,9 +638,9 @@ url = "{}"
|
||||
requests = "*"
|
||||
""".format(p.index_url))
|
||||
c = p.pipenv('install --skip-lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['_meta']['sources']
|
||||
|
||||
|
||||
@@ -650,12 +650,12 @@ def test_lock_no_warnings(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
os.environ["PYTHONWARNINGS"] = "once"
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('run python -c "import warnings; warnings.warn(\\"This is a warning\\", DeprecationWarning); print(\\"hello\\")"')
|
||||
assert c.return_code == 0
|
||||
assert "Warning" in c.err
|
||||
assert "Warning" not in c.out
|
||||
assert "hello" in c.out
|
||||
assert c.returncode == 0
|
||||
assert "Warning" in c.stderr
|
||||
assert "Warning" not in c.stdout
|
||||
assert "hello" in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.lock
|
||||
@@ -673,9 +673,9 @@ def test_lock_missing_cache_entries_gets_all_hashes(PipenvInstance, tmpdir):
|
||||
p._pipfile.add("pathlib2", "*")
|
||||
assert "pathlib2" in p.pipfile["packages"]
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0, (c.err, ("\n".join([f"{k}: {v}\n" for k, v in os.environ.items()])))
|
||||
assert c.returncode == 0, (c.stderr, ("\n".join([f"{k}: {v}\n" for k, v in os.environ.items()])))
|
||||
c = p.pipenv("lock --clear")
|
||||
assert c.return_code == 0, c.err
|
||||
assert c.returncode == 0, c.stderr
|
||||
assert "pathlib2" in p.lockfile["default"]
|
||||
assert "scandir" in p.lockfile["default"]
|
||||
assert isinstance(p.lockfile["default"]["scandir"]["hashes"], list)
|
||||
@@ -695,7 +695,7 @@ def test_vcs_lock_respects_top_level_pins(PipenvInstance):
|
||||
})
|
||||
p._pipfile.add("urllib3", "==1.21.1")
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.lockfile["default"]
|
||||
assert "git" in p.lockfile["default"]["requests"]
|
||||
assert "urllib3" in p.lockfile["default"]
|
||||
@@ -717,12 +717,12 @@ six = "*"
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write(contents)
|
||||
c = p.pipenv("lock")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile["default"]["six"]["index"] == "test"
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
f.write(contents.replace('name = "test"', 'name = "custom"'))
|
||||
c = p.pipenv("lock --clear")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "index" in p.lockfile["default"]["six"]
|
||||
assert p.lockfile["default"]["six"]["index"] == "custom", Path(p.lockfile_path).read_text()
|
||||
|
||||
@@ -736,7 +736,7 @@ def test_lock_nested_direct_url(PipenvInstance):
|
||||
"""
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install test_package")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "vistir" in p.lockfile["default"]
|
||||
assert "colorama" in p.lockfile["default"]
|
||||
assert "six" in p.lockfile["default"]
|
||||
@@ -752,7 +752,7 @@ def test_lock_nested_vcs_direct_url(PipenvInstance):
|
||||
"subdirectory": "parent_folder/pep508-package"
|
||||
})
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "git" in p.lockfile["default"]["pep508-package"]
|
||||
assert "sibling-package" in p.lockfile["default"]
|
||||
assert "git" in p.lockfile["default"]["sibling-package"]
|
||||
@@ -765,7 +765,7 @@ def test_lock_nested_vcs_direct_url(PipenvInstance):
|
||||
def test_lock_package_with_wildcard_version(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install 'six==1.11.*'")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert p.pipfile["packages"]["six"] == "==1.11.*"
|
||||
assert "six" in p.lockfile["default"]
|
||||
@@ -778,8 +778,8 @@ def test_lock_package_with_wildcard_version(PipenvInstance):
|
||||
def test_default_lock_overwrite_dev_lock(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv("install 'click==6.7'")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("install -d flask")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile["default"]["click"]["version"] == "==6.7"
|
||||
assert p.lockfile["develop"]["click"]["version"] == "==6.7"
|
||||
|
||||
@@ -8,8 +8,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils import temp_environ
|
||||
from pipenv.vendor import delegator
|
||||
from pipenv.utils import subprocess_run, temp_environ
|
||||
|
||||
|
||||
@pytest.mark.code
|
||||
@@ -39,12 +38,12 @@ pytest = "==4.6.9"
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install --verbose')
|
||||
if c.return_code != 0:
|
||||
assert c.err == '' or c.err is None
|
||||
assert c.out == ''
|
||||
assert c.return_code == 0
|
||||
if c.returncode != 0:
|
||||
assert c.stderr == '' or c.stderr is None
|
||||
assert c.stdout == ''
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
contents = """
|
||||
[packages]
|
||||
@@ -53,7 +52,7 @@ requests = "==2.19.1"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('install --deploy')
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
|
||||
@pytest.mark.update
|
||||
@@ -61,7 +60,7 @@ requests = "==2.19.1"
|
||||
def test_update_locks(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv('install jdcal==1.3')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['default']['jdcal']['version'] == '==1.3'
|
||||
with open(p.pipfile_path) as fh:
|
||||
pipfile_contents = fh.read()
|
||||
@@ -70,11 +69,11 @@ def test_update_locks(PipenvInstance):
|
||||
with open(p.pipfile_path, 'w') as fh:
|
||||
fh.write(pipfile_contents)
|
||||
c = p.pipenv('update jdcal')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.lockfile['default']['jdcal']['version'] == '==1.4'
|
||||
c = p.pipenv('run pip freeze')
|
||||
assert c.return_code == 0
|
||||
lines = c.out.splitlines()
|
||||
assert c.returncode == 0
|
||||
lines = c.stdout.splitlines()
|
||||
assert 'jdcal==1.4' in [l.strip() for l in lines]
|
||||
|
||||
|
||||
@@ -82,8 +81,8 @@ def test_update_locks(PipenvInstance):
|
||||
@pytest.mark.proper_names
|
||||
def test_proper_names_unamanged_virtualenv(PipenvInstance):
|
||||
with PipenvInstance(chdir=True):
|
||||
c = delegator.run('python -m virtualenv .venv')
|
||||
assert c.return_code == 0
|
||||
c = subprocess_run(['python', '-m', 'virtualenv', '.venv'])
|
||||
assert c.returncode == 0
|
||||
project = Project()
|
||||
assert project.proper_names == []
|
||||
|
||||
@@ -95,10 +94,10 @@ def test_directory_with_leading_dash(raw_venv, PipenvInstance):
|
||||
if "PIPENV_VENV_IN_PROJECT" in os.environ:
|
||||
del os.environ['PIPENV_VENV_IN_PROJECT']
|
||||
c = p.pipenv('run pip freeze')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('--venv')
|
||||
assert c.return_code == 0
|
||||
venv_path = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
venv_path = c.stdout.strip()
|
||||
assert os.path.isdir(venv_path)
|
||||
# Manually clean up environment, since PipenvInstance assumes that
|
||||
# the virutalenv is in the project directory.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import io
|
||||
import os
|
||||
import tarfile
|
||||
|
||||
@@ -6,9 +5,8 @@ import pytest
|
||||
|
||||
from pipenv.patched import pipfile
|
||||
from pipenv.project import Project
|
||||
from pipenv.utils import temp_environ
|
||||
from pipenv.utils import subprocess_run, temp_environ
|
||||
from pipenv.vendor.vistir.path import is_in_path, normalize_path
|
||||
from pipenv.vendor.delegator import run as delegator_run
|
||||
|
||||
|
||||
@pytest.mark.project
|
||||
@@ -61,7 +59,7 @@ six = {{version = "*", index = "pypi"}}
|
||||
if lock_first:
|
||||
# force source to be cached
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
project = Project()
|
||||
sources = [
|
||||
['pypi', 'https://pypi.org/simple'],
|
||||
@@ -87,7 +85,7 @@ def test_maintain_file_line_endings(PipenvInstance, newlines):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
# Initial pipfile + lockfile generation
|
||||
c = p.pipenv('install pytz')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# Rewrite each file with parameterized newlines
|
||||
for fn in [p.pipfile_path, p.lockfile_path]:
|
||||
@@ -104,7 +102,7 @@ def test_maintain_file_line_endings(PipenvInstance, newlines):
|
||||
|
||||
# Run pipenv install to programatically rewrite
|
||||
c = p.pipenv('install chardet')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# Make sure we kept the right newlines
|
||||
for fn in [p.pipfile_path, p.lockfile_path]:
|
||||
@@ -147,7 +145,7 @@ six = {{version = "*", index = "pypi"}}
|
||||
""".format(os.environ['PIPENV_TEST_INDEX']).strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@@ -160,7 +158,7 @@ def test_include_editable_packages(PipenvInstance, testsroot, pathlib_tmpdir):
|
||||
with tarfile.open(source_path, "r:gz") as tarinfo:
|
||||
tarinfo.extractall(path=str(pathlib_tmpdir))
|
||||
c = p.pipenv(f'install -e {package.as_posix()}')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
project = Project()
|
||||
assert "tablib" in [
|
||||
package.project_name
|
||||
@@ -172,40 +170,40 @@ def test_include_editable_packages(PipenvInstance, testsroot, pathlib_tmpdir):
|
||||
@pytest.mark.virtualenv
|
||||
def test_run_in_virtualenv_with_global_context(PipenvInstance, virtualenv):
|
||||
with PipenvInstance(chdir=True, venv_root=virtualenv.as_posix(), ignore_virtualenvs=False, venv_in_project=False) as p:
|
||||
c = delegator_run(
|
||||
"pipenv run pip freeze", cwd=os.path.abspath(p.path),
|
||||
c = subprocess_run(
|
||||
["pipenv", "run", "pip", "freeze"], cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert 'Creating a virtualenv' not in c.err, c.err
|
||||
assert c.returncode == 0, (c.stdout, c.stderr)
|
||||
assert 'Creating a virtualenv' not in c.stderr, c.stderr
|
||||
project = Project()
|
||||
assert project.virtualenv_location == virtualenv.as_posix(), (
|
||||
project.virtualenv_location, virtualenv.as_posix()
|
||||
)
|
||||
c = delegator_run(
|
||||
f"pipenv run pip install -i {p.index_url} click",
|
||||
c = subprocess_run(
|
||||
["pipenv", "run", "pip", "install", "-i", p.index_url, "click"],
|
||||
cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert "Courtesy Notice" in c.err, (c.out, c.err)
|
||||
c = delegator_run(
|
||||
f"pipenv install -i {p.index_url} six",
|
||||
assert c.returncode == 0, (c.stdout, c.stderr)
|
||||
assert "Courtesy Notice" in c.stderr, (c.stdout, c.stderr)
|
||||
c = subprocess_run(
|
||||
["pipenv", "install", "-i", p.index_url, "six"],
|
||||
cwd=os.path.abspath(p.path), env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
c = delegator_run(
|
||||
'pipenv run python -c "import click;print(click.__file__)"',
|
||||
assert c.returncode == 0, (c.stdout, c.stderr)
|
||||
c = subprocess_run(
|
||||
['pipenv', 'run', 'python', '-c', 'import click;print(click.__file__)'],
|
||||
cwd=os.path.abspath(p.path), env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert is_in_path(c.out.strip(), str(virtualenv)), (c.out.strip(), str(virtualenv))
|
||||
c = delegator_run(
|
||||
"pipenv clean --dry-run", cwd=os.path.abspath(p.path),
|
||||
assert c.returncode == 0, (c.stdout, c.stderr)
|
||||
assert is_in_path(c.stdout.strip(), str(virtualenv)), (c.stdout.strip(), str(virtualenv))
|
||||
c = subprocess_run(
|
||||
["pipenv", "clean", "--dry-run"], cwd=os.path.abspath(p.path),
|
||||
env=os.environ.copy()
|
||||
)
|
||||
assert c.return_code == 0, (c.out, c.err)
|
||||
assert "click" in c.out, c.out
|
||||
assert c.returncode == 0, (c.stdout, c.stderr)
|
||||
assert "click" in c.stdout, c.stdout
|
||||
|
||||
|
||||
@pytest.mark.project
|
||||
@@ -213,21 +211,21 @@ def test_run_in_virtualenv_with_global_context(PipenvInstance, virtualenv):
|
||||
def test_run_in_virtualenv(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('run pip freeze')
|
||||
assert c.return_code == 0
|
||||
assert 'Creating a virtualenv' in c.err
|
||||
assert c.returncode == 0
|
||||
assert 'Creating a virtualenv' in c.stderr
|
||||
project = Project()
|
||||
c = p.pipenv("run pip install click")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("install six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv('run python -c "import click;print(click.__file__)"')
|
||||
assert c.return_code == 0
|
||||
assert normalize_path(c.out.strip()).startswith(
|
||||
assert c.returncode == 0
|
||||
assert normalize_path(c.stdout.strip()).startswith(
|
||||
normalize_path(str(project.virtualenv_location))
|
||||
)
|
||||
c = p.pipenv("clean --dry-run")
|
||||
assert c.return_code == 0
|
||||
assert "click" in c.out
|
||||
assert c.returncode == 0
|
||||
assert "click" in c.stdout
|
||||
|
||||
@pytest.mark.project
|
||||
@pytest.mark.sources
|
||||
@@ -240,4 +238,4 @@ pytest = "*"
|
||||
""".format(os.environ['PIPENV_TEST_INDEX']).strip()
|
||||
f.write(contents)
|
||||
c = p.pipenv('install --skip-lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
@@ -14,8 +14,8 @@ def test_env(PipenvInstance):
|
||||
f.write('HELLO=WORLD')
|
||||
|
||||
c = p.pipenv('run python -c "import os; print(os.environ[\'HELLO\'])"')
|
||||
assert c.return_code == 0
|
||||
assert 'WORLD' in c.out
|
||||
assert c.returncode == 0
|
||||
assert 'WORLD' in c.stdout
|
||||
|
||||
|
||||
@pytest.mark.run
|
||||
@@ -34,19 +34,19 @@ multicommand = "bash -c \"cd docs && make html\""
|
||||
else:
|
||||
f.write('scriptwithenv = "echo $HELLO"\n')
|
||||
c = p.pipenv('install')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('run printfoo')
|
||||
assert c.return_code == 0
|
||||
assert c.out == 'foo\n'
|
||||
assert c.err == ''
|
||||
assert c.returncode == 0
|
||||
assert c.stdout == 'foo\n'
|
||||
assert c.stderr == ''
|
||||
|
||||
c = p.pipenv('run notfoundscript')
|
||||
assert c.return_code == 1
|
||||
assert c.out == ''
|
||||
assert c.returncode == 1
|
||||
assert c.stdout == ''
|
||||
if os.name != 'nt': # TODO: Implement this message for Windows.
|
||||
assert 'Error' in c.err
|
||||
assert 'randomthingtotally (from notfoundscript)' in c.err
|
||||
assert 'Error' in c.stderr
|
||||
assert 'randomthingtotally (from notfoundscript)' in c.stderr
|
||||
|
||||
project = Project()
|
||||
|
||||
@@ -61,6 +61,6 @@ multicommand = "bash -c \"cd docs && make html\""
|
||||
with temp_environ():
|
||||
os.environ['HELLO'] = 'WORLD'
|
||||
c = p.pipenv("run scriptwithenv")
|
||||
assert c.ok
|
||||
assert c.returncode == 0
|
||||
if os.name != "nt": # This doesn't work on CI windows.
|
||||
assert c.out.strip() == "WORLD"
|
||||
assert c.stdout.strip() == "WORLD"
|
||||
|
||||
@@ -16,8 +16,8 @@ def test_sync_error_without_lockfile(PipenvInstance):
|
||||
""".strip())
|
||||
|
||||
c = p.pipenv('sync')
|
||||
assert c.return_code != 0
|
||||
assert 'Pipfile.lock not found!' in c.err
|
||||
assert c.returncode != 0
|
||||
assert 'Pipfile.lock not found!' in c.stderr
|
||||
|
||||
|
||||
@pytest.mark.sync
|
||||
@@ -37,9 +37,9 @@ verify_ssl = true
|
||||
six = "*"
|
||||
""".strip())
|
||||
c = p.pipenv(f'lock --pypi-mirror {mirror_url}')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv(f'sync --pypi-mirror {mirror_url}')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.sync
|
||||
@@ -55,7 +55,7 @@ def test_sync_should_not_lock(PipenvInstance):
|
||||
|
||||
# Perform initial lock.
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
lockfile_content = p.lockfile
|
||||
assert lockfile_content
|
||||
|
||||
@@ -66,7 +66,7 @@ def test_sync_should_not_lock(PipenvInstance):
|
||||
six = "*"
|
||||
""".strip())
|
||||
c = p.pipenv('sync')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert lockfile_content == p.lockfile
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ requests = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# Force hash mismatch when installing `requests`
|
||||
lock = p.lockfile
|
||||
@@ -91,7 +91,7 @@ requests = "*"
|
||||
json.dump(lock, f)
|
||||
|
||||
c = p.pipenv('sync --sequential')
|
||||
assert c.return_code != 0
|
||||
assert c.returncode != 0
|
||||
|
||||
|
||||
@pytest.mark.sync
|
||||
@@ -106,8 +106,8 @@ requests = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv('lock')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('sync --sequential --verbose')
|
||||
for package in p.lockfile['default']:
|
||||
assert f'Successfully installed {package}' in c.out
|
||||
assert f'Successfully installed {package}' in c.stdout
|
||||
|
||||
@@ -15,40 +15,40 @@ def test_uninstall_requests(PipenvInstance):
|
||||
# caused by devendoring
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" in p.pipfile["packages"]
|
||||
|
||||
c = p.pipenv("run python -m requests.help")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "requests" not in p.pipfile["dev-packages"]
|
||||
|
||||
c = p.pipenv("run python -m requests.help")
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
|
||||
@pytest.mark.uninstall
|
||||
def test_uninstall_django(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install Django==1.11.13")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "django" in p.pipfile["packages"]
|
||||
assert "django" in p.lockfile["default"]
|
||||
assert "pytz" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv("run python -m django --version")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall Django")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "django" not in p.pipfile["dev-packages"]
|
||||
assert "django" not in p.lockfile["develop"]
|
||||
assert p.lockfile["develop"] == {}
|
||||
|
||||
c = p.pipenv("run python -m django --version")
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
@@ -62,7 +62,7 @@ def test_mirror_uninstall(PipenvInstance):
|
||||
assert "pypi.org" not in mirror_url
|
||||
|
||||
c = p.pipenv(f"install Django==1.11.13 --pypi-mirror {mirror_url}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "django" in p.pipfile["packages"]
|
||||
assert "django" in p.lockfile["default"]
|
||||
assert "pytz" in p.lockfile["default"]
|
||||
@@ -73,10 +73,10 @@ def test_mirror_uninstall(PipenvInstance):
|
||||
assert "https://pypi.org/simple" == p.lockfile["_meta"]["sources"][0]["url"]
|
||||
|
||||
c = p.pipenv("run python -m django --version")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv(f"uninstall Django --pypi-mirror {mirror_url}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert "django" not in p.pipfile["dev-packages"]
|
||||
assert "django" not in p.lockfile["develop"]
|
||||
assert p.lockfile["develop"] == {}
|
||||
@@ -87,7 +87,7 @@ def test_mirror_uninstall(PipenvInstance):
|
||||
assert "https://pypi.org/simple" == p.lockfile["_meta"]["sources"][0]["url"]
|
||||
|
||||
c = p.pipenv("run python -m django --version")
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
|
||||
@pytest.mark.files
|
||||
@@ -102,10 +102,10 @@ def test_uninstall_all_local_files(PipenvInstance, testsroot):
|
||||
shutil.copy(source_path, os.path.join(p.path, file_name))
|
||||
os.mkdir(os.path.join(p.path, "tablib"))
|
||||
c = p.pipenv(f"install {file_name}")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv("uninstall --all")
|
||||
assert c.return_code == 0
|
||||
assert "tablib" in c.out
|
||||
assert c.returncode == 0
|
||||
assert "tablib" in c.stdout
|
||||
# Uninstall --all is not supposed to remove things from the pipfile
|
||||
# Note that it didn't before, but that instead local filenames showed as hashes
|
||||
assert "tablib" in p.pipfile["packages"]
|
||||
@@ -116,10 +116,10 @@ def test_uninstall_all_local_files(PipenvInstance, testsroot):
|
||||
def test_uninstall_all_dev(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install --dev Django==1.11.13 six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("install tablib")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "tablib" in p.pipfile["packages"]
|
||||
assert "django" in p.pipfile["dev-packages"]
|
||||
@@ -129,10 +129,10 @@ def test_uninstall_all_dev(PipenvInstance):
|
||||
assert "six" in p.lockfile["develop"]
|
||||
|
||||
c = p.pipenv('run python -c "import django"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall --all-dev")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
assert p.pipfile["dev-packages"] == {}
|
||||
assert "django" not in p.lockfile["develop"]
|
||||
assert "six" not in p.lockfile["develop"]
|
||||
@@ -140,10 +140,10 @@ def test_uninstall_all_dev(PipenvInstance):
|
||||
assert "tablib" in p.lockfile["default"]
|
||||
|
||||
c = p.pipenv('run python -c "import django"')
|
||||
assert c.return_code > 0
|
||||
assert c.returncode > 0
|
||||
|
||||
c = p.pipenv('run python -c "import tablib"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.uninstall
|
||||
@@ -159,7 +159,7 @@ python_DateUtil = "*"
|
||||
f.write(contents)
|
||||
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall python_dateutil")
|
||||
assert "Requests" in p.pipfile["packages"]
|
||||
@@ -174,13 +174,13 @@ python_DateUtil = "*"
|
||||
def test_uninstall_all_dev_with_shared_dependencies(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install pytest")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("install --dev six")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall --all-dev")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
assert "six" in p.lockfile["develop"]
|
||||
|
||||
@@ -189,8 +189,8 @@ def test_uninstall_all_dev_with_shared_dependencies(PipenvInstance):
|
||||
def test_uninstall_missing_parameters(PipenvInstance):
|
||||
with PipenvInstance() as p:
|
||||
c = p.pipenv("install requests")
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv("uninstall")
|
||||
assert c.return_code != 0
|
||||
assert "No package provided!" in c.err
|
||||
assert c.returncode != 0
|
||||
assert "No package provided!" in c.stderr
|
||||
|
||||
@@ -15,12 +15,12 @@ def test_case_changes_windows(PipenvInstance):
|
||||
"""
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('install pytz')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
# Canonical venv location.
|
||||
c = p.pipenv('--venv')
|
||||
assert c.return_code == 0
|
||||
virtualenv_location = c.out.strip()
|
||||
assert c.returncode == 0
|
||||
virtualenv_location = c.stdout.strip()
|
||||
|
||||
# Dance around to change the casing of the project directory.
|
||||
target = p.path.upper()
|
||||
@@ -32,8 +32,8 @@ def test_case_changes_windows(PipenvInstance):
|
||||
|
||||
# Ensure the incorrectly-cased project can find the correct venv.
|
||||
c = p.pipenv('--venv')
|
||||
assert c.return_code == 0
|
||||
assert c.out.strip().lower() == virtualenv_location.lower()
|
||||
assert c.returncode == 0
|
||||
assert c.stdout.strip().lower() == virtualenv_location.lower()
|
||||
|
||||
|
||||
@pytest.mark.files
|
||||
@@ -49,7 +49,7 @@ def test_local_path_windows(PipenvInstance):
|
||||
whl = whl.absolute()
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv(f'install "{whl}"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.local
|
||||
@@ -65,17 +65,17 @@ def test_local_path_windows_forward_slash(PipenvInstance):
|
||||
whl = whl.absolute()
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv(f'install "{whl.as_posix()}"')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_pipenv_clean_windows(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
c = p.pipenv('install requests')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
c = p.pipenv(f'run pip install -i {p.index_url} click')
|
||||
assert c.return_code == 0
|
||||
assert c.returncode == 0
|
||||
|
||||
c = p.pipenv('clean --dry-run')
|
||||
assert c.return_code == 0
|
||||
assert 'click' in c.out.strip()
|
||||
assert c.returncode == 0
|
||||
assert 'click' in c.stdout.strip()
|
||||
|
||||
Reference in New Issue
Block a user