https://github.com/nsarrazin/pep723-uv-interpreter
A VSCode extension that automatically discovers and sets the Python interpreter for scripts with inline script metadata
https://github.com/nsarrazin/pep723-uv-interpreter
723 python script uv vscode vscode-extension
Last synced: 2 months ago
JSON representation
A VSCode extension that automatically discovers and sets the Python interpreter for scripts with inline script metadata
- Host: GitHub
- URL: https://github.com/nsarrazin/pep723-uv-interpreter
- Owner: nsarrazin
- License: mit
- Created: 2025-07-12T17:38:06.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-07-24T22:09:10.000Z (3 months ago)
- Last Synced: 2025-07-25T01:45:21.981Z (3 months ago)
- Topics: 723, python, script, uv, vscode, vscode-extension
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=nsarrazin.pep723-uv-interpreter
- Size: 156 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PEP723 Interpreter Picker
A Visual Studio Code extension that automatically discovers and sets the Python interpreter for PEP 723–style scripts (with `# /// script` headers) using `uv python find --script`.
### Features
- Detects PEP 723 script headers in Python files
- Runs `uv python find --script` to locate the appropriate interpreter
- Updates `python.defaultInterpreterPath` in your workspace folder settings
- Optionally auto-runs on file open or switching editors### Prerequisites
- [uv](https://github.com/jaraco/uv) installed and on your `PATH`
> [!WARNING]
> You must run the script yourself once in order for `uv` to create the environment so the extension can find it. You also need to run the script when updating dependencies to ensure they get picked up.### Installation
#### From the Marketplace
1. Open VS Code and go to the Extensions view (`Ctrl+Shift+X`).
2. Search for **PEP723 Interpreter Picker** and click **Install**.#### From a VSIX
1. Download the `.vsix` file from the releases page.
2. In VS Code, open the Command Palette (`Ctrl+Shift+P`) and choose **Extensions: Install from VSIX...**
3. Select the downloaded file and install.### Usage
1. Open or switch to a Python file containing a PEP 723 header, for example:
```python
# /// script
# requires-python = ">=3.11"
# dependencies = ["requests"]
# ///import requests
print("Hello, PEP 723!")
```2. The extension will automatically run `uv python find --script` in your workspace root.
3. It updates your workspace’s Python interpreter setting to the discovered path.#### Manual Trigger
If you prefer not to auto-run, you can manually invoke the command:
1. Open the Command Palette (`Ctrl+Shift+P`).
2. Run **PEP723: Pick Interpreter**.### Configuration
- `pep723.enableAutoPick` (boolean, default `true`)
- Enable or disable automatic interpreter picking on file open or switch.### Development
1. Clone the repo:
```bash
git clone https://github.com/your-name/pep723-interpreter.git
cd pep723-interpreter
```2. Install dependencies:
```bash
npm install
```3. Compile TypeScript:
```bash
npm run compile
```4. Open in VS Code and press `F5` to launch the Extension Development Host.
### Publishing
1. Update the version in `package.json`.
2. Log in with your publisher name:```bash
vsce login
```3. Publish:
```bash
vsce publish
```### Contributing
Contributions are welcome! Please open issues or submit pull requests for bug fixes and enhancements.
### License
MIT License. See [LICENSE](LICENSE) for details.