A tiny, batteries-included Windows batch script to bootstrap a minimal, modern Python project in seconds.
- Asks for a project name and converts it to a safe, lowercase folder name (e.g., "My App" → "my-app").
- Creates folders:
docs/,src/<name>/,tests/, and a virtual environmentvenv/. - Initializes a Git repository (if Git is installed) on branch
main. - Generates essential files:
.gitignore,README.md,requirements.txt,pyproject.toml,setup.py,pytest.ini, VS Code settings, and a tiny sample module + CLI. - Activates the new virtual environment at the very end and stops (no commands run after activation).
cmd.exe makes multi-line file generation tricky. The script calls PowerShell only to write file contents reliably. You don't need to learn PowerShell to use this.
From cmd in the repository root:
python_project_scaffolding.bat-
Type your project name when prompted.
-
You'll be asked for a destination parent folder (press Enter to use the current folder).
-
When it finishes, the virtual environment will be active in your current shell and you'll see:
[Done] Virtual environment activated. Next: pip install -e . -r requirements.txt
Note: requirements.txt starts empty. It's fine to run pip install -e . by itself; add -r requirements.txt only after you've added dependencies to that file.
Next steps inside your new project:
pip install -U pip
pip install -e .
REM optional: after you add dependencies
pip install -r requirements.txt
pytest -q
python -m <your-project-name>.cliUse Git to clone the scaffolder locally.
Now run the script:
python_project_scaffolding.batNotes:
- If you double-click the .bat from Explorer, Windows opens a temporary cmd window; the venv activates there but the window closes when the script ends. To keep the venv active, run the script from an existing cmd window.
- The script uses PowerShell only to write file contents; no admin rights required.
- Minimal GitHub Actions workflow runs on push to
mainand smoke‑tests the scaffolder on Windows (multiple Python versions).
- Windows 10/11
- Python 3.10+ available as
py -3orpython - Git (optional, for repository initialization)
<your-project-name>/
docs/
src/
<your-project-name>/
tests/
venv/ # created by the script
.git/ # if Git was available
.gitignore
README.md
requirements.txt
pyproject.toml
setup.py
pytest.ini
.editorconfig
.gitattributes
.vscode/
- What are
.editorconfig,.gitattributes, andpytest.ini?.editorconfig: Keeps editor settings consistent (UTF-8, end-of-line, trimming whitespace, 4-space Python indents)..gitattributes: Normalizes line endings in Git and keeps.batfiles as CRLF on Windows.pytest.ini: Points pytest totests/and sets quiet mode-qby default.