fixes case where name is omitted from pip arg list
This code: ``` if name.endswith('.tar.gz') or name.endswith('.tar.bz2') or name.endswith('.zip'): is_tar = True ``` was not checking whether name is defined since it is an optional param.
This commit is contained in:
parent
423fe82d94
commit
daf4c358f7
1 changed files with 31 additions and 32 deletions
|
@ -20,6 +20,7 @@
|
|||
#
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
|
@ -184,22 +185,6 @@ def main():
|
|||
if state == 'latest' and version is not None:
|
||||
module.fail_json(msg='version is incompatible with state=latest')
|
||||
|
||||
# pip can accept a path to a local project or a VCS url beginning
|
||||
# with svn+, git+, hg+, or bz+ and these sources usually do not qualify
|
||||
# --use-mirrors. Furthermore, the -e option is applied only when
|
||||
# source is a VCS url. Therefore, we will have branch cases for each
|
||||
# type of sources.
|
||||
#
|
||||
# is_vcs includes those begin with svn+, git+, hg+ or bzr+
|
||||
# is_tar ends with .zip, .tar.gz, or .tar.bz2
|
||||
is_vcs = False
|
||||
is_tar = False
|
||||
if name.endswith('.tar.gz') or name.endswith('.tar.bz2') or name.endswith('.zip'):
|
||||
is_tar = True
|
||||
elif name.startswith('svn+') or name.startswith('git+') or \
|
||||
name.startswith('hg+') or name.startswith('bzr+'):
|
||||
is_vcs = True
|
||||
|
||||
err = ''
|
||||
out = ''
|
||||
|
||||
|
@ -226,7 +211,24 @@ def main():
|
|||
|
||||
cmd = '%s %s' % (pip, state_map[state])
|
||||
|
||||
|
||||
if extra_args:
|
||||
cmd += ' %s' % extra_args
|
||||
if name:
|
||||
# pip can accept a path to a local project or a VCS url beginning
|
||||
# with svn+, git+, hg+, or bz+ and these sources usually do not qualify
|
||||
# --use-mirrors. Furthermore, the -e option is applied only when
|
||||
# source is a VCS url. Therefore, we will have branch cases for each
|
||||
# type of sources.
|
||||
#
|
||||
# is_vcs includes those begin with svn+, git+, hg+ or bzr+
|
||||
# is_tar ends with .zip, .tar.gz, or .tar.bz2
|
||||
is_vcs = False
|
||||
is_tar = False
|
||||
if name.endswith('.tar.gz') or name.endswith('.tar.bz2') or name.endswith('.zip'):
|
||||
is_tar = True
|
||||
elif name.startswith('svn+') or name.startswith('git+') or \
|
||||
name.startswith('hg+') or name.startswith('bzr+'):
|
||||
is_vcs = True
|
||||
# If is_vcs=True, we must add -e option (we assume users won't add that to extra_args).
|
||||
if is_vcs:
|
||||
args_list = [] # used if extra_args is not used at all
|
||||
|
@ -240,9 +242,6 @@ def main():
|
|||
is_package = is_vcs or is_tar # just a shortcut for bool
|
||||
if not is_package and state != 'absent' and use_mirrors:
|
||||
cmd += ' --use-mirrors'
|
||||
if extra_args:
|
||||
cmd += ' %s' % extra_args
|
||||
if name:
|
||||
cmd += ' %s' % _get_full_name(name, version)
|
||||
elif requirements:
|
||||
cmd += ' -r %s' % requirements
|
||||
|
|
Loading…
Reference in a new issue