@@ -95,7 +95,30 @@ $ pip3 install vien --upgrade
95
95
96
96
# Use
97
97
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.
99
122
100
123
``` bash
101
124
$ cd /path/to/myProject
@@ -105,12 +128,10 @@ $ vien create
105
128
By default ` vien ` will try to use ` python3 ` as the interpreter for the virtual
106
129
environment.
107
130
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.
112
133
113
- If you execute scripts like that
134
+ E.g. if you execute scripts like that
114
135
115
136
``` bash
116
137
$ python3.8 /path/to/script.py
@@ -128,9 +149,11 @@ Or provide full path to the interpreter:
128
149
$ vien create /usr/local/opt/python@3.8/bin/python3
129
150
```
130
151
131
- </details >
132
152
133
- ## Dive into interactive bash
153
+
154
+ ## shell
155
+
156
+ ` vien shell ` starts interactive bash session in the virtual environment.
134
157
135
158
``` bash
136
159
$ cd /path/to/myProject
159
182
160
183
Now you're back.
161
184
162
- ## Run a script inside the virtual environment
185
+ ## run
163
186
164
- It is ` vien run < any bash command> `
187
+ ` vien run COMMAND ` runs any shell command in the virtual environment.
165
188
166
189
``` bash
167
190
$ cd /path/to/myProject
@@ -186,56 +209,76 @@ $ /path/to/the/venv/bin/deactivate
186
209
187
210
</details >
188
211
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
201
213
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.
204
215
205
- ``` bash
206
- $ export VIENDIR=" /x/y/z"
216
+ ``` bash
217
+ $ cd /path/to/myProject
218
+ $ vien call main.py
207
219
```
208
220
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 .
211
223
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
+ ```
213
229
214
- # Other commands
230
+ ## delete
215
231
216
- ### Delete virtual environment
232
+ ` vien delete ` deletes the virtual environment.
217
233
218
234
``` bash
219
235
$ cd /path/to/myProject
220
236
$ vien delete
221
237
```
222
238
223
- ### Delete old and create new virtual environment
239
+ ## recreate
224
240
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:
226
244
227
245
``` bash
228
246
$ cd /path/to/myProject
229
247
$ vien recreate
230
248
```
231
249
232
- Or upgrade it from an old Python to a new one :
250
+ If you decided to change the Python version :
233
251
234
252
``` bash
235
253
$ cd /path/to/myProject
236
254
$ vien recreate /usr/local/opt/python@3.10/bin/python3
237
255
```
238
256
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
+
239
282
# Shell prompt
240
283
241
284
By default the ` vien shell ` adds a prefix to
@@ -302,12 +345,3 @@ be anything.
302
345
$ cd anywhere/somewhere
303
346
$ /abc/myProject/pkg/main.py
304
347
```
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