Ensure compliance, prevent unexpected failures, and enforce execution rules dynamically.
- π Monitor the runtime context before allowing imports.
- β‘ Eliminate environment inconsistencies before they break production.
- π‘οΈ Enforce strict execution policies for imported modules.
ImportSpy is a powerful runtime validation framework that ensures that external modules only import your code in a compliant execution environment.
Why is this important?
- β Prevents unexpected failures caused by incorrect dependencies.
- β Ensures security by blocking unauthorized imports.
- β Eliminates debugging headaches by validating environments dynamically.
- β Gives you full control over how and where your code is used.
ImportSpy solves real-world problems for Python developers, software architects, and enterprises that need to enforce execution constraints on external modules.
π΄ Without ImportSpy
- β Modules may break when imported into the wrong Python version.
- β Unexpected OS configurations may introduce silent failures.
- β Dependencies may change, leading to unpredictable execution issues.
- β No protection against external modules misusing your code.
π’ With ImportSpy
- β Prevent misconfigured environments from executing your code.
- β Block unauthorized imports and enforce runtime policies.
- β Ensure every imported module meets strict execution requirements.
- β Gain full visibility into how your code is being used.
ImportSpy intercepts module imports and ensures they match predefined execution constraints before allowing execution.
The process is simple:
- Define execution constraints (e.g., OS, Python version, environment variables).
- ImportSpy validates runtime conditions dynamically.
- If the environment is compliant, execution proceeds.
- If the environment is non-compliant, ImportSpy blocks execution.
Imagine you want your module to be imported only in Python 3.10+, on Linux, with a specific environment variable. With ImportSpy, you can enforce this automatically.
from importspy.models import SpyModel, Deployment, Runtime, System, Python
from importspy.constants import Config
class MyModuleSpy(SpyModel):
deployments = [
Deployment(
runtimes=[
Runtime(
arch=Config.ARCH_X86_64,
systems=[
System(
os=Config.OS_LINUX,
pythons=[
Python(
version="3.10",
interpreter=Config.INTERPRETER_CPYTHON,
modules=[]
)
],
envs={"CI": True}
)
]
)
]
)
]
β If the importing module runs in a compliant environment, execution proceeds. β If the execution environment does not meet these conditions, ImportSpy blocks execution.
- πΉ Enterprise teams that need strict environment control.
- πΉ Developers working with microservices, modular frameworks, or plugin-based architectures.
- πΉ Security-conscious projects that want to restrict execution contexts.
- πΉ Python package maintainers who need runtime validation for external users.
If your project relies on external modules, ImportSpy is your safeguard against execution chaos. π₯
ImportSpy is available on PyPI:
pip install importspy
Check out the Quickstart Guide for step-by-step instructions.
- π Documentation: ImportSpy Docs
- π GitHub: ImportSpy Repository
ImportSpy is open-source and thrives with your support!
- β Star the project on GitHub β Give it a star!
- π οΈ Contribute β Open issues, PRs, or improve docs.
- π£ Share ImportSpy with developers who need execution control.
- π Sponsor ImportSpy to support development β Become a sponsor.
Every contribution helps make ImportSpy better, stronger, and more useful!
ImportSpy is released under the MIT License. π Read the full license: LICENSE
π₯ Take control of your imports. Start using ImportSpy today! π