re-implements #226

in optional (editable) way 
with backward compatibility
This commit is contained in:
Felix Engelmann 2015-08-30 16:24:13 +02:00 committed by Felix Engelmann
parent 0de2627efc
commit 2a97e9f299

29
packaging/language/pip.py Normal file → Executable file
View file

@ -90,6 +90,12 @@ options:
required: false required: false
default: null default: null
version_added: "1.0" version_added: "1.0"
editable:
description:
- Pass the editable flag for versioning URLs.
required: false
default: yes
version_added: "2.0"
chdir: chdir:
description: description:
- cd into this directory before running the command - cd into this directory before running the command
@ -121,6 +127,9 @@ EXAMPLES = '''
# Install (MyApp) using one of the remote protocols (bzr+,hg+,git+,svn+). You do not have to supply '-e' option in extra_args. # Install (MyApp) using one of the remote protocols (bzr+,hg+,git+,svn+). You do not have to supply '-e' option in extra_args.
- pip: name='svn+http://myrepo/svn/MyApp#egg=MyApp' - pip: name='svn+http://myrepo/svn/MyApp#egg=MyApp'
# Install MyApp using one of the remote protocols (bzr+,hg+,git+) in a non editable way.
- pip: name='git+http://myrepo/app/MyApp' editable=false
# Install (MyApp) from local tarball # Install (MyApp) from local tarball
- pip: name='file:///path/to/MyApp.tar.gz' - pip: name='file:///path/to/MyApp.tar.gz'
@ -239,6 +248,7 @@ def main():
virtualenv_python=dict(default=None, required=False, type='str'), virtualenv_python=dict(default=None, required=False, type='str'),
use_mirrors=dict(default='yes', type='bool'), use_mirrors=dict(default='yes', type='bool'),
extra_args=dict(default=None, required=False), extra_args=dict(default=None, required=False),
editable=dict(default='yes', type='bool', required=False),
chdir=dict(default=None, required=False, type='path'), chdir=dict(default=None, required=False, type='path'),
executable=dict(default=None, required=False), executable=dict(default=None, required=False),
), ),
@ -312,15 +322,16 @@ def main():
# Automatically apply -e option to extra_args when source is a VCS url. VCS # Automatically apply -e option to extra_args when source is a VCS url. VCS
# includes those beginning with svn+, git+, hg+ or bzr+ # includes those beginning with svn+, git+, hg+ or bzr+
if name: if name:
if name.startswith('svn+') or name.startswith('git+') or \ if module.params['editable']:
name.startswith('hg+') or name.startswith('bzr+'): if name.startswith('svn+') or name.startswith('git+') or \
args_list = [] # used if extra_args is not used at all name.startswith('hg+') or name.startswith('bzr+'):
if extra_args: args_list = [] # used if extra_args is not used at all
args_list = extra_args.split(' ') if extra_args:
if '-e' not in args_list: args_list = extra_args.split(' ')
args_list.append('-e') if '-e' not in args_list:
# Ok, we will reconstruct the option string args_list.append('-e')
extra_args = ' '.join(args_list) # Ok, we will reconstruct the option string
extra_args = ' '.join(args_list)
if extra_args: if extra_args:
cmd += ' %s' % extra_args cmd += ' %s' % extra_args