Skip to content

Commit cb35f49

Browse files
Merge 1d19a7c into master
2 parents 2d4624e + 1d19a7c commit cb35f49

File tree

6 files changed

+190
-136
lines changed

6 files changed

+190
-136
lines changed

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
# 4.2
2+
3+
- Trying to `call` a non-existent file now prints a short error message
4+
instead of an exception
5+
- A message about a nonexistent environment displays a hint on how to create it
6+
17
# 4.1
28

3-
- fixed: `$VIENDIR` did not change the storage directory of the virtual
9+
- Fixed: `$VIENDIR` did not change the storage directory of the virtual
410
environments
511

612
# 4.0
713

814
- "call" command added
9-
- new versioning scheme
10-
- fixed: the 'run' command could be run when the virtual environment does not
15+
- New versioning scheme
16+
- Fixed: the 'run' command could be run when the virtual environment does not
1117
exist
1218

1319
# 0.3.7
1420

15-
- fixed: "run" and "shell" commands returned exit code 0 regardless of the exit
21+
- Fixed: "run" and "shell" commands returned exit code 0 regardless of the exit
1622
code of the child process

README.md

Lines changed: 77 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,30 @@ $ pip3 install vien --upgrade
9595

9696
# Use
9797

98-
## Create a virtual environment
98+
### Example: interactive shell
99+
100+
``` bash
101+
$ cd /path/to/myProject
102+
$ vien create
103+
$ vien shell
104+
```
105+
106+
### Example: running commands
107+
108+
``` bash
109+
$ cd /path/to/myProject
110+
$ vien create
111+
$ vien run pip install --upgrade pip
112+
$ vien run pip install requests lxml
113+
$ vien call main.py
114+
```
115+
116+
# Commands
117+
118+
## create
119+
120+
`vien shell` creates a virtual environment corresponding to the working
121+
directory.
99122

100123
``` bash
101124
$ cd /path/to/myProject
@@ -105,12 +128,10 @@ $ vien create
105128
By default `vien` will try to use `python3` as the interpreter for the virtual
106129
environment.
107130

108-
<details>
109-
<summary>If you have
110-
more than one Python version, provide one more argument.</summary><br/>
111-
Point to the proper interpreter the way you execute it.
131+
If you have more than one Python version, provide one more argument,
132+
point to the proper interpreter the way you execute it.
112133

113-
If you execute scripts like that
134+
E.g. if you execute scripts like that
114135

115136
``` bash
116137
$ python3.8 /path/to/script.py
@@ -128,9 +149,11 @@ Or provide full path to the interpreter:
128149
$ vien create /usr/local/opt/python@3.8/bin/python3
129150
```
130151

131-
</details>
132152

133-
## Dive into interactive bash
153+
154+
## shell
155+
156+
`vien shell` starts interactive bash session in the virtual environment.
134157

135158
```bash
136159
$ cd /path/to/myProject
@@ -159,9 +182,9 @@ $ _
159182

160183
Now you're back.
161184

162-
## Run a script inside the virtual environment
185+
## run
163186

164-
It is `vien run <any bash command>`
187+
`vien run COMMAND` runs any shell command in the virtual environment.
165188

166189
```bash
167190
$ cd /path/to/myProject
@@ -186,56 +209,76 @@ $ /path/to/the/venv/bin/deactivate
186209

187210
</details>
188211

189-
# Where are those virtual environments
190-
191-
`vien` offers a simple rule of where to keep the environments.
192-
193-
|project dir|virtual environment dir|
194-
|-----|----|
195-
|`/abc/thisProject`|`$HOME/.vien/thisProject_venv`|
196-
|`/abc/otherProject`|`$HOME/.vien/otherProject_venv`|
197-
|`/moved/to/otherProject`|`$HOME/.vien/otherProject_venv`|
198-
199-
So only the local name of the project directory matters. And all the virtual
200-
environments are in `$HOME/.vien`.
212+
## call
201213

202-
If you're not happy with the default, you can set the environment
203-
variable `VIENDIR`:
214+
`vien call PYFILE` executes a `.py` script in the virtual environment.
204215

205-
``` bash
206-
$ export VIENDIR="/x/y/z"
216+
```bash
217+
$ cd /path/to/myProject
218+
$ vien call main.py
207219
```
208220

209-
So for the project `aaa` the virtual environment will be located
210-
in `/x/y/z/aaa_venv`.
221+
The optional `-p` parameter allows you to specify the project directory relative
222+
to the parent directory of the file being run.
211223

212-
The `_venv` suffix tells the utility that this directory can be safely removed.
224+
```bash
225+
$ cd any/where
226+
$ vien call -p /path/to/myProject main.py
227+
$ vien call -p . main.py
228+
```
213229

214-
# Other commands
230+
## delete
215231

216-
### Delete virtual environment
232+
`vien delete` deletes the virtual environment.
217233

218234
``` bash
219235
$ cd /path/to/myProject
220236
$ vien delete
221237
```
222238

223-
### Delete old and create new virtual environment
239+
## recreate
224240

225-
Useful, when you want to start from scratch.
241+
`vien recreate` old and creates new virtual environment.
242+
243+
If you decided to start from scratch:
226244

227245
``` bash
228246
$ cd /path/to/myProject
229247
$ vien recreate
230248
```
231249

232-
Or upgrade it from an old Python to a new one:
250+
If you decided to change the Python version:
233251

234252
``` bash
235253
$ cd /path/to/myProject
236254
$ vien recreate /usr/local/opt/python@3.10/bin/python3
237255
```
238256

257+
258+
# Virtual environments location
259+
260+
By default, `vien` places virtual environments in the `$HOME/.vien` directory.
261+
262+
|project dir|virtual environment dir|
263+
|-----|----|
264+
|`/abc/thisProject`|`$HOME/.vien/thisProject_venv`|
265+
|`/abc/otherProject`|`$HOME/.vien/otherProject_venv`|
266+
|`/moved/to/otherProject`|`$HOME/.vien/otherProject_venv`|
267+
268+
Only the local name of the project directory matters.
269+
270+
If you're not happy with the default, you can set the environment
271+
variable `VIENDIR`:
272+
273+
``` bash
274+
$ export VIENDIR="/x/y/z"
275+
```
276+
277+
So for the project `aaa` the virtual environment will be located
278+
in `/x/y/z/aaa_venv`.
279+
280+
The `_venv` suffix tells the utility that this directory can be safely removed.
281+
239282
# Shell prompt
240283

241284
By default the `vien shell` adds a prefix to
@@ -302,12 +345,3 @@ be anything.
302345
$ cd anywhere/somewhere
303346
$ /abc/myProject/pkg/main.py
304347
```
305-
306-
Of course, the virtual environment must be initialized if it is not already done
307-
308-
``` bash
309-
$ cd /abc/myProject
310-
$ vien create
311-
$ vien shell
312-
$ pip install ...
313-
```

0 commit comments

Comments
 (0)