Skip to content

Commit

Permalink
automatically adding --trusted-host
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Jun 17, 2016
1 parent 3432126 commit f50dd05
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]

setup(name='uranium',
version='0.2.36b',
version='0.2.37b',
description='a build system for python',
long_description=open('README.rst').read(),
author='Yusuke Tsutsumi',
Expand Down
Empty file added tests/packages/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions tests/packages/test_install_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from uranium.packages.install_command import _create_args


def test_create_args_includes_trusted_hosts():
"""
if index urls are passed in, there should be a trusted host
argument returned.
"""
args = _create_args("pytest", index_urls=["http://pypi.python.org",
"http://pypi2.python.org"])
assert args == [
"-i", "http://pypi.python.org",
"--trusted-host", "http://pypi.python.org",
"--extra-index-url", "http://pypi2.python.org",
"--trusted-host", "http://pypi2.python.org",
"pytest"
]
22 changes: 14 additions & 8 deletions uranium/packages/install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,30 @@ def populate_requirement_set(self, requirement_set, args, options,
requirement_set.add_requirement(req)


def install(package_name, upgrade=False, develop=False,
version=None, index_urls=None, constraint_dict=None):
def install(*args, constraint_dict=None, **kwargs):
"""
a convenience function to create and use an
install command to install a package.
"""
constraint_dict = constraint_dict or {}
args = _create_args(*args, **kwargs)
command = UraniumInstallCommand()
if constraint_dict:
command.constraint_dict = constraint_dict
options, args = command.parse_args(args)
return command.run(options, args)


def _create_args(package_name, upgrade=False, develop=False,
version=None, index_urls=None):
args = []

if index_urls:
args += ["-i", index_urls[0]]
args += ["--trusted-host", index_urls[0]]
for url in index_urls[1:]:
args += ["--extra-index-url", url]
args += ["--trusted-host", url]

if upgrade:
args.append("--upgrade")
Expand All @@ -57,9 +68,4 @@ def install(package_name, upgrade=False, develop=False,
if version:
requirement += version
args.append(requirement)

command = UraniumInstallCommand()
if constraint_dict:
command.constraint_dict = constraint_dict
options, args = command.parse_args(args)
return command.run(options, args)
return args

0 comments on commit f50dd05

Please sign in to comment.