Importation 🛸
automagically install missing imports
Is this a good idea? Probably not.
Should you use this? Probably not.
What is this?
importation hijacks the import keyword in Python to test if the module is importable, and auto-installs missing packages.
If you're in a virtual environment, it installs it to your current virtual environment. If not, it creates one at __pypackages__/importation, adds it to sys.path so packages are discoverable, and installs missing packages there.
It takes PEP-582 "Python local packages directory" one step further by resolving packages in __pypackages__ plus auto-installing to them.
How do I get it?
> python -m pip install importation --user
How do I use it?
Just import it.
The act of importing it has the side effect of hijacking Python's import system.
# example.py
import importation # noqa: 401
import httpx
print("module resolved at", httpx.__file__)
Then
$ python test.py
# module resolved at /home/__pypackages__/importation/lib/python3.8/site-packages/httpx/__init__.py
To debug or view details of what it's doing set the IMPORTATION_VERBOSE environment variable:
$ IMPORTATION_VERBOSE=1 python test.py
Disclaimer
This has not been tested beyond this extremely simple example.
Credits
This package was inspired by PEP-582 and magicimport.py.
Metadata
Release files for importation 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| importation-0.0.1.tar.gz | 4.3 kB | Without provenance | Details for importation-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| importation-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for importation-0.0.1-py3-none-any.whl |
Total release size: 8.3 kB
Release files / importation-0.0.1.tar.gz
| Download URL | importation-0.0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbc573557ab1e700af52d137f45b14a9b48f3d5acc849564927c43c099f88b2a
|
|
BLAKE2b-256 checksum How to use checksums |
a18403d658818a37aa76338211a1b2b865fc1e644d3bfefba5544b350897e4c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Release files / importation-0.0.1-py3-none-any.whl
| Download URL | importation-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3486498f857a65ee8d481c2c0ee5947da90ba31182095ea4a6a1c752e11e4643
|
|
BLAKE2b-256 checksum How to use checksums |
3ece174d1a99d2b9217cdf154e3a62edf5e9ff5e5bcd79f4e73520cfebc14a83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
|
Security for importation 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.