Skip to main content

Auto-generate missing __init__.py files to fix Python import issues and ensure proper module discovery.

Project description

pyinitgen logo

PyPI version Python Wheel Release

Build status Codecov Test Coverage Code style: black Ruff Security

Downloads OS Python Versions

License: MIT

Docs


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

pyinitgen-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyinitgen-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pyinitgen-1.0.0.tar.gz.

File metadata

  • Download URL: pyinitgen-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyinitgen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 62e41607700db3a9bc35f87e5680eee731fd92537ddeff0d72eba5e80929535e
MD5 7e4ad117d7e1619ac4169dffaf881f5b
BLAKE2b-256 992cb1c66b8ba2deb28f4feec072ba28b63096a88fc44099a1dfa328b35fdb74

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinitgen-1.0.0.tar.gz:

Publisher: publish.yml on dhruv13x/pyinitgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyinitgen-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyinitgen-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyinitgen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6f194304eaa8171ceafd3562bbf70ad12fc4bdb0a224ff50d0b44e936cf8950
MD5 5e59a776c59ee74e21a04a558648f6cb
BLAKE2b-256 ebc58f47bbe54b2120f62471208874f60a6a359b228d59f5458680047374b341

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinitgen-1.0.0-py3-none-any.whl:

Publisher: publish.yml on dhruv13x/pyinitgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page