Skip to main content

A BOM-style dependency management package for Python, similar to Spring Boot Parent

Project description

🌌 Galaxy Bundle

PyPI version Python 3.9+ License: MIT

A BOM-style Dependency Management Package for Python - Similar to Spring Boot Parent POM

Galaxy Bundle 提供了一种类似于 Spring Boot Parent 的依赖管理方式,让你可以:

  • 🔒 锁定依赖版本 - 所有依赖使用经过测试的、相互兼容的版本
  • 📦 Starter 模式 - 按功能分组,一行命令安装所需依赖
  • 🔄 统一升级 - 只需升级 galaxy-bundle,所有依赖同步更新
  • 🛡️ 避免冲突 - 预防依赖版本不兼容的问题

快速开始

安装

# 安装单个 Starter
pip install galaxy-bundle[redis]
pip install galaxy-bundle[kafka]
pip install galaxy-bundle[fastapi]

# 安装多个 Starters
pip install galaxy-bundle[redis,kafka,fastapi]

# 安装组合 Starter(推荐)
pip install galaxy-bundle[microservice]  # 包含 FastAPI + Postgres + Redis + Kafka + 可观测性
pip install galaxy-bundle[api]           # 包含 FastAPI + Postgres + Redis + 可观测性
pip install galaxy-bundle[worker]        # 包含 Celery + Redis + Postgres + 可观测性

# 安装全部(开发环境)
pip install galaxy-bundle[all]

可用 Starters

缓存

Starter 包含的包 安装命令
redis redis, hiredis pip install galaxy-bundle[redis]

消息队列

Starter 包含的包 安装命令
kafka confluent-kafka pip install galaxy-bundle[kafka]
kafka-python kafka-python pip install galaxy-bundle[kafka-python]
rabbitmq pika pip install galaxy-bundle[rabbitmq]
celery celery, redis pip install galaxy-bundle[celery]

数据库

Starter 包含的包 安装命令
postgres psycopg2-binary, asyncpg pip install galaxy-bundle[postgres]
mysql pymysql, aiomysql pip install galaxy-bundle[mysql]
mongodb pymongo, motor pip install galaxy-bundle[mongodb]
sqlalchemy sqlalchemy, alembic pip install galaxy-bundle[sqlalchemy]

Web 框架

Starter 包含的包 安装命令
fastapi fastapi, uvicorn, pydantic, pydantic-settings pip install galaxy-bundle[fastapi]
flask flask, flask-cors, gunicorn pip install galaxy-bundle[flask]
django django, djangorestframework pip install galaxy-bundle[django]

HTTP 客户端

Starter 包含的包 安装命令
http httpx, aiohttp pip install galaxy-bundle[http]
requests requests, urllib3 pip install galaxy-bundle[requests]

AI/ML

Starter 包含的包 安装命令
openai openai, tiktoken pip install galaxy-bundle[openai]
langchain langchain, langchain-core, langchain-community pip install galaxy-bundle[langchain]

可观测性

Starter 包含的包 安装命令
observability opentelemetry-api/sdk/instrumentation, prometheus-client pip install galaxy-bundle[observability]
logging structlog, python-json-logger pip install galaxy-bundle[logging]

测试 & 开发

Starter 包含的包 安装命令
testing pytest, pytest-asyncio, pytest-cov, pytest-mock, httpx, factory-boy, faker pip install galaxy-bundle[testing]
dev ruff, mypy, pre-commit, ipython pip install galaxy-bundle[dev]

🌟 组合 Starters(推荐)

Starter 包含的 Starters 适用场景
web fastapi + http + redis Web 应用
api fastapi + postgres + sqlalchemy + redis + observability API 服务
worker celery + redis + postgres + sqlalchemy + observability 后台任务
microservice fastapi + postgres + sqlalchemy + redis + kafka + http + observability + logging 微服务

编程方式使用

from galaxy_bundle import (
    show_info,           # 显示帮助信息
    show_starters,       # 列出所有可用 Starters
    show_versions,       # 显示所有包版本
    get_version,         # 获取特定包的版本
    VERSIONS,            # 版本字典
)

# 查看信息
show_info()
show_starters()
show_starters('fastapi')  # 查看特定 Starter
show_versions()

# 获取版本
print(get_version('redis'))  # '5.0.0'
print(get_version('fastapi'))  # '0.109.0'

# 生成 requirements.txt
from galaxy_bundle.versions import generate_requirements_txt
print(generate_requirements_txt(['redis', 'fastapi']))

版本策略

Galaxy Bundle 遵循以下版本策略:

  • 主版本 (1.0.0): 重大变更,可能包含不兼容的依赖升级
  • 次版本 (0.1.0): 添加新 Starters 或依赖小版本升级
  • 补丁版本 (0.0.1): 安全修复或 Bug 修复

与 Spring Boot Parent 的对比

特性 Spring Boot Parent Galaxy Bundle
依赖版本管理 ✅ dependencyManagement ✅ extras dependencies
功能分组 ✅ Starters ✅ Starters (extras)
一行安装 ✅ starter 依赖 pip install galaxy-bundle[xxx]
版本锁定 ✅ BOM ✅ pinned versions
统一升级 ✅ 升级 parent ✅ 升级 galaxy-bundle

在项目中使用

pyproject.toml

[project]
dependencies = [
    "galaxy-bundle[microservice]",
]

requirements.txt

galaxy-bundle[api]

贡献

欢迎贡献!请查看 CONTRIBUTING.md 了解更多。

License

MIT License - 详见 LICENSE 文件。

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

galaxy_bundle-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

galaxy_bundle-0.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: galaxy_bundle-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for galaxy_bundle-0.2.0.tar.gz
Algorithm Hash digest
SHA256 700a69824c5e2411407d0ca14448784007eca16599e8e9e7206dfff23e6a259c
MD5 cea2b30f83a07f3aa625c45d7d38c08f
BLAKE2b-256 39d6272cdee06b1f762f2cf0e290e8a5b8942df6d00c67ed4fe41e87bbf8f051

See more details on using hashes here.

File details

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

File metadata

  • Download URL: galaxy_bundle-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for galaxy_bundle-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bd108074a4962a2159c0a40e096bae9f94a7fd72006f193c2034d9c923032a8
MD5 507075ef2a9de360ab237126d39322ad
BLAKE2b-256 68ca87593aa5da34a77db07098c75c670f8dd247713947251e69247855a978a5

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