Merge branch 'master' into master

This commit is contained in:
Dan Ryan
2018-08-19 21:29:18 -04:00
committed by GitHub
13 changed files with 145 additions and 28 deletions
+26 -3
View File
@@ -1,10 +1,10 @@
Pipenv: Python Development Workflow for Humans
==============================================
[![image](https://img.shields.io/pypi/v/pipenv.svg)](https://pypi.python.org/pypi/pipenv)
[![image](https://img.shields.io/pypi/l/pipenv.svg)](https://pypi.python.org/pypi/pipenv)
[![image](https://img.shields.io/pypi/v/pipenv.svg)](https://python.org/pypi/pipenv)
[![image](https://img.shields.io/pypi/l/pipenv.svg)](https://python.org/pypi/pipenv)
[![image](https://badge.buildkite.com/79c7eccf056b17c3151f3c4d0e4c4b8b724539d84f1e037b9b.svg?branch=master)](https://code.kennethreitz.org/source/pipenv/)
[![image](https://img.shields.io/pypi/pyversions/pipenv.svg)](https://pypi.python.org/pypi/pipenv)
[![image](https://img.shields.io/pypi/pyversions/pipenv.svg)](https://python.org/pypi/pipenv)
[![image](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/kennethreitz)
------------------------------------------------------------------------
@@ -216,6 +216,29 @@ Install packages:
To activate this project's virtualenv, run the following:
$ pipenv shell
Installing from git:
You can install packages with pipenv from git and other version control systems using URLs formatted according to the following rule:
<vcs_type>+<scheme>://<location>/<user_or_organizatoin>/<repository>@<branch_or_tag>#<package_name>
The only optional section is the `@<branch_or_tag>` section. When using git over SSH, you may use the shorthand vcs and scheme alias `git+git@<location>:<user_or_organization>/<repository>@<branch_or_tag>#<package_name>`. Note that this is translated to `git+ssh://git@<location>` when parsed.
Valid values for `<vcs_type>` include `git`, `bzr`, `svn`, and `hg`. Valid values for `<scheme>` include `http,`, `https`, `ssh`, and `file`. In specific cases you also have access to other schemes: `svn` may be combined with `svn` as a scheme, and `bzr` can be combined with `sftp` and `lp`.
Note that it is **strongly recommended** that you install any version-controlled dependencies in editable mode, using `pipenv install -e`, in order to ensure that dependency resolution can be performed with an up to date copy of the repository each time it is performed, and that it includes all known dependencies.
Below is an example usage which installs the git repository located at `https://github.com/requests/requests.git` from tag `v2.19.1` as package name `requests`:
$ pipenv install -e git+https://github.com/requests/requests.git@v2.19#egg=requests
Creating a Pipfile for this project...
Installing -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests...
[...snipped...]
Adding -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests to Pipfile's [packages]...
[...]
You can read more about [pip's implementation of vcs support here](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support).
Install a dev dependency:
$ pipenv install pytest --dev
+20 -5
View File
@@ -329,21 +329,35 @@ You should do this for your shell too, in your ``~/.profile`` or ``~/.bashrc`` o
.. note:: The shell launched in interactive mode. This means that if your shell reads its configuration from a specific file for interactive mode (e.g. bash by default looks for a ``~/.bashrc`` configuration file for interactive mode), then you'll need to modify (or create) this file.
If you experience issues with ``$ pipenv shell``, just check the ``PIPENV_SHELL`` environment variable, which ``$ pipenv shell`` will use if available. For detail, see :ref:`configuration-with-environment-variables`.
☤ A Note about VCS Dependencies
-------------------------------
Pipenv will resolve the subdependencies of VCS dependencies, but only if they are installed in editable mode::
You can install packages with pipenv from git and other version control systems using URLs formatted according to the following rule::
$ pipenv install -e git+https://github.com/requests/requests.git#egg=requests
<vcs_type>+<scheme>://<location>/<user_or_organizatoin>/<repository>@<branch_or_tag>#<package_name>
The only optional section is the ``@<branch_or_tag>`` section. When using git over SSH, you may use the shorthand vcs and scheme alias ``git+git@<location>:<user_or_organization>/<repository>@<branch_or_tag>#<package_name>``. Note that this is translated to ``git+ssh://git@<location>`` when parsed.
Note that it is **strongly recommended** that you install any version-controlled dependencies in editable mode, using ``pipenv install -e``, in order to ensure that dependency resolution can be performed with an up to date copy of the repository each time it is performed, and that it includes all known dependencies.
Below is an example usage which installs the git repository located at ``https://github.com/requests/requests.git`` from tag ``v2.19.1`` as package name ``requests``::
$ pipenv install -e git+https://github.com/requests/requests.git@v2.19#egg=requests
Creating a Pipfile for this project...
Installing -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests...
[...snipped...]
Adding -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests to Pipfile's [packages]...
[...]
$ cat Pipfile
[packages]
requests = {git = "https://github.com/requests/requests.git", editable=true}
requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "2.19.1"}
If editable is not true, subdependencies will not be resolved.
Valid values for ``<vcs_type>`` include ``git``, ``bzr``, ``svn``, and ``hg``. Valid values for ``<scheme>`` include ``http``, ``https``, ``ssh``, and ``file``. In specific cases you also have access to other schemes: ``svn`` may be combined with ``svn`` as a scheme, and ``bzr`` can be combined with ``sftp`` and ``lp``.
For more information about other options available when specifying VCS dependencies, please check the `Pipfile spec <https://github.com/pypa/pipfile>`__.
You can read more about pip's implementation of VCS support `here <https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support>`_. For more information about other options available when specifying VCS dependencies, please check the `Pipfile spec <https://github.com/pypa/pipfile>`_.
☤ Pipfile.lock Security Features
@@ -365,3 +379,4 @@ production environments for reproducible builds.
This will include all hashes, however (which is great!). To get a ``requirements.txt``
without hashes, use ``$ pipenv run pip freeze``.
.. _configuration-with-environment-variables:https://docs.pipenv.org/advanced/#configuration-with-environment-variables
+1 -1
View File
@@ -7,7 +7,7 @@ docutils==0.14
first==2.0.1
idna==2.6
imagesize==0.7.1
Jinja2==2.9.6
Jinja2==2.10
MarkupSafe==1.0
pbr==3.1.1
pip-tools==1.9.0
+1
View File
@@ -0,0 +1 @@
Added additional information about troubleshooting ``pipenv shell`` by using the the ``$PIPENV_SHELL`` environment variable.
+1
View File
@@ -0,0 +1 @@
Added simple example to README.md for installing from git.
+1
View File
@@ -0,0 +1 @@
Added additional information to error messaging during failed resolution.
+1
View File
@@ -0,0 +1 @@
Correctly pass `verbose` and `debug` flags to the resolver subprocess so it generates appropriate output. This also resolves a bug introduced by the fix to #2527.
+8 -4
View File
@@ -550,15 +550,19 @@ def ensure_project(
):
click.echo(
"{0}: Your Pipfile requires {1} {2}, "
"but you are using {3} ({4}). Running"
"{5} and rebuilding the virtual environment"
"may resolve the issue".format(
"but you are using {3} ({4}).".format(
crayons.red("Warning", bold=True),
crayons.normal("python_version", bold=True),
crayons.blue(project.required_python_version),
crayons.blue(python_version(path_to_python)),
crayons.green(shorten_path(path_to_python)),
crayons.green("`pipenv --rm`"),
),
err=True,
)
click.echo(
" {0} and rebuilding the virtual environment "
"may resolve the issue.".format(
crayons.green("$ pipenv --rm"),
),
err=True,
)
+1 -1
View File
@@ -95,7 +95,7 @@ PIPENV_MAX_RETRIES = int(os.environ.get(
))
"""Specify how many retries Pipenv should attempt for network requests.
Default is 0. Aautomatically set to 1 on CI environments for robust testing.
Default is 0. Automatically set to 1 on CI environments for robust testing.
"""
PIPENV_MAX_ROUNDS = int(os.environ.get("PIPENV_MAX_ROUNDS", "16"))
+8 -6
View File
@@ -113,9 +113,10 @@ class Bar(object):
self.etadisp = self.format_time(self.eta)
x = int(self.width * progress / self.expected_size)
if not self.hide:
if (progress % self.every) == 0 or ( # True every "every" updates
progress == self.expected_size
): # And when we're done
if (
progress % self.every == 0 # True every "every" updates
or progress == self.expected_size # And when we're done
):
STREAM.write(
BAR_TEMPLATE
% (
@@ -208,9 +209,10 @@ def mill(it, label="", hide=None, expected_size=None, every=1):
def _show(_i):
if not hide:
if (_i % every) == 0 or (
_i == count
): # True every "every" updates # And when we're done
if (
_i % every == 0 # True every "every" updates
or _i == count # And when we're done
):
STREAM.write(MILL_TEMPLATE % (label, _mill_char(_i), _i, count))
STREAM.flush()
+10 -3
View File
@@ -22,6 +22,7 @@ def which(*args, **kwargs):
def main():
do_pre = "--pre" in " ".join(sys.argv)
do_clear = "--clear" in " ".join(sys.argv)
is_verbose = "--verbose" in " ".join(sys.argv)
is_debug = "--debug" in " ".join(sys.argv)
system = "--system" in " ".join(sys.argv)
new_sys_argv = []
@@ -35,11 +36,17 @@ def main():
os.environ["PIP_PYTHON_VERSION"] = ".".join([str(s) for s in sys.version_info[:3]])
os.environ["PIP_PYTHON_PATH"] = sys.executable
if int(os.environ.get("PIPENV_VERBOSITY", 0)) > 0:
logging.getLogger("notpip").setLevel(logging.INFO)
verbosity = int(os.environ.get("PIPENV_VERBOSITY", 0))
if is_debug:
# Shit's getting real at this point.
verbosity = max(verbosity, 2)
elif is_verbose:
verbosity = max(verbosity, 1)
if verbosity > 1: # Shit's getting real at this point.
logging.getLogger("notpip").setLevel(logging.DEBUG)
elif verbosity > 0:
logging.getLogger("notpip").setLevel(logging.INFO)
if "PIPENV_PACKAGES" in os.environ:
packages = os.environ["PIPENV_PACKAGES"].strip().split("\n")
else:
+7 -5
View File
@@ -310,11 +310,13 @@ def actually_resolve_deps(
click_echo(
"{0}: Your dependencies could not be resolved. You likely have a "
"mismatch in your sub-dependencies.\n "
"You can use {1} to bypass this mechanism, then run {2} to inspect "
"the situation.\n "
"Hint: try {3} if it is a pre-release dependency."
"First try clearing your dependency cache with {1}, then try the original command again.\n "
"Alternatively, you can use {2} to bypass this mechanism, then run "
"{3} to inspect the situation.\n "
"Hint: try {4} if it is a pre-release dependency."
"".format(
crayons.red("Warning", bold=True),
crayons.red("$ pipenv lock --clear"),
crayons.red("$ pipenv install --skip-lock"),
crayons.red("$ pipenv graph"),
crayons.red("$ pipenv lock --pre"),
@@ -352,11 +354,10 @@ def venv_resolve_deps(
if not deps:
return []
resolver = escape_grouped_arguments(resolver.__file__.rstrip("co"))
cmd = "{0} {1} {2} {3} {4} {5}".format(
cmd = "{0} {1} {2} {3} {4}".format(
escape_grouped_arguments(which("python", allow_global=allow_global)),
resolver,
"--pre" if pre else "",
"--verbose" if (environments.is_verbose()) else "",
"--clear" if clear else "",
"--system" if allow_global else "",
)
@@ -364,6 +365,7 @@ def venv_resolve_deps(
os.environ["PIPENV_PACKAGES"] = "\n".join(deps)
if pypi_mirror:
os.environ["PIPENV_PYPI_MIRROR"] = str(pypi_mirror)
os.environ["PIPENV_VERBOSITY"] = str(environments.PIPENV_VERBOSITY)
c = delegator.run(cmd, block=True)
try:
assert c.return_code == 0
+60
View File
@@ -57,6 +57,66 @@ zip_safe=False
assert "six" in p.lockfile["default"]
@pytest.mark.install
@pytest.mark.local
@pytest.mark.needs_internet
@flaky
class TestDependencyLinks(object):
"""Ensure dependency_links are parsed and installed.
This is needed for private repo dependencies.
"""
@staticmethod
def helper_dependency_links_install_make_setup(pipenv_instance, deplink):
setup_py = os.path.join(pipenv_instance.path, "setup.py")
with open(setup_py, "w") as fh:
contents = """
from setuptools import setup
setup(
name='testdeplinks',
version='0.1',
packages=[],
install_requires=[
'test-private-dependency'
],
dependency_links=[
'{0}'
]
)
""".strip().format(deplink)
fh.write(contents)
@staticmethod
def helper_dependency_links_install_test(pipenv_instance, deplink):
TestDependencyLinks.helper_dependency_links_install_make_setup(pipenv_instance, deplink)
c = pipenv_instance.pipenv("install -v -e .")
assert c.return_code == 0
assert "test-private-dependency" in pipenv_instance.lockfile["default"]
assert "version" in pipenv_instance.lockfile["default"]["test-private-dependency"]
assert "0.1" in pipenv_instance.lockfile["default"]["test-private-dependency"]["version"]
def test_https_dependency_links_install(self, PipenvInstance, pypi):
"""Ensure dependency_links are parsed and installed (needed for private repo dependencies).
"""
with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p:
os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1'
TestDependencyLinks.helper_dependency_links_install_test(
p,
'git+https://github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1'
)
@pytest.mark.needs_github_ssh
def test_ssh_dependency_links_install(self, PipenvInstance, pypi):
with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p:
os.environ['PIP_PROCESS_DEPENDENCY_LINKS'] = '1'
TestDependencyLinks.helper_dependency_links_install_test(
p,
'git+ssh://git@github.com/atzannes/test-private-dependency@v0.1#egg=test-private-dependency-v0.1'
)
@pytest.mark.e
@pytest.mark.install
@pytest.mark.skip(reason="this doesn't work on windows")