Python development with Poetry and pipx

Python development with Poetry and pipx.

# modern python development
## install tools with platform-specific choice
brew install poetry pipx  # mac
scoop install poetry pipx # windows
apt install poetry pipx   # linux
mise use -g poetry pipx   # mise

## init a project and common commands
poetry init [-n]              # creates pyproject.toml
poetry add requests           # add runtime dependency, would create venv automatically
poetry add --group dev pytest # add dev dependency
poetry add typer --optional   # add optional dependency
poetry show                   # display installed dependency
poetry remove requests        # remove dependency
poetry env list               # list all venv
poetry env remove xxx         # remove an venv
poetry env remove --all       # remove all venv
### for cli util manually add something like below to pyproject.toml
[tool.poetry.scripts]
mytool = "mytool.cli:main"

## project definition with metadata and dependency 
pyproject.toml
poetry.lock

## customize poetry venv behavior
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry install # would install from pyproject.toml and create venv for fresh repo
### run a cli command under poetry managed venv context
poetry run mytool # option 1 
poetry shell      # option 2
mytool            # option 2

## self managed venv - when needed
python -m venv .venv # manually create venv
source .venv/bin/activate
poetry install
deactivate

## globally available command tools
### install a dev cli tool globally from current directory
pipx install -e . # editable link
pipx install .    # immutable snapshot
### install a production cli tool globally from the remote
pipx install sometool
### manage life cycle
pipx reinstall sometool
pipx uninstall sometool

python