Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
049f4a98
Commit
049f4a98
authored
Aug 08, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6701 from carlanton/pr/pip_check_fix2
Make pip dry run work better for the common case
parents
7f005fdd
71949fbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
library/packaging/pip
+35
-3
No files found.
library/packaging/pip
View file @
049f4a98
...
@@ -153,6 +153,19 @@ def _get_full_name(name, version=None):
...
@@ -153,6 +153,19 @@ def _get_full_name(name, version=None):
resp
=
name
+
'=='
+
version
resp
=
name
+
'=='
+
version
return
resp
return
resp
def
_is_present
(
name
,
version
,
installed_pkgs
):
for
pkg
in
installed_pkgs
:
if
'=='
not
in
pkg
:
continue
[
pkg_name
,
pkg_version
]
=
pkg
.
split
(
'=='
)
if
pkg_name
==
name
and
(
version
is
None
or
version
==
pkg_version
):
return
True
return
False
def
_get_pip
(
module
,
env
=
None
,
executable
=
None
):
def
_get_pip
(
module
,
env
=
None
,
executable
=
None
):
# On Debian and Ubuntu, pip is pip.
# On Debian and Ubuntu, pip is pip.
...
@@ -295,13 +308,32 @@ def main():
...
@@ -295,13 +308,32 @@ def main():
cmd
+=
'
%
s'
%
_get_full_name
(
name
,
version
)
cmd
+=
'
%
s'
%
_get_full_name
(
name
,
version
)
elif
requirements
:
elif
requirements
:
cmd
+=
' -r
%
s'
%
requirements
cmd
+=
' -r
%
s'
%
requirements
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
this_dir
=
tempfile
.
gettempdir
()
this_dir
=
tempfile
.
gettempdir
()
if
chdir
:
if
chdir
:
this_dir
=
os
.
path
.
join
(
this_dir
,
chdir
)
this_dir
=
os
.
path
.
join
(
this_dir
,
chdir
)
if
module
.
check_mode
:
if
env
or
extra_args
or
requirements
or
state
==
'latest'
or
not
name
:
module
.
exit_json
(
changed
=
True
)
elif
name
.
startswith
(
'svn+'
)
or
name
.
startswith
(
'git+'
)
or
\
name
.
startswith
(
'hg+'
)
or
name
.
startswith
(
'bzr+'
):
module
.
exit_json
(
changed
=
True
)
freeze_cmd
=
'
%
s freeze'
%
pip
rc
,
out_pip
,
err_pip
=
module
.
run_command
(
freeze_cmd
,
cwd
=
this_dir
)
if
rc
!=
0
:
module
.
exit_json
(
changed
=
True
)
out
+=
out_pip
err
+=
err_pip
is_present
=
_is_present
(
name
,
version
,
out
.
split
())
changed
=
(
state
==
'present'
and
not
is_present
)
or
(
state
==
'absent'
and
is_present
)
module
.
exit_json
(
changed
=
changed
,
cmd
=
freeze_cmd
,
stdout
=
out
,
stderr
=
err
)
rc
,
out_pip
,
err_pip
=
module
.
run_command
(
cmd
,
path_prefix
=
path_prefix
,
cwd
=
this_dir
)
rc
,
out_pip
,
err_pip
=
module
.
run_command
(
cmd
,
path_prefix
=
path_prefix
,
cwd
=
this_dir
)
out
+=
out_pip
out
+=
out_pip
err
+=
err_pip
err
+=
err_pip
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment