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
@loaddecorator 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 loadFor detailed documentation, please refer to:
Use the @load decorator to automatically handle dependencies for specific functions:
fromloadimportload_decoratorasload@load('numpy', 'pandas', 'plt=matplotlib.pyplot')defanalyze_data():
importnumpyasnpdata=np.random.rand(10, 3)
plt.plot(data)
plt.show()
# The required packages will be automatically installed when the function is first calledanalyze_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 wayimportnumpyasnpimportpandasaspdimportmatplotlib.pyplotaspltimportseabornassnsfromsklearn.linear_modelimportLinearRegression# With Loadfromloadimportload, import_aliases# Single importnp=load('numpy')
# Multiple imports with aliasespd, plt, sns=import_aliases('pandas', 'plt=matplotlib.pyplot', 'seaborn')
# Direct attribute accessmodel=load('sklearn.linear_model.LinearRegression')()
# Now use them as usualdata=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()fromloadimportload, configure_private_registry# Configure private registryconfigure_private_registry(
name="company",
index_url="https://pypi.company.com/simple/"
)
# Import standard and private packagesfastapi=load('fastapi')
internal_auth=load('company-auth', registry="company")
app=fastapi.FastAPI()
@app.get("/")asyncdefroot():
return {"message": "Hello World"}# Prywatny PyPI firmyconfigure_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żyjcompany_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") # → GitHubload("gitlab.com/user/proj") # → GitLabload("./file.py") # → Lokalny plikload("https://example.com/x.py") # → URL# Najnowsze z GitHub zamiast PyPIml_lib=load("huggingface/transformers")
selenium=load("SeleniumHQ/selenium/py") playwright=load("microsoft/playwright-python")# Skonfiguruj rejestry firmyconfigure_private_registry("nexus", index_url="https://nexus.company.com/pypi/simple/")
configure_private_registry("artifactory",
index_url="https://company.jfrog.io/pypi/simple/")
# Używajauth_lib=load("company-auth", registry="nexus")
internal_api=load("team-api-client", registry="artifactory")defsetup_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ówlist_registries()
# Dodaj własny rejestradd_registry("custom", {
'index_url': 'https://pypi.custom.com/simple/',
'install_cmd': [sys.executable, "-m", "pip", "install", "--index-url"],
'description': 'Custom PyPI mirror'
})
# Szybka konfiguracjaconfigure_private_registry("maven-central", index_url="https://maven.central.com/pypi/")defsetup_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
}defsetup_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
}defsetup_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łaALLOWED_REGISTRIES= ['pypi', 'company', 'github-trusted']
defsecure_load(name, registry=None):
ifregistrynotinALLOWED_REGISTRIES:
raiseSecurityError(f"Registry {registry} not allowed")
returnload(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
fromloadimport*# Podstawowehttp=requests() # PyPIdata=pd() # PyPI + alias# GitHub (najnowsze wersje)ai=load("openai/openai-python") # GitHubml=load("huggingface/transformers") # GitHub# Prywatne firmyauth=load("company-auth", registry="nexus")
api=load("team/api", registry="gitlab")
# Lokalneutils=load("./utils.py")# Skonfiguruj razconfigure_private_registry("company", index_url="https://pypi.company.com/simple/")
# Używaj wszędzieinternal_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! 🚀