Skip to content

Commit

Permalink
handle non-URL sources - raise PipenvUsageError
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGold committed Jan 17, 2019
1 parent c4341a7 commit b60439d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/2373.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise `PipenvUsageError` when [[source]] does not contain url field.
12 changes: 8 additions & 4 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import parse

from . import environments
from .exceptions import PipenvUsageError
from .pep508checker import lookup


Expand Down Expand Up @@ -203,20 +204,23 @@ def prepare_pip_source_args(sources, pip_args=None):
pip_args = []
if sources:
# Add the source to notpip.
pip_args.extend(["-i", sources[0]["url"]])
package_url = sources[0].get("url")
if not package_url:
raise PipenvUsageError("Please provide a source URL.")
pip_args.extend(["-i", package_url])
# Trust the host if it's not verified.
if not sources[0].get("verify_ssl", True):
pip_args.extend(
["--trusted-host", urllib3_util.parse_url(sources[0]["url"]).host]
["--trusted-host", urllib3_util.parse_url(package_url).host]
)
# Add additional sources as extra indexes.
if len(sources) > 1:
for source in sources[1:]:
pip_args.extend(["--extra-index-url", source["url"]])
pip_args.extend(["--extra-index-url", source.get("url")])
# Trust the host if it's not verified.
if not source.get("verify_ssl", True):
pip_args.extend(
["--trusted-host", urllib3_util.parse_url(source["url"]).host]
["--trusted-host", urllib3_util.parse_url(source.get("url")).host]
)
return pip_args

Expand Down

0 comments on commit b60439d

Please sign in to comment.