Python package and CLI project structure

Python package and CLI project structure

Explorer

  • .git…
  • .venv…, not committed
  • .vscodenew
  • settings.jsonnew
  • extensions.jsonnew
  • .pytest_cache…new, not committed
  • .ruff_cache…new, not committed
  • .mypy_cache…new, not committed
  • .coveragenew, not committed
  • dist…, not committed
  • htmlcov…new, not committed
  • site…new, not committed
  • docsnew
  • index.mdnew
  • installation.mdnew
  • tutorial.mdnew
  • usage.mdnew
  • configuration.mdnew
  • reference.mdnew
  • src
  • testsnew
  • conftest.pynew
  • .editorconfignew
  • .gitignore
  • .pre-commit-config.yamlnew
  • .python-version
  • LICENSE
  • README.md
  • mkdocs.ymlnew
  • pyproject.toml
  • uv.lock
  1. # Create a packaged project with a src layout and a console script (needs uv)

    uv init --package mdlinks
  2. # Pin the Python version for the project

    cd mdlinks && uv python pin 3.14
  3. # Add the CLI and runtime dependencies

    uv add typer rich httpx platformdirs
  4. # Add test, lint, type and docs tools as dev dependencies

    uv add --dev pytest pytest-cov ruff mypy pre-commit mkdocs-material "mkdocstrings[python]"
  5. # Run your CLI from the project environment

    uv run mdlinks --help
  6. # Install the Git hooks once per clone

    uv run pre-commit install
  7. # Build the sdist and wheel into dist/

    uv build
  8. # Install the published tool globally, the way users will

    uv tool install mdlinks