Skip to content

Commit

Permalink
Make pip.* operation virtualenv management idempotent.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Apr 26, 2021
1 parent a53829b commit f5989d4
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
7 changes: 7 additions & 0 deletions pyinfra/operations/pip.py
Expand Up @@ -43,6 +43,7 @@ def virtualenv(
if present is False:
if host.fact.file(activate_script_path):
yield files.directory(path, present=False, state=state, host=host)
host.fact._delete('file', args=(activate_script_path,))
else:
host.noop('virtualenv {0} does not exist'.format(path))

Expand All @@ -68,6 +69,12 @@ def virtualenv(
command.append(path)

yield ' '.join(command)

host.fact._create(
'file',
args=(activate_script_path,),
data={'user': None, 'group': None},
)
else:
host.noop('virtualenv {0} exists'.format(path))

Expand Down
Expand Up @@ -20,6 +20,5 @@
"commands": [
"virtualenv --system-site-packages testdir",
"testdir/bin/pip install elasticquery==1.1 flask"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.venv/add_virtualenv.json
Expand Up @@ -10,6 +10,5 @@
},
"commands": [
"python -m venv --copies /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/add_virtualenv.json
Expand Up @@ -9,6 +9,5 @@
},
"commands": [
"virtualenv /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/add_virtualenv_py3.json
Expand Up @@ -10,6 +10,5 @@
},
"commands": [
"virtualenv -p python3 /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/add_with_options.json
Expand Up @@ -12,6 +12,5 @@
},
"commands": [
"virtualenv -p python2 --system-site-packages --always-copy /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/present_empty_directory.json
Expand Up @@ -12,6 +12,5 @@
},
"commands": [
"virtualenv /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/use_stdlib_venv.json
Expand Up @@ -11,6 +11,5 @@
},
"commands": [
"python -m venv --copies /some/virtualenv"
],
"idempotent": false
]
}
3 changes: 1 addition & 2 deletions tests/operations/pip.virtualenv/use_stdlib_venv_py3.json
Expand Up @@ -11,6 +11,5 @@
},
"commands": [
"python3 -m venv /some/virtualenv"
],
"idempotent": false
]
}

0 comments on commit f5989d4

Please sign in to comment.