{"id":30045297,"url":"https://github.com/deadpool2000/magicimporter","last_synced_at":"2025-08-07T07:43:03.952Z","repository":{"id":308177219,"uuid":"1031968576","full_name":"Deadpool2000/magicimporter","owner":"Deadpool2000","description":"Smart Python import wrapper that makes your imports lazier, safer, and smarter.","archived":false,"fork":false,"pushed_at":"2025-08-04T15:51:33.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T18:12:11.417Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Deadpool2000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-04T15:48:57.000Z","updated_at":"2025-08-04T15:51:36.000Z","dependencies_parsed_at":"2025-08-04T18:13:52.892Z","dependency_job_id":"afac7716-b07b-4206-8493-86a5e646ab47","html_url":"https://github.com/Deadpool2000/magicimporter","commit_stats":null,"previous_names":["deadpool2000/magicimporter"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Deadpool2000/magicimporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpool2000%2Fmagicimporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpool2000%2Fmagicimporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpool2000%2Fmagicimporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpool2000%2Fmagicimporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deadpool2000","download_url":"https://codeload.github.com/Deadpool2000/magicimporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpool2000%2Fmagicimporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269220663,"owners_count":24380622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-07T07:42:58.628Z","updated_at":"2025-08-07T07:43:03.919Z","avatar_url":"https://github.com/Deadpool2000.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🪄 magicimporter\n\n**Smart Python import wrapper** that makes your imports lazier, safer, and smarter.\n\n\u003e Written by a developer who's tired of writing `try: import ... except: install ...` everywhere.\n\n---\n\n## 🚀 What It Does\n\nmagicimporter is a tiny utility that helps you:\n\n✅ **Lazy-load modules** - defer importing until first access  \n✅ **Auto-install missing packages** - no more `pip install` errors  \n✅ **Avoid clutter** - wrap your imports cleanly and clearly  \n✅ **Support optional dependencies** - without breaking your app\n\nPerfect for:\n- Notebooks and prototyping\n- Reducing startup time (e.g., in CLI tools)\n- Handling optional packages gracefully\n- Plug-and-play with any Python script\n\n---\n\n## 📦 Installation\n\n### From PyPI (soon):\n```bash\npip install magicimporter\n```\n\n### From source:\n```bash\ngit clone https://github.com/Deadpool2000/magicimporter\ncd magicimporter\npip install -e .\n```\n\n---\n\n## 🔧 How to Use\n\n### Basic Usage\n\n```python\nfrom magicimporter import magic_import\n\njson = magic_import(\"json\")  # Just works like import\nprint(json.dumps({\"hello\": \"world\"}))\n```\n\n---\n\n### Lazy Import (delay loading until accessed)\n\n```python\nnp = magic_import(\"numpy\", lazy=True)\n\n# numpy isn’t imported until this line:\nprint(np.array([1, 2, 3]))\n```\n\n---\n\n### Auto-Install Missing Packages\n\n```python\nrequests = magic_import(\"requests\", auto_install=True)\n\nres = requests.get(\"https://httpbin.org/get\")\nprint(res.status_code)\n```\n\n---\n\n### Lazy + Auto-Install Together\n\n```python\npandas = magic_import(\"pandas\", lazy=True, auto_install=True)\n\n# Nothing is loaded yet...\nprint(\"About to create DataFrame\")\n\ndf = pandas.DataFrame({\"a\": [1, 2, 3]})  # Now pandas loads\nprint(df)\n```\n\n---\n\n### Import Submodules\n\n```python\nos_path = magic_import(\"os.path\", lazy=True)\nprint(os_path.basename(\"/foo/bar.txt\"))\n```\n\n---\n\n### Optional Dependencies Pattern\n\n```python\ntry:\n    yaml = magic_import(\"pyyaml\", auto_install=False)\n    config = yaml.safe_load(open(\"config.yaml\"))\nexcept ModuleNotFoundError:\n    print(\"Skipping YAML config support: dependency missing\")\n```\n\n---\n\n## 📁 Directory Structure\n\n```txt\nmagicimporter/\n├── magicimporter/\n│   ├── __init__.py\n│   ├── core.py          # main logic\n│   ├── lazy.py          # lazy loader\n│   └── installer.py     # auto-installer\n├── examples/\n│   └── demo.py\n├── tests/\n│   └── test_magicimporter.py\n├── setup.py\n├── pyproject.toml\n└── README.md\n```\n\n---\n\n## 🧪 Running Tests\n\n```bash\npytest tests/\n```\n\nYou can also test individual features manually from `examples/demo.py`.\n\n---\n\n## 🧠 Why This Exists\n\nYou're writing a script or notebook and hit this:\n\n```python\nimport somepackage  # ModuleNotFoundError\n```\n\nThen you type:\n\n```bash\npip install somepackage\n```\n\nAnd do it again. And again.  \nWhat if your code just handled that?  \nThat's what magicimporter does.\n\nIt’s especially useful when:\n- Building CLI tools with optional features\n- Using heavy modules only in specific branches\n- Rapid prototyping in notebooks or scripts\n\n---\n\n## 📌 Notes \u0026 Caveats\n\n- Auto-install uses `subprocess` to call pip - no fancy API yet.\n- Lazy import doesn't delay sub-imports inside a module (standard Python behavior).\n- Use responsibly in production: implicit installs may surprise your users.\n\n---\n\n## 🛠️ Roadmap Ideas\n\n- [ ] Async import support\n- [ ] Config file or env variable overrides\n- [ ] Warnings and logging customization\n- [ ] Module-level caching\n\n---\n\n## 👨‍💻 Author\n\nMade with care by Deadpool2000 – feel free to fork, extend, or PR ideas!\n\n---\n\n## 📄 License\n\nMIT – use it, hack it, ship it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadpool2000%2Fmagicimporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadpool2000%2Fmagicimporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadpool2000%2Fmagicimporter/lists"}