Skip to content

Commit

Permalink
Merge pull request #3217 from pypa/maintenance/merge-3191-3196-3209
Browse files Browse the repository at this point in the history
Merge #3191, #3196 and #3209
  • Loading branch information
techalchemy authored Nov 14, 2018
2 parents e20f0fe + 41cbe4d commit d9ebad3
Show file tree
Hide file tree
Showing 167 changed files with 3,391 additions and 7,439 deletions.
6 changes: 3 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions news/2200.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added persistent settings for all CLI flags via ``PIPENV_{FLAG_NAME}`` environment variables by enabling ``auto_envvar_prefix=PIPENV`` in click (implements PEEP-0002).
2 changes: 1 addition & 1 deletion news/2737.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Handle non-ASCII characters correctly in TOML.
Non-ascii characters will now be handled correctly when parsed by pipenv's ``ToML`` parsers.
2 changes: 1 addition & 1 deletion news/2983.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pipenv will no longer fail when encountering python versions on Windows that were unintalled.
Pipenv will no longer fail when encountering python versions on Windows that have been uninstalled.
2 changes: 1 addition & 1 deletion news/3041.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--bare now has an effect on clean, and sync's bare option is now used to reduce output.
Added support for ``--bare`` to ``pipenv clean``, and fixed ``pipenv sync --bare`` to actually reduce output.
1 change: 1 addition & 0 deletions news/3061.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``pythonfinder`` to correct an issue with unnesting of nested paths when searching for python versions.
2 changes: 1 addition & 1 deletion news/3088.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fixed a bug which caused ``Unexpected EOF`` errors to be thrown when PIP awaited input from users who put login credentials in their environment.
Fixed a bug which caused ``Unexpected EOF`` errors to be thrown when ``pip`` was waiting for input from users who had put login credentials in environment variables.
1 change: 1 addition & 0 deletions news/3096.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed a bug which sometimes prevented cloning and parsing ``mercurial`` requirements.
1 change: 1 addition & 0 deletions news/3096.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added support for python installations managed by ``asdf``.
6 changes: 6 additions & 0 deletions news/3096.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Updated vendored dependencies:
- ``requests 2.19.1 => 2.20.1``
- ``tomlkit 0.4.46 => 0.5.2``
- ``vistir 0.1.6 => 0.2.4``
- ``pythonfinder 1.1.2 => 1.1.8``
- ``requirementslib 1.1.10 => 1.3.0``
2 changes: 1 addition & 1 deletion news/3145.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Remote non-PyPI artifacts and local wheels and artifacts will now include their own hashes rather than including hashes from ``PyPI``.
Hashes for remote and local non-PyPI artifacts will now be included in ``Pipfile.lock`` during resolution.
2 changes: 1 addition & 1 deletion news/3170.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Do not show error but success for running pipenv uninstall --all in a fresh virtuanlenv
Do not show error but success for running ``pipenv uninstall --all`` in a fresh virtual environment.
1 change: 1 addition & 0 deletions news/3191.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to ``tomlkit`` for parsing and writing. Drop ``prettytoml`` and ``contoml`` from vendors.
1 change: 1 addition & 0 deletions news/3196.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``requirementslib`` to aid in resolution of local and remote archives.
1 change: 1 addition & 0 deletions news/3216.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When sources are missing names, names will now be derived from the supplied URL.
1 change: 1 addition & 0 deletions news/3217.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved asynchronous installation and error handling via queued subprocess paralleization.
12 changes: 8 additions & 4 deletions pipenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .__version__ import __version__

PIPENV_ROOT = os.path.dirname(os.path.realpath(__file__))
PIPENV_ROOT = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
PIPENV_VENDOR = os.sep.join([PIPENV_ROOT, "vendor"])
PIPENV_PATCHED = os.sep.join([PIPENV_ROOT, "patched"])
# Inject vendored directory into system path.
Expand All @@ -27,11 +27,15 @@
if sys.version_info >= (3, 1) and sys.version_info <= (3, 6):
if sys.stdout.isatty() and sys.stderr.isatty():
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf8')
import atexit
stdout_wrapper = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
atexit.register(stdout_wrapper.close)
stderr_wrapper = io.TextIOWrapper(sys.stderr.buffer, encoding='utf8')
atexit.register(stderr_wrapper.close)
sys.stdout = stdout_wrapper
sys.stderr = stderr_wrapper

os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = fs_str("1")
os.environ["PIP_SHIMS_BASE_MODULE"] = fs_str("pipenv.patched.notpip")

# Hack to make things work better.
try:
Expand Down
2 changes: 1 addition & 1 deletion pipenv/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .cli import cli

if __name__ == "__main__":
cli()
cli(auto_envvar_prefix="PIPENV")
33 changes: 14 additions & 19 deletions pipenv/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Exposes a standard API that enables compatibility across python versions,
operating systems, etc.
"""

import functools
import importlib
import io
Expand Down Expand Up @@ -66,21 +67,10 @@ def detach(self):
warnings.filterwarnings("ignore", category=ResourceWarning)


def pip_import(module_path, subimport=None, old_path=None):
internal = "pip._internal.{0}".format(module_path)
old_path = old_path or module_path
pip9 = "pip.{0}".format(old_path)
try:
_tmp = importlib.import_module(internal)
except ImportError:
_tmp = importlib.import_module(pip9)
if subimport:
return getattr(_tmp, subimport, _tmp)
return _tmp


class TemporaryDirectory(object):
"""Create and return a temporary directory. This has the same

"""
Create and return a temporary directory. This has the same
behavior as mkdtemp but can be used as a context manager. For
example:
Expand Down Expand Up @@ -146,9 +136,11 @@ def _sanitize_params(prefix, suffix, dir):


class _TemporaryFileCloser:
"""A separate object allowing proper closing of a temporary file's
"""
A separate object allowing proper closing of a temporary file's
underlying file object, without adding a __del__ method to the
temporary file."""
temporary file.
"""

file = None # Set here since __del__ checks it
close_called = False
Expand Down Expand Up @@ -192,7 +184,9 @@ def close(self):


class _TemporaryFileWrapper:
"""Temporary file wrapper

"""
Temporary file wrapper
This class provides a wrapper around files opened for
temporary use. In particular, it seeks to automatically
remove the file when it is no longer needed.
Expand Down Expand Up @@ -268,7 +262,8 @@ def NamedTemporaryFile(
dir=None,
delete=True,
):
"""Create and return a temporary file.
"""
Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
'mode' -- the mode argument to io.open (default "w+b").
Expand Down Expand Up @@ -382,7 +377,7 @@ def decode_output(output):
except (AttributeError, UnicodeDecodeError, UnicodeEncodeError):
if six.PY2:
output = unicode.translate(vistir.misc.to_text(output),
UNICODE_TO_ASCII_TRANSLATION_MAP)
UNICODE_TO_ASCII_TRANSLATION_MAP)
else:
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
output = output.encode(DEFAULT_ENCODING, "replace")
Expand Down
3 changes: 1 addition & 2 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ def uninstall(
):
"""Un-installs a provided package and removes it from Pipfile."""
from ..core import do_uninstall

retcode = do_uninstall(
packages=state.installstate.packages,
editable_packages=state.installstate.editables,
three=state.three,
python=state.python,
system=state.system,
lock=not skip_lock,
lock=not state.installstate.skip_lock,
all_dev=all_dev,
all=all,
keep_outdated=state.installstate.keep_outdated,
Expand Down
71 changes: 36 additions & 35 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def callback(ctx, param, value):
state.index = value
return value
return option('-i', '--index', expose_value=False, envvar="PIP_INDEX_URL",
help='Target PyPI-compatible package index url.', nargs=1,
callback=callback)(f)
help='Target PyPI-compatible package index url.', nargs=1,
callback=callback)(f)


def extra_index_option(f):
Expand All @@ -96,8 +96,8 @@ def callback(ctx, param, value):
state.extra_index_urls.extend(list(value))
return value
return option("--extra-index-url", multiple=True, expose_value=False,
help=u"URLs to the extra PyPI compatible indexes to query for package lookups.",
callback=callback, envvar="PIP_EXTRA_INDEX_URL")(f)
help=u"URLs to the extra PyPI compatible indexes to query for package lookups.",
callback=callback, envvar="PIP_EXTRA_INDEX_URL")(f)


def editable_option(f):
Expand All @@ -106,8 +106,8 @@ def callback(ctx, param, value):
state.installstate.editables.extend(value)
return value
return option('-e', '--editable', expose_value=False, multiple=True,
help='An editable python package URL or path, often to a VCS repo.',
callback=callback)(f)
help='An editable python package URL or path, often to a VCS repo.',
callback=callback, type=click.types.STRING)(f)


def sequential_option(f):
Expand All @@ -116,8 +116,8 @@ def callback(ctx, param, value):
state.installstate.sequential = value
return value
return option("--sequential", is_flag=True, default=False, expose_value=False,
help="Install dependencies one-at-a-time, instead of concurrently.",
callback=callback, type=click.types.BOOL)(f)
help="Install dependencies one-at-a-time, instead of concurrently.",
callback=callback, type=click.types.BOOL)(f)


def skip_lock_option(f):
Expand All @@ -126,8 +126,8 @@ def callback(ctx, param, value):
state.installstate.skip_lock = value
return value
return option("--skip-lock", is_flag=True, default=False, expose_value=False,
help=u"Skip locking mechanisms and use the Pipfile instead during operation.",
callback=callback, type=click.types.BOOL)(f)
help=u"Skip locking mechanisms and use the Pipfile instead during operation.",
envvar="PIPENV_SKIP_LOCK", callback=callback, type=click.types.BOOL)(f)


def keep_outdated_option(f):
Expand All @@ -136,8 +136,8 @@ def callback(ctx, param, value):
state.installstate.keep_outdated = value
return value
return option("--keep-outdated", is_flag=True, default=False, expose_value=False,
help=u"Keep out-dated dependencies from being updated in Pipfile.lock.",
callback=callback, type=click.types.BOOL)(f)
help=u"Keep out-dated dependencies from being updated in Pipfile.lock.",
callback=callback, type=click.types.BOOL)(f)


def selective_upgrade_option(f):
Expand All @@ -146,8 +146,8 @@ def callback(ctx, param, value):
state.installstate.selective_upgrade = value
return value
return option("--selective-upgrade", is_flag=True, default=False, type=click.types.BOOL,
help="Update specified packages.", callback=callback,
expose_value=False)(f)
help="Update specified packages.", callback=callback,
expose_value=False)(f)


def ignore_pipfile_option(f):
Expand All @@ -156,8 +156,8 @@ def callback(ctx, param, value):
state.installstate.ignore_pipfile = value
return value
return option("--ignore-pipfile", is_flag=True, default=False, expose_value=False,
help="Ignore Pipfile when installing, using the Pipfile.lock.",
callback=callback)(f)
help="Ignore Pipfile when installing, using the Pipfile.lock.",
callback=callback, type=click.types.BOOL)(f)


def dev_option(f):
Expand All @@ -166,8 +166,8 @@ def callback(ctx, param, value):
state.installstate.dev = value
return value
return option("--dev", "-d", is_flag=True, default=False, type=click.types.BOOL,
help="Install both develop and default packages.", callback=callback,
expose_value=False)(f)
help="Install both develop and default packages.", callback=callback,
expose_value=False)(f)


def pre_option(f):
Expand All @@ -176,15 +176,16 @@ def callback(ctx, param, value):
state.installstate.pre = value
return value
return option("--pre", is_flag=True, default=False, help=u"Allow pre-releases.",
callback=callback, type=click.types.BOOL, expose_value=False)(f)
callback=callback, type=click.types.BOOL, expose_value=False)(f)


def package_arg(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
state.installstate.packages.extend(value)
return value
return argument('packages', nargs=-1, callback=callback, expose_value=False,)(f)
return argument('packages', nargs=-1, callback=callback, expose_value=False,
type=click.types.STRING)(f)


def three_option(f):
Expand All @@ -195,8 +196,8 @@ def callback(ctx, param, value):
state.two = not value
return value
return option("--three/--two", is_flag=True, default=None,
help="Use Python 3/2 when creating virtualenv.", callback=callback,
expose_value=False)(f)
help="Use Python 3/2 when creating virtualenv.", callback=callback,
expose_value=False)(f)


def python_option(f):
Expand All @@ -206,8 +207,8 @@ def callback(ctx, param, value):
state.python = validate_python_path(ctx, param, value)
return value
return option("--python", default=False, nargs=1, callback=callback,
help="Specify which version of Python virtualenv should use.",
expose_value=False)(f)
help="Specify which version of Python virtualenv should use.",
expose_value=False)(f)


def pypi_mirror_option(f):
Expand All @@ -217,7 +218,7 @@ def callback(ctx, param, value):
state.pypi_mirror = validate_pypi_mirror(ctx, param, value)
return value
return option("--pypi-mirror", default=environments.PIPENV_PYPI_MIRROR, nargs=1,
callback=callback, help="Specify a PyPI mirror.", expose_value=False)(f)
callback=callback, help="Specify a PyPI mirror.", expose_value=False)(f)


def verbose_option(f):
Expand All @@ -227,7 +228,7 @@ def callback(ctx, param, value):
state.verbose = True
setup_verbosity(ctx, param, value)
return option("--verbose", "-v", is_flag=True, expose_value=False,
callback=callback, help="Verbose mode.")(f)
callback=callback, help="Verbose mode.", type=click.types.BOOL)(f)


def site_packages_option(f):
Expand All @@ -236,8 +237,8 @@ def callback(ctx, param, value):
state.site_packages = value
return value
return option("--site-packages", is_flag=True, default=False, type=click.types.BOOL,
help="Enable site-packages for the virtualenv.", callback=callback,
expose_value=False)(f)
help="Enable site-packages for the virtualenv.", callback=callback,
expose_value=False)(f)


def clear_option(f):
Expand All @@ -246,8 +247,8 @@ def callback(ctx, param, value):
state.clear = value
return value
return option("--clear", is_flag=True, callback=callback, type=click.types.BOOL,
help="Clears caches (pipenv, pip, and pip-tools).",
expose_value=False)(f)
help="Clears caches (pipenv, pip, and pip-tools).",
expose_value=False)(f)


def system_option(f):
Expand All @@ -257,7 +258,7 @@ def callback(ctx, param, value):
state.system = value
return value
return option("--system", is_flag=True, default=False, help="System pip management.",
callback=callback, type=click.types.BOOL, expose_value=False)(f)
callback=callback, type=click.types.BOOL, expose_value=False)(f)


def requirementstxt_option(f):
Expand All @@ -267,7 +268,7 @@ def callback(ctx, param, value):
state.installstate.requirementstxt = value
return value
return option("--requirements", "-r", nargs=1, default=False, expose_value=False,
help="Import a requirements.txt file.", callback=callback)(f)
help="Import a requirements.txt file.", callback=callback)(f)


def requirements_flag(f):
Expand All @@ -277,7 +278,7 @@ def callback(ctx, param, value):
state.installstate.requirementstxt = value
return value
return option("--requirements", "-r", default=False, is_flag=True, expose_value=False,
help="Generate output in requirements.txt format.", callback=callback)(f)
help="Generate output in requirements.txt format.", callback=callback)(f)


def code_option(f):
Expand All @@ -296,8 +297,8 @@ def callback(ctx, param, value):
state.installstate.deploy = value
return value
return option("--deploy", is_flag=True, default=False, type=click.types.BOOL,
help=u"Abort if the Pipfile.lock is out-of-date, or Python version is"
" wrong.", callback=callback, expose_value=False)(f)
help=u"Abort if the Pipfile.lock is out-of-date, or Python version is"
" wrong.", callback=callback, expose_value=False)(f)


def setup_verbosity(ctx, param, value):
Expand Down
Loading

0 comments on commit d9ebad3

Please sign in to comment.