You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: best_practice/python_environments.md
+2-59Lines changed: 2 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Working with Python Environments
6
6
7
7
## Managing Python Versions and Virtual Environments with uv
8
8
9
-
Most projects we work on require Python 3.8 or greater. A few projects may require an even later version. In either case it is necessary to be able to have multiple versions of Python installed and easily switch between them, as well as manage project-specific dependencies. We use [uv](https://github.com/astral-sh/uv) to handle both Python version management and virtual environments.
9
+
Most projects we work on require Python 3.9 or greater. Many require a later version. In either case it is necessary to be able to have multiple versions of Python installed and easily switch between them, as well as manage project-specific dependencies. We use [uv](https://github.com/astral-sh/uv) to handle both Python version management and virtual environments.
10
10
11
11
### Installing uv
12
12
@@ -259,21 +259,6 @@ Install from a requirements file:
259
259
uv pip sync requirements.txt
260
260
```
261
261
262
-
### Environment Variables
263
-
264
-
Useful environment variables for uv:
265
-
266
-
-`UV_PYTHON`: Set default Python version
267
-
-`UV_INDEX_URL`: Set custom package index
268
-
-`UV_CACHE_DIR`: Set cache directory location
269
-
-`UV_SYSTEM_PYTHON`: Use system Python instead of managed versions
270
-
271
-
Example:
272
-
273
-
```shell
274
-
UV_PYTHON=3.11 uv sync
275
-
```
276
-
277
262
## Migrating from Other Tools
278
263
279
264
### From pip/venv
@@ -299,51 +284,9 @@ To fully migrate, you may want to:
299
284
2. Delete `poetry.lock`
300
285
3. Run `uv sync` to generate `uv.lock`
301
286
302
-
### From pipenv
303
-
304
-
Convert `Pipfile` to `pyproject.toml` then:
305
-
306
-
```shell
307
-
uv sync
308
-
```
309
-
310
-
## Best Practices
311
-
312
-
1.**Always commit `uv.lock`**: This ensures reproducible builds across all environments
313
-
2.**Use `.python-version` files**: Pin Python versions per project with `uv python pin`
314
-
3.**Specify version bounds carefully**: Use `>=` for minimum versions, `<` for maximum
315
-
4.**Separate dev dependencies**: Use `--dev` flag for development-only packages
316
-
5.**Use dependency groups**: Organize optional dependencies (docs, testing, etc.)
0 commit comments