Skip to content

Comments

add PEP 723 script detection and activation#11

Open
Weidav wants to merge 2 commits intoteticio:mainfrom
Weidav:main
Open

add PEP 723 script detection and activation#11
Weidav wants to merge 2 commits intoteticio:mainfrom
Weidav:main

Conversation

@Weidav
Copy link

@Weidav Weidav commented Feb 13, 2026

Added PEP 723 support as requested in #10
Checks for PEP 723 compatible scripts and, searches for the venv path by running uv python find --script an activates tit.

@teticio
Copy link
Owner

teticio commented Feb 16, 2026

Hi

First of all, thanks for picking this up and doing the work. I've been recovering from a motorcycle accident for a while, so I didn't get around to looking into it.

I have to say, I'm not completely convinced it makes sense to do this. It feels like it is a bit at odds with the purpose of the extension. I can only think of a use case where you have a script depending on a venv that is managed outside of the project that you want to debug for some reason, so you click on it and run "Debug Python File" and it loads the correct venv. Can you help me understand the use cases better?

I will leave this open for the time being. If anyone else coming here thinks this is useful, please let me know and ideally help me to understand how.

Thanks

@Weidav
Copy link
Author

Weidav commented Feb 17, 2026

Oh man, I wish you a speedy and mainly full recovery 🍀

After switching to uv I was looking for a way to automatically activate the corresponding venv. I always had to manually select the venv. I work in a repo with multiple python applications / packages and many scripts

I found your Extension and thought it is made for uv, but I just checked the readme and you never mention it. But still your extension works great for python projects/application's/packages where the venv is created in the projects directory. This way of handling venv's was introduced to me when i switched to uv, I don't know how other all-in-one package managers (poetry, hatch) manage venvs.

Then there are scripts and PEP 723 allows inline metadata, usually to declare script dependencies. uv promotes this for scripts, but for some reason stores the venv in the it's cache directory. That's when your extension doesn't find the venv and won't activate it. That's where my PR comes in and find's the venv using uv python find --script to find and activate it.

Long story short:

  • If your extension is meant to work universally and isn't meant to be uv-specific, close the PR
  • If you want to focus on uv, than this PR is worth reviewing and merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants