Skip to content

Commit d52b472

Browse files
authored
Remove 'venv sync' command (#17)
Closes #13
2 parents 131633f + 10731fe commit d52b472

File tree

7 files changed

+8
-101
lines changed

7 files changed

+8
-101
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

3-
## [Unreleased](https://github.com/SallingGroup-AI-and-ML/venv-cli/tree/develop)
3+
## [v2.0.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/tree/release/2.0)
4+
5+
### Major changes
6+
* `venv sync` has been removed. Use `venv install <requirements>.lock` instead. [#17](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/17)
47

58
### Minor changes
69
* `venv sync` command marked as deprecated with removal planned for `v2.0`. Use `venv install <requirements>.lock` instead. [#14](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/14)

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 & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -302,52 +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 "DEPRECATED: This command is deprecated and will be removed in version 2.0."
310-
echo "Use 'venv install <requirements.lock>' instead."
311-
echo ""
312-
echo "Remove all installed packages from the environment (venv clear)"
313-
echo "and install all packages specified in <lock file>."
314-
echo "The <lock file> must be in the form '*requirements.lock'."
315-
echo
316-
echo "If no <lock file> is specified, defaults to 'requirements.lock'."
317-
echo
318-
echo "Examples:"
319-
echo "$ venv sync dev-requirements.lock"
320-
echo "Clears the environment and installs requirements from 'dev-requirements.lock'."
321-
echo
322-
echo "$ venv sync"
323-
echo "Tries to install from 'requirements.lock'."
324-
echo "Clears the environment and installs requirements from 'requirements.lock'."
325-
return "${_success}"
326-
fi
327-
328-
venv::color_echo "${_yellow}" "DEPRECATED: This command is deprecated and will be removed in version 2.0. Use 'venv install <requirements.lock>' instead."
329-
330-
local lock_file
331-
if [ -z "$1" ]; then
332-
# If no argument passed
333-
lock_file="requirements.lock"
334-
335-
# If full lock file passed
336-
else
337-
if ! venv::_check_lock_requirements_file "$1" "Can only sync using .lock file"; then
338-
return "${_fail}"
339-
fi
340-
341-
lock_file="$1"
342-
shift
343-
fi
344-
345-
venv::clear
346-
venv::install "${lock_file}" "$@"
347-
return "$?" # Return exit status from venv::install command
348-
}
349-
350-
351305
venv::help() {
352306
echo "Utility to help create and manage python virtual environments."
353307
echo "Lightweight wrapper around pip and venv."
@@ -361,8 +315,6 @@ venv::help() {
361315
echo "install Install requirements from a requirements file in the current environment"
362316
echo "lock Lock installed requirements in a '.lock'-file"
363317
echo "clear Remove all installed packages in the current environment"
364-
echo "sync Run 'venv clear', then install locked requirements from a"
365-
echo " '.lock'-file in the current environment"
366318
echo "deactivate Deactivate the currently activated virtual environment"
367319
echo "-h, --help Show this help and exit"
368320
echo "-v, --version Show the venv-cli version number and exit"
@@ -388,7 +340,6 @@ venv::main() {
388340
| install \
389341
| lock \
390342
| clear \
391-
| sync \
392343
| deactivate \
393344
)
394345
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)