Skip to content

Preset for development on Python using uv on VSCode.

License

Notifications You must be signed in to change notification settings

Yoshida24/preset-python-uv-vscode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

badge badge badge badge

Open in GitHub Codespaces

preset-python-uv-vscode

Preset for develop Python app by uv.

Included

  • Auto format on save by ruff
  • Task runner by make
  • Jupyter Notebook support
  • Env support

Usage

  • Python: 3.12
  • uv: 0.6.2
  • OS and Device: M1 Macbook Air Sequoia 15.3.1

Prerequest

Install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc

Gettig Started

First of all, install VSCode recommended extensions. This includes Linter, Formatter, and so on. Recommendation settings is written on .vscode/extensions.json.

Install dependencies:

uv sync

To use environment variables in .env file, run below script to create .env

if [ ! -f .env ]; then
    cp .env.tmpl .env
    echo 'Info: .env file has successfully created. Please rewrite .env file'
else
    echo 'Info: Skip to create .env file. Because it is already exists.'
fi

Now you can run script:

# load environment variables from .env to your shell.
set -a && source ./.env && set +a
make run
  ____________
| Hello, Alan! |
  ============
            \
             \
               ^__^
               (oo)\_______
               (__)\       )\/\
                   ||----w |
                   ||     ||

Note

This project does not depends on dotenv-python. Instead, using below script. set -a && source ./.env && set +a

Use Jupyter

In VSCode, src/notebook.ipyenv can be used with .venv automatically.

Serve Juyter server:

uv run --with jupyter jupyter lab
# Then automatically open http://localhost:8888/lab

Cheat Sheet

Add dependencies:

uv add requests

Add dev dependencies:

uv add --dev ruff

Pin python version:

uv python pin 3.12

Update uv:

uv self update

About

Preset for development on Python using uv on VSCode.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published