Preset for develop Python app by uv
.
- Auto format on save by ruff
- Task runner by make
- Jupyter Notebook support
- Env support
- Python: 3.12
- uv: 0.6.2
- OS and Device: M1 Macbook Air Sequoia 15.3.1
Install uv
:
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc
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
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
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