Merge pull request #48419 from selfin/issue-48223-add-extra_index_url-support

Fix #48223: broken pip extra-index-url param support at the pip_state
This commit is contained in:
Nicole Thomas 2018-07-03 12:14:50 -04:00 committed by GitHub
commit 9096166bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -1430,7 +1430,8 @@ def list_all_versions(pkg,
include_rc=False,
user=None,
cwd=None,
index_url=None):
index_url=None,
extra_index_url=None):
'''
.. versionadded:: 2017.7.3
@ -1464,6 +1465,10 @@ def list_all_versions(pkg,
Base URL of Python Package Index
.. versionadded:: Fluorine
extra_index_url
Additional URL of Python Package Index
.. versionadded:: Fluorine
CLI Example:
.. code-block:: bash
@ -1480,6 +1485,13 @@ def list_all_versions(pkg,
)
cmd.extend(['--index-url', index_url])
if extra_index_url:
if not salt.utils.url.validate(extra_index_url, VALID_PROTOS):
raise CommandExecutionError(
'\'{0}\' is not a valid URL'.format(extra_index_url)
)
cmd.extend(['--extra-index-url', extra_index_url])
cmd_kwargs = dict(cwd=cwd, runas=user, output_loglevel='quiet', redirect_stderr=True)
if bin_env and os.path.isdir(bin_env):
cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}

View File

@ -193,6 +193,7 @@ def _check_if_installed(prefix,
bin_env,
env_vars,
index_url,
extra_index_url,
**kwargs):
# result: None means the command failed to run
# result: True means the package is installed
@ -235,7 +236,7 @@ def _check_if_installed(prefix,
available_versions = __salt__['pip.list_all_versions'](
prefix_realname, bin_env=bin_env, include_alpha=include_alpha,
include_beta=include_beta, include_rc=include_rc, user=user,
cwd=cwd, index_url=index_url)
cwd=cwd, index_url=index_url, extra_index_url=extra_index_url)
desired_version = ''
if any(version_spec):
for version in reversed(available_versions):
@ -732,7 +733,7 @@ def installed(name,
out = _check_if_installed(prefix, state_pkg_name, version_spec,
ignore_installed, force_reinstall,
upgrade, user, cwd, bin_env, env_vars,
index_url, **kwargs)
index_url, extra_index_url, **kwargs)
# If _check_if_installed result is None, something went wrong with
# the command running. This way we keep stateful output.
if out['result'] is None: