recursive_import
Trivial library that will import the whole module tree.
Main use case for this library is importing everything in given package. Simplest exaple are decorators that register stuff for CI, a bit like annotation scanning in Java.
Requires python 3.5+, because of
typing. Besides that, there are no dependencies.
System-independent. Tested on CPython 3.9-3.12 (to simplify CI), but its really trivial.
The whole API is best documented by docstrings:
def package_root(pkg: ModuleType) -> str:
"""
Find out where is the root directory holding code for specified package or module.
:param pkg: package to be located.
:raise ValueError: if the argument is a module and not a package
:return: absolute path to the directory holding the `__init__` file of the package
"""
(...)
def current_project_root() -> str:
"""
Find out where is the root directory holding code for currently running app.
By "currently running app" we mean the module that is present as `__main__`.
:return: absolute path to the directory holding the module that is `__main__`
"""
(...)
def import_package_recursively(root_package: str) -> None:
"""
Will import the package specified by name and all its subpackages and submodules recursively.
Order is: each subpackage or submodule of the package, then recurse in that same order.
:param root_package: name of the package to be scanned. If that's already a subpackage, its parent packages
will get imported by default (because that's how python works)
"""
(...)
Reading the test suite is gonna be useful too, in case of uncertainty.
Metadata
Release files for recursive-import 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| recursive_import-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for recursive_import-1.0.0-py3-none-any.whl |
Release files / recursive_import-1.0.0-py3-none-any.whl
| Download URL | recursive_import-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fff19508675bda5afbec884bcccf54ad267f9948d4f9874c272ac8348c76843
|
|
BLAKE2b-256 checksum How to use checksums |
44d6ea30fa4cee12ee1f39b1dfe7e14c4199aa6306b559d6070cbda2f3a0bf03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for recursive-import 1.0.0
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.