Load is a modern alternative to Python's import
system, inspired by the simplicity of Go and Groovy. It provides automatic package installation, intelligent caching, and magic import syntax.
Load simplifies Python imports by:
- Reducing boilerplate code
- Automating package installation
- Improving developer productivity
- Making imports more intuitive
- Automatic Package Installation: Missing packages are installed on demand
- Smart Caching: Modules are cached for faster subsequent imports
- Magic Import Syntax: Import with just the package name
- Function-level Imports: Use
@load
decorator to manage dependencies at function level - Multiple Registries: Support for PyPI, GitHub, GitLab, and private registries
- Python 2/3 Compatible: Works across Python versions
Install load using any of these methods:
# 1. Using curl (Linux/macOS/WSL)
curl -sSL https://load.pyfunc.com | python3 -
# 2. Using PowerShell (Windows)
(Invoke-WebRequest -Uri https://load.pyfunc.com -UseBasicParsing).Content | py -
# 3. Using Poetry
poetry add load
# 4. Using pip
pip install load
For detailed documentation, please refer to:
Use the @load
decorator to automatically handle dependencies for specific functions:
from load import load_decorator as load
@load('numpy', 'pandas', 'plt=matplotlib.pyplot')
def analyze_data():
import numpy as np
data = np.random.rand(10, 3)
plt.plot(data)
plt.show()
# The required packages will be automatically installed when the function is first called
analyze_data()
For more examples and advanced usage, see the Decorator Documentation.
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- 📚 Installation Guide
- 💪 Usage Examples
- 🎯 Function-level Imports
- 📦 Features List
- 🔧 API Reference
- 🎯 Examples
- 📊 Diagrams
# Traditional way
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.linear_model import LinearRegression
# With Load
from load import load, import_aliases
# Single import
np = load('numpy')
# Multiple imports with aliases
pd, plt, sns = import_aliases('pandas', 'plt=matplotlib.pyplot', 'seaborn')
# Direct attribute access
model = load('sklearn.linear_model.LinearRegression')()
# Now use them as usual
data = pd.DataFrame({'x': [1, 2, 3], 'y': [1, 2, 3]})
model.fit(data[['x']], data['y'])
plt.scatter(data['x'], data['y'])
plt.plot(data['x'], model.predict(data[['x']]), 'r')
plt.show()
from load import load, configure_private_registry
# Configure private registry
configure_private_registry(
name="company",
index_url="https://pypi.company.com/simple/"
)
# Import standard and private packages
fastapi = load('fastapi')
internal_auth = load('company-auth', registry="company")
app = fastapi.FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
# Prywatny PyPI firmy
configure_private_registry(
name="company",
index_url="https://pypi.company.com/simple/"
)
# Prywatny GitLab z tokenem
configure_private_registry(
name="internal",
base_url="https://gitlab.company.com/",
token="your-token" # lub GITLAB_TOKEN env var
)
# Użyj
company_lib = load("internal-package", registry="company")
secret_tool = load("team/secret-sauce", registry="internal")
Load automatycznie wykrywa skąd ładować:
load("json") # → stdlib (nie instaluje)
load("requests") # → PyPI
load("user/repo") # → GitHub
load("gitlab.com/user/proj") # → GitLab
load("./file.py") # → Lokalny plik
load("https://example.com/x.py") # → URL
# Najnowsze z GitHub zamiast PyPI
ml_lib = load("huggingface/transformers")
selenium = load("SeleniumHQ/selenium/py")
playwright = load("microsoft/playwright-python")
# Skonfiguruj rejestry firmy
configure_private_registry("nexus",
index_url="https://nexus.company.com/pypi/simple/")
configure_private_registry("artifactory",
index_url="https://company.jfrog.io/pypi/simple/")
# Używaj
auth_lib = load("company-auth", registry="nexus")
internal_api = load("team-api-client", registry="artifactory")
def setup_project():
return {
# PyPI - stabilne wersje
'web': load("fastapi"),
'db': load("sqlalchemy"),
# GitHub - najnowsze funkcje
'ai': load("openai/openai-python"),
'scraping': load("microsoft/playwright-python"),
# Prywatne - firmowe narzędzia
'auth': load("auth-service", registry="company"),
'monitoring': load("team/observability", registry="internal"),
# Lokalne - logika biznesowa
'models': load("./models.py"),
'utils': load("./utils.py")
}
# Lista dostępnych rejestrów
list_registries()
# Dodaj własny rejestr
add_registry("custom", {
'index_url': 'https://pypi.custom.com/simple/',
'install_cmd': [sys.executable, "-m", "pip", "install", "--index-url"],
'description': 'Custom PyPI mirror'
})
# Szybka konfiguracja
configure_private_registry("maven-central",
index_url="https://maven.central.com/pypi/")
def setup_ds():
return {
'pd': load("pandas", "pd"), # PyPI
'np': load("numpy", "np"), # PyPI
'latest_sklearn': load("scikit-learn/scikit-learn"), # GitHub
'utils': load("./ds_utils.py") # Local
}
def setup_web():
return {
'api': load("fastapi"), # PyPI
'auth': load("company-sso", registry="nexus"), # Private
'monitoring': load("team/apm-client", registry="gitlab"), # GitLab
'models': load("./models.py") # Local
}
def setup_ai():
return {
'torch': load("pytorch/pytorch"), # GitHub latest
'transformers': load("huggingface/transformers"), # GitHub
'custom_models': load("team/ml-models", registry="company"), # Private
'preprocessing': load("./preprocess.py") # Local
}
- PyPI - podstawowe biblioteki
- GitHub - najnowsze wersje, eksperymenty
- Lokalne pliki - własna logika
- PyPI - sprawdzone, stable biblioteki
- Prywatny PyPI - firmowe pakiety
- GitLab Enterprise - internal repos
- Artifactory/Nexus - cache i security scanning
- GitHub - cutting-edge research code
- PyPI - etablowane biblioteki naukowe
- URL - papers with code, direct downloads
# Kontroluj źródła
ALLOWED_REGISTRIES = ['pypi', 'company', 'github-trusted']
def secure_load(name, registry=None):
if registry not in ALLOWED_REGISTRIES:
raise SecurityError(f"Registry {registry} not allowed")
return load(name, registry=registry)
Problem | Tradycyjnie | Z Load |
---|---|---|
Instalacja | pip install pkg |
load("pkg") |
GitHub repo | Clone, setup.py, pip install | load("user/repo") |
Prywatny rejestr | Konfiguruj pip.conf | load("pkg", registry="company") |
Różne źródła | Różne komendy | load() dla wszystkiego |
Najnowsza wersja | Czekaj na PyPI | load("user/repo") z GitHub |
Load - jeden interfejs do wszystkich rejestrów Python! 🚀
Skopiuj load.py
, napisz from load import *
i ładuj skąd chcesz!
Load z obsługą wszystkich głównych rejestrów Python:
- PyPI (~500k pakietów) -
load("requests")
- GitHub (~miliony repozytoriów) -
load("user/repo")
- GitLab (~setki tysięcy) -
load("gitlab.com/user/proj")
- Prywatne PyPI -
load("pkg", registry="company")
- URL -
load("https://example.com/lib.py")
- Lokalne pliki -
load("./utils.py")
- Smart detection - automatycznie wykrywa skąd ładować
- Auto-install - instaluje co brakuje
- Cache w RAM - szybkie powtórne ładowanie
- Prywatne rejestry - obsługa firmowych PyPI/GitLab z tokenami
- Zero config - działa od razu
from load import *
# Podstawowe
http = requests() # PyPI
data = pd() # PyPI + alias
# GitHub (najnowsze wersje)
ai = load("openai/openai-python") # GitHub
ml = load("huggingface/transformers") # GitHub
# Prywatne firmy
auth = load("company-auth", registry="nexus")
api = load("team/api", registry="gitlab")
# Lokalne
utils = load("./utils.py")
# Skonfiguruj raz
configure_private_registry("company",
index_url="https://pypi.company.com/simple/")
# Używaj wszędzie
internal_lib = load("secret-package", registry="company")
- Jeden interfejs do wszystkich źródeł
- Automatyczne wykrywanie - nie musisz pamiętać skąd co
- Obsługa tokenów dla prywatnych repozytoriów
- Szybkie dzięki cache w RAM
- Proste jak w Go - jedna funkcja
load()
Rezultat: Zamiast kombinować z pip install
, git clone
, konfiguracją pip.conf - po prostu load()
i działa! 🚀