Skip to main content

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

pyinitgen-0.1.1.tar.gz (4.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-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyinitgen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 677f0b46c08439d077b74c55e999171b205c47d16c6fad488854eabf54ca4b8f
MD5 3e7696c66d23e803619b7b583da16fae
BLAKE2b-256 be49fc26cbdf7219366b3e98a5123888760b0b3faebb8d4f3b3ea6584deff191

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinitgen-0.1.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-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pyinitgen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87e39af4418fa35baf1f69e81c3ce80ff650f3be14dae54a37a0cc7c5c105377
MD5 b76cb3b8845ff647e55bdd33dbed8995
BLAKE2b-256 fc8fa61e505eab9ee555c9943c982f9d74bfc801c1608bdb38ae8ea7fa8b31b9

See more details on using hashes here.

Provenance

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