Files

1.5 KiB

new-python

CLI tool to scaffold a Python repository configured with pipenv, a basic justfile, code formatters, and a pre-commit hook. For use in test-driven development workflows.

Install

Clone the repo, then create a symlink to ./bin/new-python in a directory in your PATH, such as ~/.local/bin.

git clone https://git.wisehodl.dev/jay/new-python ~/lib/new-python
ln -s ~/lib/new-python/bin/new-python ~/.local/bin/new-python

Usage

new-python NAME [--packages PKG ...] [--dir PATH] [--python VERSION]
  • NAME — Project name in kebab-case (e.g., demo-project)
  • --packages — Runtime dependencies to add to the Pipfile
  • --dir — Parent directory for the new project (default: current directory)
  • --python — Python version pin (default: 3.12.4, must be installed in pyenv)

The script renders the template, initializes a Git repo on main, runs pipenv install --dev, creates the initial commit, and installs the pre-commit hook.

$ new-python demo-project --dir ~/path/to/repo
/home/user/path/to/repo/demo-project

Development

  • pipenv install --dev — set up virtual environment
  • just test — run test suite (pass path to run a single test)
  • just ci — run linter, formatter checks, and tests
  • just fmt — run automatic code formatters

Template files live in template/ and use {{NAME}}, {{PKG}}, and {{PYVER}} placeholders. tests/test_selfhost.py checks that this repository's configuration matches the template files.