A CLI tool to scaffold new Python projects, similar to create-react-app.
Project description
pyforge
pyforge is a lightweight command-line tool for scaffolding Python projects in seconds. It creates a working project layout, starter tests, basic tooling config, and a template-specific entry point so you can start coding immediately.
Key Features
- Terminal-native TUI: A Rich-powered wizard with a visual template menu and styled prompts.
- Multiple Built-in Templates: Native templates for
basicpackages,clitools,fastapiservices, andflaskapplications. - Remote Templates: Pull custom project layouts directly from public GitHub repositories using the
gh:owner/reposyntax. - Configurable Defaults: Save persistent author, license, template, 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, and optionalpre-commithooks. - Task Automation: Optional virtual environment creation, 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
In an interactive terminal, pyforge opens a template picker first and then asks for project details. The template menu includes:
1. Basic package - Minimal package with a real entry point and starter test.
2. Click CLI - Console application with a click command and script entry point.
3. FastAPI service - API scaffold with a health endpoint.
4. Flask app - Factory-style web app.
5. Custom GitHub template - gh:owner/repo[@ref]
If you pass --yes, pyforge skips prompts and uses defaults. You can also pass --template directly to bypass the picker.
Once the wizard completes, your project directory is created and populated. Typical next steps are:
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 or command
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 or remote GitHub template.
Built-ins: basic, cli, fastapi, flask.
Remote: gh:owner/repo or gh:owner/repo@ref.
If omitted, an interactive template picker is shown.
--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.
Built-in Templates
Basic
Minimal package scaffold with an executable module layout.
src/<project>/main.pysrc/<project>/__main__.pytests/test_main.py
CLI
Click-based command-line application with a console script entry point.
src/<project>/cli.pysrc/<project>/__main__.pytests/test_cli.py
FastAPI
API scaffold with a root route and a /health endpoint.
src/<project>/main.pytests/test_main.py
Flask
Factory-style Flask application with a test client setup.
src/<project>/app.pytests/test_app.py
Project Structure
The default basic template generates the following directory structure:
myproject/
├── src/
│ └── myproject/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Module entry point
│ └── main.py # Console entry point
--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
Remote Templates
pyforge is a lightweight command-line tool for scaffolding Python projects in seconds. It creates a working project layout, starter tests, basic tooling config, and a template-specific entry point so you can start coding immediately.
Key Features
- Terminal-native TUI: A Rich-powered wizard with a visual template menu and styled prompts.
- Multiple Built-in Templates: Native templates for
basicpackages,clitools,fastapiservices, andflaskapplications. - Remote Templates: Pull custom project layouts directly from public GitHub repositories using the
gh:owner/reposyntax. - Configurable Defaults: Save persistent author, license, template, 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, and optionalpre-commithooks. - Task Automation: Optional virtual environment creation, 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
In an interactive terminal, pyforge opens a template picker first and then asks for project details. The template menu includes:
1. Basic package - Minimal package with a real entry point and starter test.
2. Click CLI - Console application with a click command and script entry point.
3. FastAPI service - API scaffold with a health endpoint.
4. Flask app - Factory-style web app.
5. Custom GitHub template - gh:owner/repo[@ref]
If you pass --yes, pyforge skips prompts and uses defaults. You can also pass --template directly to bypass the picker.
Once the wizard completes, your project directory is created and populated. Typical next steps are:
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 or command
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 or remote GitHub template.
Built-ins: basic, cli, fastapi, flask.
Remote: gh:owner/repo or gh:owner/repo@ref.
If omitted, an interactive template picker is shown.
--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.
Built-in Templates
Basic
Minimal package scaffold with an executable module layout.
src/<project>/main.pysrc/<project>/__main__.pytests/test_main.py
CLI
Click-based command-line application with a console script entry point.
src/<project>/cli.pysrc/<project>/__main__.pytests/test_cli.py
FastAPI
API scaffold with a root route and a /health endpoint.
src/<project>/main.pytests/test_main.py
Flask
Factory-style Flask application with a test client setup.
src/<project>/app.pytests/test_app.py
Project Structure
The default basic template generates the following directory structure:
myproject/
├── src/
│ └── myproject/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Module entry point
│ └── main.py # Console entry point
├── 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
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, so no Jinja 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 are 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, from highest to lowest:
- CLI flags, such as
--templateand--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 exposes standard commands for project maintenance:
install: Install the project locally in editable mode alongside all development dependencies.test: Execute the test suite usingpytest.lint: Perform static analysis withruff.format: Auto-format code styles usingruff format.run: Start the application server or CLI script, depending on the selected template.clean: Remove local cache and build directories such as__pycache__,.pytest_cache,.ruff_cache,build, anddist.
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/*
Development
To work on pyforge locally:
git clone https://github.com/your-name/pyforge.git
cd pyforge
pip install -e ".[dev]"
python -m pytest -v
Contributing
Contributions are welcome. Open an issue or pull request if you find a bug or want to propose an improvement.
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.1.tar.gz.
File metadata
- Download URL: pyforge_init-0.1.1.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c41c58c08f8bf0fec62f5fb83a6eac855410f205e647d0fc8bce0f0dc323842c
|
|
| MD5 |
8de886aabafee1b68ef554dd9a4000b0
|
|
| BLAKE2b-256 |
cfcb335e798d3864543a50335d363b0d70ee0bb5de006cceede89ab21179e69e
|
Provenance
The following attestation bundles were made for pyforge_init-0.1.1.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.1.tar.gz -
Subject digest:
c41c58c08f8bf0fec62f5fb83a6eac855410f205e647d0fc8bce0f0dc323842c - Sigstore transparency entry: 2087802529
- Sigstore integration time:
-
Permalink:
princeraj-cs/pyforge@8141bb8aaf3d1b2e03a6bcf43d981e4ff4e352da -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/princeraj-cs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8141bb8aaf3d1b2e03a6bcf43d981e4ff4e352da -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyforge_init-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyforge_init-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.0 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 |
3a694962f935b6fe4400ccdb2fc046be22c5d5dc004276d78fb9fcc49d4bb73d
|
|
| MD5 |
1ec373dce181e6ae1fa60a40d508809a
|
|
| BLAKE2b-256 |
64729adecb4765d2e5e03e8dea524ddbb75982396e16c49f81b5e63266916afe
|
Provenance
The following attestation bundles were made for pyforge_init-0.1.1-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.1-py3-none-any.whl -
Subject digest:
3a694962f935b6fe4400ccdb2fc046be22c5d5dc004276d78fb9fcc49d4bb73d - Sigstore transparency entry: 2087802776
- Sigstore integration time:
-
Permalink:
princeraj-cs/pyforge@8141bb8aaf3d1b2e03a6bcf43d981e4ff4e352da -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/princeraj-cs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8141bb8aaf3d1b2e03a6bcf43d981e4ff4e352da -
Trigger Event:
push
-
Statement type: