Skip to content

Commit d9a91d9

Browse files
committed
Format README and CHANGELOG
1 parent 18ae8d4 commit d9a91d9

2 files changed

Lines changed: 65 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Changelog
22

33
## Unreleased
4+
45
* The project is now following the [Github Flow](https://docs.github.com/en/get-started/using-github/github-flow) branching model. The `main` branch is now the default branch, and the `develop` branch has been removed. Future development should create a new branch directly from `main`, and when done, creating a pull request back into `main`. Releases should be tagged directly on `main` as well.
56

67
## [v2.0.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v2.0.0) (2024-03-06)
78

89
### Breaking changes
10+
911
* `venv install` can now be used to install individual packages: `venv install <package>`. [#37](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/37)
1012

1113
To enable this feature, installing from a requirements file now requires the use of the new `-r | --requirement` flags: `venv install -r requirements.txt`. Packages installed using `venv install <package>` are first added to the requirements file before reinstalling the entire environment to ensure reproducibility. To uninstall packages, use the new `venv uninstall` subcommand, e.g. `venv uninstall <package>`.
1214
* `venv sync` has been removed. Use `venv install -r <requirements>.lock` instead. [#17](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/17)
1315

1416
### Major changes
17+
1518
* Added `venv uninstall` subcommand to complement the new functionality of `venv install <package>`. [#37](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/37)
1619

1720
Running `venv uninstall <package>` will first remove the package from `requirements.txt`, then use `venv install -r requirements.txt` to reinstall the environment without `<package>`.
@@ -20,17 +23,20 @@
2023
* Loosened the file name requirements for `requirements` files. Requirements files can now be any valid file name with the extension `.txt` (`.lock` for lock files). [#35](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/35)
2124

2225
### Minor changes
26+
2327
* The `install.sh` script now supports specifying for which shell to install `venv-cli`, e.g. `./install.sh zsh`. [#29](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/29)
2428
* Updated virtual environment activation instructions in `README.md` and when running `venv activate -h` [#37](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/37)
2529
* Refactored bash completion script to enable better handling of arguments for subcommands. [8ac4daf](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/32/commits/8ac4daf89314f0ac2c1daf56bee9f4ac489f5004)
2630

2731
### Bug fixes
32+
2833
* Running the uninstall script now correctly removes the sourcing line from the user's `rc`-file. [#29](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/29)
2934
* Running the installation script now adds the sourcing line to the user's `rc`-file only if it is not there already. [#29](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/29)
3035
* Running `venv <subcommand>` now correctly returns the exit code from that subcommand. [8b7a54d](https://github.com/SallingGroup-AI-and-ML/venv-cli/commit/8b7a54db77e075760847dba8c12489e7fc4dbd4d)
3136
* Removed a unit test that was failing sporadically when running tests multiprocessed using `pytest-xdist`. [30c501c](https://github.com/SallingGroup-AI-and-ML/venv-cli/commit/30c501ce1ef43d151ceb22718de80dc9ea9c30ac)
3237

3338
### Internal changes
39+
3440
* Added several new test cases to cover loosened requirements file name check. [#35](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/35)
3541
* Removed unused test files. [8be87d9](https://github.com/SallingGroup-AI-and-ML/venv-cli/commit/8be87d95a75f5b532eaf1fd062796674ce7a764c)
3642
* Updated test cases for `venv clear` and `venv lock` that use the `venv install` command. [6985681](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/32/commits/6985681a3b3ac8ae783406e1b76401b7075ea260)
@@ -39,61 +45,74 @@
3945
## [v1.5.1](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.5.1) (2024-01-10)
4046

4147
### Minor changes
48+
4249
* `venv install` now fails early and with a more descriptve error message when run outside of a virtual environment. [#31](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/31)
4350

4451
### Bug fixes
52+
4553
* `venv clear` is now able to clear virtual environments that contain editable installs. [#31](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/31)
4654

4755
## [v1.5.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.5.0) (2024-01-04)
4856

4957
### Major changes
58+
5059
* Added `venv delete` command. [#25](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/25)
5160

5261
Running `venv delete` completely removes the virtual environment located in the current folder.
5362

5463
### Minor changes
64+
5565
* Added `-s` alias for `--skip-lock` when running `venv install`. [#24](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/24)
5666

5767
### Internal changes
68+
5869
* The `run_command` test helper function can now pass through inputs to the command that is being run.
5970

6071
## [v1.4.1](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.4.1) (2023-10-30)
6172

6273
### Bugfixes
74+
6375
* Fixed `venv lock` failing to lock when called as part of `venv install`. [#21](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/21)
6476

6577
## [v1.4.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.4.0) (2023-10-30)
6678

6779
### Minor changes
80+
6881
* `venv install` now runs `venv clear` before installation. This ensures that the enrivonment doesn't end up with orphaned packages after making changes to `requirements.txt`. [#9](https://github.com/SallingGroup-AI-and-ML/venv-cli/issues/9)
6982

7083
## Minor changes
84+
7185
* `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)
7286

7387
## [v1.3.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.3.0) (2023-10-30)
7488

7589
## Major changes
90+
7691
* `venv lock` no longer tries to fill in credentials for packages installed via VCS. This behavior was undocumented and difficult to maintain and ultimately tried to alleviate a shortcoming of the way `pip` handles these credentials. [#11](https://github.com/SallingGroup-AI-and-ML/venv-cli/pull/11)
77-
For users who have credentials as part of URLs in their `requirements.txt` files, there are other ways to handle credentials, e.g. filling them in `requirements.lock` manually, using a `.netrc` file to store the credetials or using a keyring. See https://pip.pypa.io/en/stable/topics/authentication/ for more info.
92+
For users who have credentials as part of URLs in their `requirements.txt` files, there are other ways to handle credentials, e.g. filling them in `requirements.lock` manually, using a `.netrc` file to store the credetials or using a keyring. See [https://pip.pypa.io/en/stable/topics/authentication](https://pip.pypa.io/en/stable/topics/authentication) for more info.
7893

7994
### Minor changes
95+
8096
* `venv create` now prints the full python version used for creating the environment. [bb62c21](https://github.com/SallingGroup-AI-and-ML/venv-cli/commit/bb62c216cbad2fcec06bfb1cde8b875dbfc237d3)
8197

8298
### Internal changes
99+
83100
* Added `pytest-cases` to development dependencies.
84101

85102
## [v1.2.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.2.0) (2023-08-04)
86103

87104
From this release forward, this project follows the `Git Flow` branching model. To reflect this, the default development branch have been renamed `develop`, and the `main` branch is now only for tagged releases.
88-
To read more about Git Flow, see (https://nvie.com/posts/a-successful-git-branching-model/). Also see [README](https://github.com/SallingGroup-AI-and-ML/venv-cli/blob/v1.2.0/README.md#git-flow) for branch naming conventions.
105+
To read more about Git Flow, see [https://nvie.com/posts/a-successful-git-branching-model](https://nvie.com/posts/a-successful-git-branching-model). Also see [README](https://github.com/SallingGroup-AI-and-ML/venv-cli/blob/v1.2.0/README.md#git-flow) for branch naming conventions.
89106

90107
* Changed github test workflow to reflect new branch naming conventions.
91108
* Added better, context-based bash completions.
92109

93110
## [v1.1.0](https://github.com/SallingGroup-AI-and-ML/venv-cli/releases/tag/v1.1.0) (2023-08-02)
94111

95112
### New install script
113+
96114
This release adds an `install.sh` script for easier installation of `venv-cli`. Now it can be installed by simply running
115+
97116
```console
98117
$ bash install.sh
99118
```

README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[![Linting and tests](https://github.com/SallingGroup-AI-and-ML/venv-cli/actions/workflows/run_tests.yml/badge.svg)](https://github.com/SallingGroup-AI-and-ML/venv-cli/actions/workflows/run_tests.yml)
22
![GitHub License](https://img.shields.io/github/license/SallingGroup-AI-and-ML/venv-cli)
33

4-
# venv-cli - A CLI tool to create and manage virtual python environments.
4+
# venv-cli - A CLI tool to create and manage virtual python environments
55

66
## Overview
7+
78
`venv-cli` is a CLI tool to help create and manage virtual python environments.
89
It is built on `pip` and `python -m venv`, and so only requires packages that are already part of the core python installation; no third-party python packages required. This alleviates the bootstrapping problem of needing to install a python package using your system `python` and `pip` before you are able to create virtual environments.
910

@@ -12,40 +13,52 @@ You also don't need `conda`, `pyenv`, `pythonz` etc. to manage your python versi
1213
## Installation
1314

1415
Clone this repository, then run the `install.sh` script:
16+
1517
```console
1618
$ ./install.sh
1719
```
20+
1821
This will install the `venv` source file, along with an uninstall script, in `/usr/local/share/venv/`, and add a line in the appropriate shell `rc`-file (e.g. `~/.bashrc`) sourcing the `venv` source script.
1922

2023
The default shell is `bash`. To install for a different shell, specify the shell name, e.g.
24+
2125
```console
2226
$ ./install.sh zsh
2327
```
2428

2529
The installation makes the `venv` command available in your terminal. To check if it works, restart the terminal and run
30+
2631
```console
2732
$ venv --version
2833
venv-cli 1.0.0
2934
```
3035

3136
# Uninstall
37+
3238
To uninstall `venv` and remove all files, run the uninstall script placed at `/usr/local/share/venv/`:
39+
3340
```console
3441
$ bash /usr/local/share/venv/uninstall.sh
3542
```
43+
3644
The script should be run by the user that ran the install script to correctly remove the sourcing lines from the `rc`-file of that user. However, since it also cleans up the files in `/usr/share/local/venv/`, it will ask for `sudo` access.
3745

3846
## Usage
3947

4048
To see the help menu, along with a list of available commands, run `venv -h/--help`.
4149

4250
**In the following sections it is assumed that the working directory is the folder `~/project`.**
51+
4352
### Create virtual environment
53+
4454
To create a virtual environment, use the command
55+
4556
```console
4657
$ venv create <python-version>
4758
```
59+
4860
e.g.
61+
4962
```console
5063
$ venv create 3.9
5164
```
@@ -57,28 +70,37 @@ $ venv create 3.9 venv-name
5770
```
5871

5972
If you don't have the specific version of python installed yet, you can get it by running
73+
6074
```console
6175
$ sudo apt install python<version>
6276
```
77+
6378
e.g.
79+
6480
```console
6581
$ sudo apt install python3.10
6682
```
83+
6784
(or in the case of Debian-based distributions, like Ubuntu, `sudo apt install python3.10-venv`. The `-venv` part is necessary to be able to use the system python to create virtual environments.)
6885

6986
## Activating and deactivating the virtual environment
87+
7088
To activate the virtual environment, place yourself _in the folder containing_ the `.venv` folder, then run
89+
7190
```console
7291
$ venv activate
7392
```
7493

7594
To deactivate it again, run
95+
7696
```console
7797
$ venv deactivate
7898
```
7999

80100
## Install/uninstall packages and requirements
101+
81102
To install a single package, simply run
103+
82104
```console
83105
$ venv install <package>
84106
```
@@ -93,23 +115,31 @@ Unlike `pip install <package>`, which leaves no trace, this ensures that the `re
93115
In the same spirit, `venv uninstall <package>` first removes the package from `requirements.txt`, then runs `venv install -r requirements.txt` to reinstall the environment from scratch. Unlike `pip uninstall <package>`, this ensures that the uninstall does not leave any "orphaned" packages in the current environment (packages that were installed as secondary dependencies, but are no longer needed since the primary dependency has been uninstalled).
94116

95117
### Requirements files
118+
96119
To specify a different requirements file to install to/uninstall from, use `-r <requirements>` :
120+
97121
```console
98122
$ venv install numpy 'pandas >= 2.0' -r core.txt
99123
```
124+
100125
This will add `numpy` and `pandas >= 2.0` as requirements in `core.txt`, then install from that file. Similarly,
126+
101127
```console
102128
$ venv uninstall pandas -r core.txt
103129
```
130+
104131
will remove the `pandas >= 2.0` requirement from `core.txt` again, then reinstall the environment using the updated `core.txt`.
105132

106133
### Lock files
134+
107135
When installing or uninstalling packages, the resulting environment is _locked_ into a corresponding `.lock`-file, e.g. running `venv install -r requirements.txt` will lock the installed packages into `requirements.lock`[^1].
108136

109137
This file is useful if a reproducible install is needed, e.g. when deploying a project to a different machine, or when running a colleagues project. Where `requrements.txt` is used to specify the packages and version your project _needs_ (and nothing more), installing from `requirements.lock` makes sure that you get the exact version of every package.
110138

111139
### Additional requirements
140+
112141
If you have both production and development package requirements, keep them in separate requirements-files, e.g. `requirements.txt` for production requirements and `test.txt` for requirements needed when running tests. An example of these could be:
142+
113143
```bash
114144
# requirements.txt
115145
numpy
@@ -123,19 +153,23 @@ pytest-cov
123153
```
124154

125155
You can then use either
156+
126157
```console
127158
$ venv install -r requirements.txt
128159
```
129160

130161
To install production requirements only, or
162+
131163
```console
132164
$ venv install -r test.txt
133165
```
134166

135167
to install both production and test requirements. The `-r requirements.txt` in `test.txt` is what makes sure that installing test requirements also installs the requirements from `requirements.txt`.
136168

137169
## Clearing the environment
170+
138171
If you want to manually clear the environment, you can run
172+
139173
```console
140174
$ venv clear
141175
```
@@ -151,28 +185,35 @@ $ venv install requirements.txt
151185
```
152186

153187
## Deleting the environment
188+
154189
To completely delete the virtual environment and everything in it, run
190+
155191
```console
156192
$ venv delete
157193
```
158194

159195
(this will not delete any requirement or .lock-files). This will ask for confirmation before deleting the virtual environment. To give immediate confirmation, pass the `-y` flag:
196+
160197
```console
161198
$ venv delete -y
162199
```
163200

164201
## Contributing
202+
165203
Before creating a pull request, please open an issue first to discuss what you would like to change.
166204

167205
To contribute, clone the repo and create a branch, create a virtual environment and install `dev-requirements.txt`. When you are done with your changes, run the test suite with
206+
168207
```console
169208
$ pytest .
170209
```
210+
171211
then create a pull request for the `main` branch.
172212

173213
Every (public) subcommand has its own test file `tests/test_venv_<command>.py` Please make sure to add/update tests as appropriate.
174214

175215
### Branches
216+
176217
When creating a new branch, please prefix them with one of the following:
177218

178219
```
@@ -199,5 +240,5 @@ Then commit the changes, push to `main`, and create a new release on GitHub with
199240

200241
[MIT](https://choosealicense.com/licenses/mit/)
201242

202-
[^1]: A current limitation of using `pip freeze` under the hood is that installing packages from a version control system (VCS) URL that requires authentication, e.g. `private_package @ git+https://USERNAME:PASSWORD@github.com/my-user/private-package`, the authentication is not locked (see https://github.com/pypa/pip/issues/12365).
203-
These credentials can either be inserted manually into the generated `.lock`-file, or the credentials can instead be stored in a `.netrc` file, which `pip install` will then reference when running `pip install`: https://pip.pypa.io/en/stable/topics/authentication/#netrc-support
243+
[^1]: A current limitation of using `pip freeze` under the hood is that installing packages from a version control system (VCS) URL that requires authentication, e.g. `private_package @ git+https://USERNAME:PASSWORD@github.com/my-user/private-package`, the authentication is not locked (see [https://github.com/pypa/pip/issues/12365](https://github.com/pypa/pip/issues/12365)).
244+
These credentials can either be inserted manually into the generated `.lock`-file, or the credentials can instead be stored in a `.netrc` file, which `pip install` will then reference when running `pip install`: [https://pip.pypa.io/en/stable/topics/authentication/#netrc-support](https://pip.pypa.io/en/stable/topics/authentication/#netrc-support)

0 commit comments

Comments
 (0)