Skip to content

Commit

Permalink
Switch to uv for package management.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhogg committed Sep 19, 2024
1 parent 1dd6c23 commit 66acc11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
venv:
python3 -m venv venv
source venv/bin/activate ; pip install --upgrade pip ; python3 -m pip install -r requirements-dev.txt
source venv/bin/activate ; pip freeze > requirements_freeze.txt
# Install uv on macOS and Linux:
# $ curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install -r requirements-dev.txt

# venv:
# python3 -m venv .venv
# source .venv/bin/activate ; pip install --upgrade pip ; python3 -m pip install -r requirements-dev.txt
# source .venv/bin/activate ; pip freeze > requirements_freeze.txt

clean:
rm -rf venv
rm -rf .venv

run:
source venv/bin/activate ; PYTHONPATH='./src' python -m app reqarg1
# source .venv/bin/activate ; PYTHONPATH='./src' python -m app reqarg1
uv run src/app.py reqarg1

jupyter:
source venv/bin/activate; PYTHONPATH='./src' jupyter lab
source .venv/bin/activate; PYTHONPATH='./src' jupyter lab

black-check:
source venv/bin/activate ; black src --check --verbose --line-length 120
source .venv/bin/activate ; black src --check --verbose --line-length 120

black:
source venv/bin/activate ; black src --line-length 120
source .venv/bin/activate ; black src --line-length 120

ruff-check:
source venv/bin/activate ; ruff check .
source .venv/bin/activate ; ruff check .

ruff:
source venv/bin/activate ; ruff check . --fix
source .venv/bin/activate ; ruff check . --fix

test:
source venv/bin/activate ; PYTHONPATH='./src' pytest -vv --capture=no tests
source .venv/bin/activate ; PYTHONPATH='./src' pytest -vv --capture=no tests

.DEFAULT_GOAL := help
.PHONY: help
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# minimal-python-project-template

A minimal quick-start Python project template.
A minimal quick-start Python project template, using [uv](https://github.com/astral-sh/uv) package manager.

Uses the following 3rd party libraries:
Uses the following 3rd party libraries:

- APP - https://github.com/tiangolo/typer - For building CLI applications
- APP - https://github.com/Delgan/loguru - Python logging made (stupidly) simple
- APP - https://github.com/theskumar/python-dotenv - Reads key-value pairs from a .env file and can set them as environment variables.
- DEV - https://github.com/astral-sh/uv - An extremely fast Python package and project manager
- DEV - https://github.com/psf/black - The uncompromising Python code formatter
- DEV - https://github.com/pytest-dev/pytest - makes it easy to write small tests, yet scales to support complex functional testing

Expand Down
2 changes: 1 addition & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def main(required_arg: str, optional_arg: str = None):
token = os.getenv("EXAMPLE_TOKEN")
# token = os.getenv("EXAMPLE_TOKEN")
logger.debug(f"Hello! required_arg = {required_arg}, optional_arg = {optional_arg}")
logger.debug(f"PYTHONPATH = {os.getenv('PYTHONPATH', 'Not set')}")
logger.info(f"LOG_STDERR_LEVEL = {os.getenv('LOG_STDERR_LEVEL', 'Not set. Copy `.env_template` to `.env`')}")
Expand Down

0 comments on commit 66acc11

Please sign in to comment.