Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PEP 508 @ url syntax #4175

Merged
merged 3 commits into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
* Return a failing exit status when `pip install`, `pip download`, or
`pip wheel` is called with no requirements. (:issue:`2720`, :pull:`2721`)


* Add `--exclude-editable` to ``pip freeze`` to exclude editable packages
from installed package list.

* Add `--progress-bar <progress_bar>` to ``pip download``, ``pip install``
and ``pip wheel`` to suppress progress bar in the console (:pull:`4194`)

* Add support for the new ``@ url`` syntax from PEP 508 (:pull:`4175`)


**9.0.1 (2016-11-06)**

Expand Down
12 changes: 11 additions & 1 deletion pip/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def __init__(self, req, comes_from, source_dir=None, editable=False,
self.editable = editable

self._wheel_cache = wheel_cache
self.link = self.original_link = link
if link is not None:
self.link = self.original_link = link
else:
from pip.index import Link
self.link = self.original_link = req and req.url and Link(req.url)

self.as_egg = as_egg
if extras:
self.extras = extras
Expand Down Expand Up @@ -159,6 +164,11 @@ def from_req(cls, req, comes_from=None, isolated=False, wheel_cache=None):
req = Requirement(req)
except InvalidRequirement:
raise InstallationError("Invalid requirement: '%s'" % req)
if req.url:
raise InstallationError(
"Direct url requirement (like %s) are not allowed for "
"dependencies" % req
)
return cls(req, comes_from, isolated=isolated, wheel_cache=wheel_cache)

@classmethod
Expand Down
29 changes: 29 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pip.status_codes import ERROR
from tests.lib import (pyversion, pyversion_tuple,
_create_test_package, _create_svn_repo, path_to_url,
create_test_package_with_setup,
requirements_file)
from tests.lib.local_repos import local_checkout
from tests.lib.path import Path
Expand Down Expand Up @@ -1191,3 +1192,31 @@ def test_install_environment_markers(script, data):
assert ("Ignoring missing-pkg: markers 'python_version == \"1.0\"' don't "
"match your environment") in res.stderr, str(res)
assert "Successfully installed pkga-0.1" in res.stdout, str(res)


@pytest.mark.network
def test_install_pep508_with_url(script):
res = script.pip(
'install', '--no-index',
'packaging@https://files.pythonhosted.org/packages/2f/2b/'
'c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/'
'packaging-15.3-py2.py3-none-any.whl#sha256='
'ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4'
)
assert "Successfully installed packaging-15.3" in str(res), str(res)


@pytest.mark.network
def test_install_pep508_with_url_in_install_requires(script):
pkga_path = create_test_package_with_setup(
script, name='pkga', version='1.0',
install_requires=[
'packaging@https://files.pythonhosted.org/packages/2f/2b/'
'c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/'
'packaging-15.3-py2.py3-none-any.whl#sha256='
'ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4'
],
)
res = script.pip('install', pkga_path, expect_error=True)
assert "Direct url requirement " in res.stderr, str(res)
assert "are not allowed for dependencies" in res.stderr, str(res)