Skip to main content

Revolutionary Package CDN with Natural Import System - Stream Python packages instantly without local installation!

Project description

PyCDN - Revolutionary Package CDN with Natural Import System ๐Ÿš€

The Netflix of Python packages - Stream packages instantly without local installation!

PyCDN revolutionizes Python package management by serving packages through CDN networks with lazy loading and natural import syntax. Say goodbye to dependency hell and pip install delays!

๐ŸŒŸ Revolutionary Import System

PyCDN now supports natural Python import syntax using an advanced meta path import hook system. This means you can import packages directly from CDN servers as if they were installed locally!

Classic Usage (Still Works)

import pycdn

# Connect to CDN server
cdn = pycdn.pkg("http://localhost:8000")

# Use packages via attribute access
result = cdn.math.sqrt(16)  # Returns 4.0
data = cdn.numpy.array([1, 2, 3, 4, 5])
model = cdn.sklearn.LinearRegression()

๐ŸŽฏ NEW: Natural Import Syntax

import pycdn

# Connect and register CDN
cdn = pycdn.pkg("http://localhost:8000")  # Registers 'cdn' prefix

# Now use natural Python imports!
from cdn.openai import OpenAI
from cdn.numpy import array, mean
from cdn.pandas import DataFrame
from cdn.sklearn.ensemble import RandomForestClassifier

# Use exactly like local packages
client = OpenAI(api_key="your-key")
data = array([1, 2, 3, 4, 5])
avg = mean(data)
df = DataFrame({"col1": [1, 2, 3]})
model = RandomForestClassifier()

๐Ÿ”ง Custom Import Prefixes

# Use custom prefixes for different CDN servers
ml_cdn = pycdn.pkg("http://ml-cdn:8000", prefix="ml")
data_cdn = pycdn.pkg("http://data-cdn:8000", prefix="data")

# Import from different CDNs
from ml.tensorflow import keras
from ml.pytorch import nn
from data.pandas import DataFrame
from data.dask import dataframe as dd

๐Ÿข Multiple CDN Support

# Connect to multiple CDN environments
prod = pycdn.pkg("http://prod-cdn:8000", prefix="prod")
dev = pycdn.pkg("http://dev-cdn:8000", prefix="dev")
test = pycdn.pkg("http://test-cdn:8000", prefix="test")

# Import from specific environments
from prod.stable_package import ProductionClass
from dev.beta_package import ExperimentalFeature
from test.mock_package import TestDouble

๐ŸŽฏ Key Features

  • ๐Ÿ”ฅ Natural Import Syntax: Use from cdn.package import Class - feels exactly like local imports
  • โšก Instant Access: No pip install required - packages execute remotely
  • ๐ŸŒ Global CDN: Packages served from edge locations worldwide
  • ๐Ÿ”’ Zero Dependencies: No local installation or dependency conflicts
  • ๐Ÿ’พ Smart Caching: Intelligent caching with hybrid in-memory + disk storage
  • ๐Ÿ›ก๏ธ Security: Sandboxed execution with runtime security scanning
  • ๐Ÿ“Š Analytics: Usage tracking and performance monitoring
  • ๐Ÿ”„ Multi-CDN: Connect to multiple CDN servers simultaneously
  • ๐Ÿงฐ Development Mode: Local fallback and enhanced debugging

๐Ÿš€ Installation

pip install pycdn

๐Ÿ“– Quick Start

1. Basic Usage

import pycdn

# Connect to CDN
cdn = pycdn.pkg("http://localhost:8000")

# Classic usage
result = cdn.math.sqrt(16)
print(result)  # 4.0

# Natural imports (NEW!)
from cdn.math import sqrt, pow
print(sqrt(25))    # 5.0
print(pow(2, 3))   # 8.0

2. Working with Classes

import pycdn

cdn = pycdn.pkg("http://localhost:8000")

# Import and use classes naturally
from cdn.openai import OpenAI
from cdn.sklearn.ensemble import RandomForestClassifier

# Create instances and call methods
client = OpenAI(api_key="your-key")
response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "Hello!"}]
)

model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
predictions = model.predict(X_test)

3. Data Science Workflow

import pycdn

# Connect to data science CDN
ds_cdn = pycdn.pkg("http://ds-cdn:8000", prefix="ds")

# Natural imports for entire data pipeline
from ds.pandas import DataFrame, read_csv
from ds.numpy import array, mean, std
from ds.matplotlib.pyplot as plt
from ds.sklearn.model_selection import train_test_split
from ds.sklearn.ensemble import RandomForestRegressor
from ds.sklearn.metrics import mean_squared_error

# Use exactly like local packages
df = read_csv("data.csv")
X = df[["feature1", "feature2"]]
y = df["target"]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = RandomForestRegressor()
model.fit(X_train, y_train)

predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print(f"MSE: {mse}")

๐Ÿ› ๏ธ Advanced Features

Dynamic Prefix Management

cdn = pycdn.pkg("http://localhost:8000", prefix="initial")

# Change prefix dynamically
cdn.set_prefix("dynamic")

# Enable specific package imports
cdn.enable_imports(["tensorflow", "pytorch", "scikit-learn"])

# Now these work:
from dynamic.tensorflow import keras
from dynamic.pytorch import nn

Error Handling

from pycdn import PyCDNRemoteError

try:
    from cdn.nonexistent import something
except PyCDNRemoteError as e:
    print(f"CDN Error: {e.message}")
    print(f"Package: {e.package_name}")
    if e.remote_traceback:
        print(f"Remote traceback: {e.remote_traceback}")

Development Mode

# Configure for development
pycdn.configure(debug=True, timeout=60)

cdn = pycdn.pkg("http://localhost:8000", prefix="dev")
# Enables local fallback, enhanced debugging, mock mode

CDN Management

# View active CDN mappings
mappings = pycdn.get_cdn_mappings()
print(mappings)  # {'cdn': 'http://localhost:8000', 'ml': 'http://ml-cdn:8000'}

# Clear all mappings
pycdn.clear_cdn_mappings()

# Register/unregister specific prefixes
pycdn.register_cdn_client("custom", cdn_client)
pycdn.unregister_cdn_client("custom")

๐Ÿ—๏ธ Server Setup

Deploy packages to your CDN server:

from pycdn.server import CDNServer

# Create CDN server
server = CDNServer(port=8000)

# Deploy packages
server.deploy_package("math", version="1.0.0")
server.deploy_package("numpy", version="1.24.0")
server.deploy_package("openai", version="1.0.0")

# Start server
server.start()

๐ŸŒ Meta Path Import System

PyCDN uses Python's sys.meta_path to intercept imports and resolve them from CDN servers:

import sys
import pycdn

# When you create a CDN connection
cdn = pycdn.pkg("http://localhost:8000", prefix="cdn")

# PyCDN automatically:
# 1. Registers a MetaPathFinder in sys.meta_path
# 2. Maps the 'cdn' prefix to your CDN client
# 3. Intercepts imports starting with 'cdn.'
# 4. Creates proxy objects that execute remotely
# 5. Handles classes, functions, modules transparently

# All of this happens automatically!
from cdn.package import Class  # Intercepted and resolved

๐Ÿ”ง Configuration

# Global configuration
pycdn.configure(
    debug=True,
    timeout=30,
    cache_size="100MB",
    max_retries=3
)

# Per-connection configuration
cdn = pycdn.pkg(
    "http://localhost:8000",
    prefix="cdn",
    timeout=60,
    api_key="your-api-key",
    region="us-east-1",
    cache_size="500MB",
    max_retries=5,
    debug=True
)

๐Ÿ“Š Performance

  • ๐Ÿš€ First call: ~50-100ms (network + execution)
  • โšก Cached calls: ~1-5ms (local cache hit)
  • ๐Ÿ’พ Memory usage: Minimal (only proxy objects stored locally)
  • ๐ŸŒ Global reach: CDN edge servers reduce latency worldwide
  • ๐Ÿ“ˆ Scalability: Automatic scaling based on demand

๐Ÿ›ก๏ธ Security

  • ๐Ÿ”’ Sandboxed execution: Each package runs in isolated environment
  • ๐Ÿ›ก๏ธ Runtime scanning: Real-time security vulnerability detection
  • ๐Ÿšซ Package allowlists: Control which packages can be imported
  • ๐Ÿ” API authentication: Secure CDN access with API keys
  • ๐Ÿ“ Audit logs: Complete execution history and monitoring

๐Ÿงช Examples

Check out our comprehensive examples:

๐Ÿค Contributing

We welcome contributions! Check out our Contributing Guide for details.

๐Ÿ“„ License

Apache-2.0 License - see LICENSE for details.

๐ŸŒŸ Why PyCDN?

Traditional package management is broken:

  • โŒ Long installation times
  • โŒ Dependency conflicts
  • โŒ Storage space waste
  • โŒ Environment inconsistencies
  • โŒ Version management complexity

PyCDN fixes all of this:

  • โœ… Instant access - no installation needed
  • โœ… Zero conflicts - packages run remotely
  • โœ… Minimal storage - only proxy objects locally
  • โœ… Consistent environments - CDN guarantees consistency
  • โœ… Automatic updates - always use latest versions
  • โœ… Natural syntax - import exactly like local packages

PyCDN: The Netflix of Python packages ๐ŸŽฌ
Stream packages instantly, anywhere, anytime!

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

pycdn-1.1.2.tar.gz (83.9 kB view details)

Uploaded Source

Built Distribution

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

pycdn-1.1.2-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file pycdn-1.1.2.tar.gz.

File metadata

  • Download URL: pycdn-1.1.2.tar.gz
  • Upload date:
  • Size: 83.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycdn-1.1.2.tar.gz
Algorithm Hash digest
SHA256 45afbad4f0551d78f0e72403f1c1c0217078e52c079132dd24423057707f50f8
MD5 052694973e48fb7bd701af3bcb757a35
BLAKE2b-256 055f80705d873676ad55bf2e8b8d9db427d2617964c2a89f5ccfc4085c138c9e

See more details on using hashes here.

File details

Details for the file pycdn-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: pycdn-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 48.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycdn-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55d3e4ca4ee51f638de513784d39aa71fdfa83abc79e00ee856cb33bca5db3de
MD5 7d25f237574d9a4c372825bc48c5730a
BLAKE2b-256 91e3ae38496b22a8f60de668c3b9f4329b639eff965b23ee3be25687acd8e9a7

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