Auto-generate missing __init__.py files to fix Python import issues and ensure proper module discovery.
Project description
pyinitgen
Automated init.py generator for Python packages Ensures every directory in your project is a proper Python package — no more mysterious ModuleNotFoundError surprises.
Perfect for:
Large refactors
Monorepos / multi-package architectures
Auto-generated project structures
Migration from namespace-less directories
CI environments ensuring package integrity
🚀 Features
Feature Description
📂 Recursive scan Walks directory tree intelligently 🛠️ Auto-creates init.py Only where missing — safe & precise 🧠 Excludes system/runtime dirs pycache, .git, .venv, etc. 👀 Dry-Run Mode See what will be created first 🎯 Project-safe Avoids touching non-Python folders ✨ Emoji status (optional) Fancy terminal UX 🔒 Zero destructive actions Never overwrites content
📦 Installation
pip install pyinitgen
🧠 Usage
✅ Default — scan current directory
pyinitgen
📁 Scan a specific project root
pyinitgen --base-dir src/
🔍 Preview changes (no write)
pyinitgen --dry-run
🗣️ Verbose mode
pyinitgen --verbose
🤐 Quiet mode
pyinitgen --quiet
🛑 Disable emojis
pyinitgen --no-emoji
📝 Example Output
Scanning: src/utils Created src/utils/init.py ✅ Operation complete. Scanned 43 dirs, created 8 new init.py files.
🧩 Why this tool?
Problem Solution
Large Python codebases without -inits Auto insert all required files ModuleNotFoundError during import Ensures folders become packages Hand-creating 50+ init.py files One command 🤖 Accidental file writes? Only creates missing files
⚙️ CLI Help
pyinitgen --help
🛡️ Safe by Design
Never touches existing files
Ignores system & irrelevant dirs by default
Supports dry-run to preview
💡 Tip
Use in CI to guarantee package consistency:
pyinitgen --dry-run
🤝 Contributing
PRs welcome — improve detection logic, add custom exclusion rules, enhance output UX.
👉 Repo: https://github.com/dhruv13x/pyinitgen
📜 License
MIT
🧭 Related Tools in the Suite
Tool Purpose
importdoc Import issue diagnosis import-surgeon Safe import refactoring pypurge Clean caches, venv junk pyinitgen Generate missing init.py ✅ (this project)
⭐ Support
If you like this tool:
⭐ Star the GitHub repo
🐍 Use it in CI & projects
📦 Recommend to Python dev friends
Project details
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 pyinitgen-3.0.1.tar.gz.
File metadata
- Download URL: pyinitgen-3.0.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03b102159e614029f16046742faaf9f9f9a91e6fab3971869e74ee0dcb207935
|
|
| MD5 |
c6269facf9f2622aacae4a2c4fe9584b
|
|
| BLAKE2b-256 |
eac6f3946e52c5232a866ce06d4b3730858f19ffcf7e5e7246b7d272245884ea
|
Provenance
The following attestation bundles were made for pyinitgen-3.0.1.tar.gz:
Publisher:
publish.yml on dhruv13x/pyinitgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyinitgen-3.0.1.tar.gz -
Subject digest:
03b102159e614029f16046742faaf9f9f9a91e6fab3971869e74ee0dcb207935 - Sigstore transparency entry: 720743940
- Sigstore integration time:
-
Permalink:
dhruv13x/pyinitgen@6dfde09f35cdcf387dd332947546ba3e769035c2 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dhruv13x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6dfde09f35cdcf387dd332947546ba3e769035c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyinitgen-3.0.1-py3-none-any.whl.
File metadata
- Download URL: pyinitgen-3.0.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b474cd184ca219e32c5433a3672755bdcb7e41a7c1afc990c03017d6f8a637f3
|
|
| MD5 |
bdf2878098b909b638090851c73c35e2
|
|
| BLAKE2b-256 |
f256c9c74a3f20d0bf548941ecb9aa9c2d3f5b8c732e223a923852fb591921af
|
Provenance
The following attestation bundles were made for pyinitgen-3.0.1-py3-none-any.whl:
Publisher:
publish.yml on dhruv13x/pyinitgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyinitgen-3.0.1-py3-none-any.whl -
Subject digest:
b474cd184ca219e32c5433a3672755bdcb7e41a7c1afc990c03017d6f8a637f3 - Sigstore transparency entry: 720743945
- Sigstore integration time:
-
Permalink:
dhruv13x/pyinitgen@6dfde09f35cdcf387dd332947546ba3e769035c2 -
Branch / Tag:
refs/tags/v3.0.1 - Owner: https://github.com/dhruv13x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6dfde09f35cdcf387dd332947546ba3e769035c2 -
Trigger Event:
push
-
Statement type: