A CLI tool to scaffold new Python projects, similar to create-react-app.
Project description
pyforge
pyforge is a lightweight, interactive command-line interface (CLI) tool designed to scaffold production-ready Python projects in seconds. Inspired by standard scaffolding tools, pyforge automates project initialization, environment setup, testing configuration, linting, formatting, and dependency management.
Key Features
- Interactive TUI: Driven by
questionaryfor guided project configuration (supports non-interactive overrides). - Multiple Built-in Templates: Native templates for
basicpackages,clitools,fastapimicroservices, andflaskapplications. - Remote Templates: Pull custom project layouts directly from public GitHub repositories using the
gh:owner/reposyntax. - Configurable Defaults: Save persistent author, license, and tool choices in a
~/.newpythonrcconfiguration file. - Standards-Compliant: Generates PEP 621-compliant
pyproject.tomlusinghatchlingas the build backend. - Tooling Configuration: Preconfigured integration with
pytest,ruff(linter and formatter), andpre-commithooks. - Task Automation: Automated creation of a local virtual environment, Git repository initialization, and generation of a template-aware
MakefileorJustfile.
Installation
Install pyforge-init globally via PyPI:
pip install pyforge-init
Or install it in an isolated environment using pipx:
pipx install pyforge-init
Quick Start
Initialize a new project by running:
newpython myproject
The CLI will start the interactive configuration wizard:
? Project description: A new Python project
? Author name: Jane Doe
? License: MIT
? Initialize a virtual environment (.venv)? Yes
? Initialize a git repository? Yes
Once the wizard completes, your project directory is created and populated. Execute the following commands to begin development:
cd myproject
source .venv/bin/activate # On Windows use: .venv\Scripts\activate
make install # Installs the package and all dev dependencies
make run # Runs the application (varies by template)
CLI Reference
Usage: newpython [OPTIONS] PROJECT_NAME
Scaffold a new Python project.
Arguments:
PROJECT_NAME Name of the project (must be a valid Python identifier)
Options:
--template TEXT Built-in template (basic, cli, fastapi, flask)
or a remote GitHub repo (gh:owner/repo[@ref]) [default: basic]
--no-pre-commit Skip generating .pre-commit-config.yaml
--justfile Generate a Justfile instead of a Makefile
-y, --yes Skip interactive prompts and accept defaults
--help Show this message and exit.
Project Structure (Basic Template)
The default template (basic) generates the following directory structure:
myproject/
├── src/
│ └── myproject/
│ └── __init__.py # Package initialization
├── tests/
│ └── test_main.py # Starter unit test
├── .env.example # Example environment variables
├── .gitignore # Standard Python git ignore rules
├── .pre-commit-config.yaml # Pre-configured linting/formatting hooks
├── Makefile # Task runner
├── README.md # Generated project documentation
├── pyproject.toml # Metadata, dependencies, and tool settings
└── requirements.txt # Project dependencies
Templates
Built-in Templates
| Template | Primary Stack | Generated Entry Point | Run Command |
|---|---|---|---|
basic |
Pure Python | src/package/__init__.py |
python -m package |
cli |
click |
src/package/cli.py & __main__.py |
Registered console script |
fastapi |
fastapi, uvicorn, httpx |
src/package/main.py |
uvicorn src.package.main:app |
flask |
flask (Factory pattern) |
src/package/app.py |
flask run |
Remote Templates
You can import any public GitHub repository to use as a project template:
# Uses the main/master branch
newpython myproject --template gh:username/repo-name
# Pin to a specific branch, tag, or commit hash
newpython myproject --template gh:username/repo-name@v1.0.0
Remote Repository Requirements
Remote templates are fetched and copied as-is (no Jinja template rendering is performed on remote files).
- If the remote repository has a top-level
template/directory, only the contents of that folder are copied to the destination. - If no
template/directory is present, the entire contents of the repository root will be copied.
Configuration File (~/.newpythonrc)
You can persist configuration defaults in a ~/.newpythonrc (TOML format) file to pre-fill prompt values and skip entering them on every run.
# ~/.newpythonrc
author = "Jane Doe"
license = "MIT"
template = "basic"
pre_commit = true
justfile = false
Precedence Order
When resolving configurations, pyforge applies overrides in the following order (highest to lowest):
- CLI Flags (e.g.
--template,--justfile) - Configuration file (
~/.newpythonrc) - Interactive Prompt Defaults
To override the default config location, set the NEWPYTHON_CONFIG environment variable:
export NEWPYTHON_CONFIG="/path/to/custom/config.toml"
Automated Task Runner
The generated Makefile (or Justfile if --justfile is passed) exposes standard commands for project maintenance:
make install: Installs the project locally in editable mode alongside all development dependencies (pip install -e ".[dev]").make test: Executes the test suite usingpytest.make lint: Performs static analysis checking withruff.make format: Auto-formats code styles usingruff format.make run: Starts the application server or CLI script (template-aware).make clean: Recursively cleans local cache directories (__pycache__,.pytest_cache,.ruff_cache,build,dist).
Publishing to PyPI
Projects generated by pyforge use hatchling as the build system and are ready to be built and uploaded to PyPI:
- Install build and publication dependencies:
pip install build twine
- Build the project distribution packages (source archive and wheel):
python -m build
- Upload to PyPI (or TestPyPI first):
python -m twine upload dist/*
Contributing
Contributions to pyforge are welcome. To set up a local development environment:
git clone https://github.com/your-name/pyforge.git
cd pyforge
pip install -e ".[dev]"
python -m pytest -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyforge_init-0.1.0.tar.gz.
File metadata
- Download URL: pyforge_init-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab2c8af337d7bf8a3ffb251b146c2f6e656cd77720cf9eccf5a11a8d8402adc5
|
|
| MD5 |
8b2a4c3efff8885a65fabfa2779e1dfd
|
|
| BLAKE2b-256 |
7dada2f74aa696e622d8f1e186628d827ad5c2d2d7b656b07e0e51a9e45cd2f5
|
Provenance
The following attestation bundles were made for pyforge_init-0.1.0.tar.gz:
Publisher:
release.yml on princeraj-cs/pyforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyforge_init-0.1.0.tar.gz -
Subject digest:
ab2c8af337d7bf8a3ffb251b146c2f6e656cd77720cf9eccf5a11a8d8402adc5 - Sigstore transparency entry: 2085895510
- Sigstore integration time:
-
Permalink:
princeraj-cs/pyforge@0ad2cf1d6540eee3662300f5d8c9fe16d48df47e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/princeraj-cs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0ad2cf1d6540eee3662300f5d8c9fe16d48df47e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyforge_init-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyforge_init-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8173294e95adfc45ebdf2c94a92780c1e4e03d46ddab3ecca6daa01f5bcedc8f
|
|
| MD5 |
f0779cc961df59f0f76ea4dae02cbc3c
|
|
| BLAKE2b-256 |
07fddafffee973ad251ae80bfe26ca95aa79f73a2c38eaa5b795a22219698399
|
Provenance
The following attestation bundles were made for pyforge_init-0.1.0-py3-none-any.whl:
Publisher:
release.yml on princeraj-cs/pyforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyforge_init-0.1.0-py3-none-any.whl -
Subject digest:
8173294e95adfc45ebdf2c94a92780c1e4e03d46ddab3ecca6daa01f5bcedc8f - Sigstore transparency entry: 2085895751
- Sigstore integration time:
-
Permalink:
princeraj-cs/pyforge@0ad2cf1d6540eee3662300f5d8c9fe16d48df47e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/princeraj-cs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0ad2cf1d6540eee3662300f5d8c9fe16d48df47e -
Trigger Event:
push
-
Statement type: