Skip to content

fix(python-plugin): add UV_PROJECT_ENVIRONMENT env variable #2659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/app/docs/devbox_examples/languages/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This will install Python 3.10 in your shell. You can find other versions of Pyth

The `python` package automatically comes bundled with `pip`, and the `python` plugin for Devbox will automatically create a virtual environment for installing your packages locally

Your virtual environment is created in the `.devbox/virtenv/python` directory by default, and can be activated by running `. $VENV_DIR/bin/activate` in your Devbox shell. You can activate the virtual environment automatically using the init_hook of your `devbox.json`:
Your virtual environment is created in the root directory of your project by default, and can be activated by running `. $VENV_DIR/bin/activate` in your Devbox shell. You can activate the virtual environment automatically using the init_hook of your `devbox.json`:

```json
{
Expand All @@ -46,7 +46,7 @@ For Fish or other shells, you may need to use a different activation script. See

:::

Devbox installs the virtual environment in `.devbox/virtenv/python/.venv` by default. You can modify this path by setting the `VENV_DIR` environment variable in your devbox.json:
Devbox installs the virtual environment in `$DEVBOX_PROJECT_ROOT/.venv` by default. You can modify this path by setting the `VENV_DIR` environment variable in your devbox.json:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion examples/development/python/pip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This will install Python 3.10 in your shell. You can find other versions of Pyth

You can install `pip` by running `devbox add python3xxPackages.pip`, where `3xx` is the version of Python you want to install. This will also install the pip plugin for Devbox, which automatically creates a virtual environment for installing your packages locally

Your virtual environment is created in the `.devbox/virtenv/pip` directory by default, and can be activated by running `. $VENV_DIR/bin/activate` in your devbox shell. You can activate the virtual environment automatically using the init_hook of your `devbox.json`:
Your virtual environment is created in the root directory of your project by default, and can be activated by running `. $VENV_DIR/bin/activate` in your devbox shell. You can activate the virtual environment automatically using the init_hook of your `devbox.json`:

```json
{
Expand Down
5 changes: 4 additions & 1 deletion plugins/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"{{ .Virtenv }}/bin/venvShellHook.sh": "python/venvShellHook.sh"
},
"shell": {
"init_hook": ["{{ .Virtenv }}/bin/venvShellHook.sh"]
"init_hook": [
"export UV_PROJECT_ENVIRONMENT=\"$VENV_DIR\"",
"{{ .Virtenv }}/bin/venvShellHook.sh"
]
}
}