Merge branch 'master' into bugfix/3239

This commit is contained in:
Dan Ryan
2018-11-18 17:49:44 -05:00
committed by GitHub
5 changed files with 87 additions and 15 deletions
+5 -5
View File
@@ -367,18 +367,18 @@ The only optional section is the ``@<branch_or_tag>`` section. When using git o
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``::
Below is an example usage which installs the git repository located at ``https://github.com/requests/requests.git`` from tag ``v2.20.1`` as package name ``requests``::
$ pipenv install -e git+https://github.com/requests/requests.git@v2.19#egg=requests
$ pipenv install -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests
Creating a Pipfile for this project...
Installing -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests...
Installing -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests...
[...snipped...]
Adding -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests to Pipfile's [packages]...
Adding -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests to Pipfile's [packages]...
[...]
$ cat Pipfile
[packages]
requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "2.19.1"}
requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "v2.20.1"}
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``.
+1 -1
View File
@@ -732,7 +732,7 @@ def batch_install(deps_list, procs, failed_deps_queue,
ignore_hashes=any([ignore_hashes, dep.editable, dep.is_vcs]),
allow_global=allow_global,
no_deps=False if is_artifact else no_deps,
block=any([dep.is_vcs, blocking]),
block=any([dep.editable, dep.is_vcs, blocking]),
index=index,
requirements_dir=requirements_dir,
pypi_mirror=pypi_mirror,
+13 -9
View File
@@ -727,6 +727,18 @@ class Project(object):
data[u"requires"] = {"python_version": version[: len("2.7")]}
self.write_toml(data)
@classmethod
def populate_source(cls, source):
"""Derive missing values of source from the existing fields."""
# Only URL pararemter is mandatory, let the KeyError be thrown.
if "name" not in source:
source["name"] = get_url_name(source["url"])
if "verify_ssl" not in source:
source["verify_ssl"] = "https://" in source["url"]
if not isinstance(source["verify_ssl"], bool):
source["verify_ssl"] = source["verify_ssl"].lower() == "true"
return source
def get_or_create_lockfile(self):
from pipenv.vendor.requirementslib.models.lockfile import Lockfile as Req_Lockfile
lockfile = None
@@ -747,15 +759,7 @@ class Project(object):
elif not isinstance(sources, list):
sources = [sources,]
lockfile_dict["_meta"]["sources"] = [
{
"name": s.get("name", get_url_name(s.get("url"))),
"url": s["url"],
"verify_ssl": (
s["verify_ssl"] if isinstance(s["verify_ssl"], bool) else (
True if s["verify_ssl"].lower() == "true" else False
)
)
} for s in sources
self.populate_source(s) for s in sources
]
_created_lockfile = Req_Lockfile.from_data(
path=self.lockfile_location, data=lockfile_dict, meta_from_project=False
+51
View File
@@ -333,3 +333,54 @@ six = {{path = "./artifacts/{}"}}
c = p.pipenv("install")
assert c.return_code == 0
assert "six" in p.lockfile["default"]
@pytest.mark.files
@pytest.mark.install
@pytest.mark.run
def test_multiple_editable_packages_should_not_race(PipenvInstance, pypi, tmpdir, testsroot):
"""Test for a race condition that can occur when installing multiple 'editable' packages at
once, and which causes some of them to not be importable.
This issue had been fixed for VCS packages already, but not local 'editable' packages.
So this test locally installs packages from tarballs that have already been committed in
the local `pypi` dir to avoid using VCS packages.
"""
pkgs = {
"requests-2.19.1": "requests/requests-2.19.1.tar.gz",
"Flask-0.12.2": "flask/Flask-0.12.2.tar.gz",
"six-1.11.0": "six/six-1.11.0.tar.gz",
"Jinja2-2.10": "jinja2/Jinja2-2.10.tar.gz",
}
pipfile_string="""
[packages]
"""
# Unzip tarballs to known location, and update Pipfile template.
for pkg_name, file_name in pkgs.items():
source_path = str(Path(testsroot, "pypi", file_name))
unzip_path = str(Path(tmpdir.strpath, pkg_name))
import tarfile
with tarfile.open(source_path, "r:gz") as tgz:
tgz.extractall(path=tmpdir.strpath)
pipfile_string += "'{0}' = {{path = '{1}', editable = true}}\n".format(pkg_name, unzip_path)
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write(pipfile_string.strip())
c = p.pipenv('install')
assert c.return_code == 0
c = p.pipenv('run python -c "import requests"')
assert c.return_code == 0
c = p.pipenv('run python -c "import flask"')
assert c.return_code == 0
c = p.pipenv('run python -c "import six"')
assert c.return_code == 0
c = p.pipenv('run python -c "import jinja2"')
assert c.return_code == 0
+17
View File
@@ -486,3 +486,20 @@ def test_lockfile_with_empty_dict(PipenvInstance):
assert c.return_code == 0
assert 'Pipfile.lock is corrupted' in c.err
assert p.lockfile['_meta']
@pytest.mark.lock
@pytest.mark.install
def test_lock_with_incomplete_source(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[[source]]
url = "https://test.pypi.org/simple"
[packages]
requests = "*"
""")
c = p.pipenv('install')
assert c.return_code == 0
assert p.lockfile['_meta']['sources']