Skip to content

Commit f8febf5

Browse files
committed
Remove 'venv sync' command
1 parent cf247bc commit f8febf5

File tree

6 files changed

+4
-95
lines changed

6 files changed

+4
-95
lines changed

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,12 @@ matplotlib
126126
The `-r requirements.txt` will make sure that installing development requirements also install production requirements.
127127

128128
## Reproducing environment
129-
To install a reproducible environment, you need to install from a `.lock`-file, since those have all versions of all requirements locked[^1]. From a clean environment (no packages installed yet), run
129+
To install a reproducible environment, you need to install from a `.lock`-file, since those have all versions of all requirements locked[^1]:
130130
```console
131131
$ venv install requirements.lock
132132
```
133133

134-
If you don't have a clean environment, but still want to recreate the environment as it was when the requirements were locked, you can run
135-
```console
136-
$ venv sync requirements.lock
137-
```
138-
139-
This will first remove all installed packages, then run `venv install requirements.lock`.
140-
141-
**NOTE: Since this command is meant to create a reproducable environment, you cannot `sync` to a `.txt` file; it has to be a `.lock` file.**
134+
This will first clear the environment of any installed packages, then install the packages and versions specified in `requirements.lock`.
142135

143136
## Clearing the environment
144137
If you want to manually clear the environment, you can run

src/venv-cli/completions/bash/venv_completion.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ _venv() {
55
cur_word="${COMP_WORDS[COMP_CWORD]}"
66
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
77

8-
_subcommands="activate clear create deactivate install lock sync"
8+
_subcommands="activate clear create deactivate install lock"
99
subcommands=( $(compgen -W "${_subcommands}" -- "${cur_word}") )
1010
help_options=( $(compgen -W "-h --help" -- "${cur_word}") )
1111

@@ -51,12 +51,6 @@ _venv() {
5151
COMPREPLY+=( ${help_options[*]} )
5252
compopt -o plusdirs +o nosort # Add directories after generated completions
5353
;;
54-
"sync")
55-
# Generate completions for lock file paths
56-
COMPREPLY+=( $(compgen -f -X '!*.lock' -- "${cur_word}" | sort) )
57-
COMPREPLY+=( ${help_options[*]} )
58-
compopt -o plusdirs +o nosort # Add directories after generated completions
59-
;;
6054
"activate"|"deactivate"|"clear")
6155
# Only generate help options
6256
COMPREPLY+=( ${help_options[*]} )

src/venv-cli/completions/zsh/venv_completion.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local curcontext="${curcontext}" state line
44
typeset -A opt_args
55

66
# List of available options
7-
local -a subcommands=("create" "activate" "install" "lock" "clear" "sync" "deactivate" "-V" "--version")
7+
local -a subcommands=("create" "activate" "install" "lock" "clear" "deactivate" "-V" "--version")
88
local -a command_options=("-h" "--help")
99
local -a all=("${subcommands[@]} ${command_options[@]}")
1010

src/venv-cli/venv.sh

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -302,47 +302,6 @@ venv::clear() {
302302
}
303303

304304

305-
venv::sync() {
306-
if venv::_check_if_help_requested "$1"; then
307-
echo "venv sync [<lock file>]"
308-
echo
309-
echo "Remove all installed packages from the environment (venv clear)"
310-
echo "and install all packages specified in <lock file>."
311-
echo "The <lock file> must be in the form '*requirements.lock'."
312-
echo
313-
echo "If no <lock file> is specified, defaults to 'requirements.lock'."
314-
echo
315-
echo "Examples:"
316-
echo "$ venv sync dev-requirements.lock"
317-
echo "Clears the environment and installs requirements from 'dev-requirements.lock'."
318-
echo
319-
echo "$ venv sync"
320-
echo "Tries to install from 'requirements.lock'."
321-
echo "Clears the environment and installs requirements from 'requirements.lock'."
322-
return "${_success}"
323-
fi
324-
325-
local lock_file
326-
if [ -z "$1" ]; then
327-
# If no argument passed
328-
lock_file="requirements.lock"
329-
330-
# If full lock file passed
331-
else
332-
if ! venv::_check_lock_requirements_file "$1" "Can only sync using .lock file"; then
333-
return "${_fail}"
334-
fi
335-
336-
lock_file="$1"
337-
shift
338-
fi
339-
340-
venv::clear
341-
venv::install "${lock_file}" "$@"
342-
return "$?" # Return exit status from venv::install command
343-
}
344-
345-
346305
venv::help() {
347306
echo "Utility to help create and manage python virtual environments."
348307
echo "Lightweight wrapper around pip and venv."
@@ -356,8 +315,6 @@ venv::help() {
356315
echo "install Install requirements from a requirements file in the current environment"
357316
echo "lock Lock installed requirements in a '.lock'-file"
358317
echo "clear Remove all installed packages in the current environment"
359-
echo "sync Run 'venv clear', then install locked requirements from a"
360-
echo " '.lock'-file in the current environment"
361318
echo "deactivate Deactivate the currently activated virtual environment"
362319
echo "-h, --help Show this help and exit"
363320
echo "-v, --version Show the venv-cli version number and exit"
@@ -383,7 +340,6 @@ venv::main() {
383340
| install \
384341
| lock \
385342
| clear \
386-
| sync \
387343
| deactivate \
388344
)
389345
shift

tests/test_venv_help.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_venv_help(arg: str, tmp_path: Path, capfd: pytest.CaptureFixture):
2626
"install",
2727
"lock",
2828
"clear",
29-
"sync",
3029
],
3130
)
3231
@pytest.mark.parametrize("help_arg", ["-h", "--help"])

tests/test_venv_sync.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)