Skip to main content

ImportSpy ensures structural integrity, runtime compliance, and security for external modules, preventing inconsistencies and enforcing controlled execution.

Project description

https://static.pepy.tech/badge/importspy https://img.shields.io/github/actions/workflow/status/atellaluca/ImportSpy/python-package.yml?style=flat-square https://img.shields.io/github/license/atellaluca/ImportSpy?style=flat-square Documentation Status

ImportSpy - Intelligent Import Validation 🛡️

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 Architecture

What is ImportSpy?

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.

Why Should You Use ImportSpy? 🚀

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.

How ImportSpy Works

ImportSpy intercepts module imports and ensures they match predefined execution constraints before allowing execution.

The process is simple:

  1. Define execution constraints (e.g., OS, Python version, environment variables).

  2. ImportSpy validates runtime conditions dynamically.

  3. If the environment is compliant, execution proceeds.

  4. If the environment is non-compliant, ImportSpy blocks execution.

Example: Preventing Imports in the Wrong Environment

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.

Who Should Use ImportSpy?

  • 🔹 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. 🔥

Installation & Quickstart

ImportSpy is available on PyPI:

pip install importspy

Check out the Quickstart Guide for step-by-step instructions.

Support & Contribute

ImportSpy is open-source and thrives with your support!

Ways to Help 🚀

  • 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!

License

ImportSpy is released under the MIT License. 📜 Read the full license: LICENSE

🔥 Take control of your imports. Start using ImportSpy today! 🚀

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

importspy-0.2.0.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

importspy-0.2.0-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file importspy-0.2.0.tar.gz.

File metadata

  • Download URL: importspy-0.2.0.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.9 Linux/6.13.5-100.fc40.x86_64

File hashes

Hashes for importspy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5c1b354b34a5c16dd4491f1d2da0dd3ddbf84b0ccc9743db8c97e2662500c166
MD5 9abac463ad2c5e11224e8b1fdf9f665d
BLAKE2b-256 9f3964edb90f4f9a10e062f9f2e5bc1113ec769b190a2dcb918234371805fdb3

See more details on using hashes here.

File details

Details for the file importspy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: importspy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.9 Linux/6.13.5-100.fc40.x86_64

File hashes

Hashes for importspy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b50b61ff545184ed10bca5f3d8956356492243a0c22c39af2f85c816a335fa5
MD5 4afe77b7fbf04e0ba9a522024015a37f
BLAKE2b-256 2f8f484e77f6435655b425c4cb3af48b01011f0069df5c683eda90d081188dce

See more details on using hashes here.

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