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.1.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.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: importspy-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 db56b37e59c6cc3e1af5ecfbeab55b194175e00bf4fb0ba799ed0175e32f2ced
MD5 70992f819381570d3570e27921c8a1f3
BLAKE2b-256 6122a897d34a6d0648d23820e542503764f012643fcd4e0a6d9104c075325ced

See more details on using hashes here.

File details

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

File metadata

  • Download URL: importspy-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0e3153007c91f55e3a7a921125e2094e5234611c3e48f3b9c3e4533608c7a06
MD5 f2e33f3e8f20ffd1b9427cfbfbeb4be1
BLAKE2b-256 abfb4a9e1ff063130b55e7c407015f62c6ac336570d8de0a6021c35fce89fc32

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