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-3.0.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

pyinitgen-3.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

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

Hashes for pyinitgen-3.0.1.tar.gz
Algorithm Hash digest
SHA256 03b102159e614029f16046742faaf9f9f9a91e6fab3971869e74ee0dcb207935
MD5 c6269facf9f2622aacae4a2c4fe9584b
BLAKE2b-256 eac6f3946e52c5232a866ce06d4b3730858f19ffcf7e5e7246b7d272245884ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinitgen-3.0.1.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-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

Hashes for pyinitgen-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b474cd184ca219e32c5433a3672755bdcb7e41a7c1afc990c03017d6f8a637f3
MD5 bdf2878098b909b638090851c73c35e2
BLAKE2b-256 f256c9c74a3f20d0bf548941ecb9aa9c2d3f5b8c732e223a923852fb591921af

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinitgen-3.0.1-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