Skip to main content

A tiny local-first package manager demo with build/publish/install commands

Project description

gp_hub

gp_hub 是一个本地优先的极简包管理系统 MVP,目标是提供类似 pip/npm/cargo 的基础体验。

当前包含六个核心能力:

  • build: 构建项目产物(tar.gz
  • publish: 发布到本地仓库或 HTTP 云仓库
  • install: 从本地仓库或云仓库安装包
  • list: 列出本地仓库或云仓库中的包
  • search: 按关键字搜索本地仓库或云仓库包
  • info: 查看本地仓库或云仓库的包版本详情

并提供三条已安装包查询命令:

  • installed-list: 列出当前项目已安装包
  • installed-search: 按关键字搜索当前项目已安装包
  • installed-info: 查看当前项目已安装包详情

并提供一条卸载命令:

  • uninstall: 删除当前项目已安装包(支持按版本或整包删除)

安装(开发模式)

pip install -e .

快速开始

1) 构建

gp-hub build --project-dir . --dist-dir dist

2) 发布到本地仓库

gp-hub publish dist/gp_hub-0.1.0.tar.gz --repo-dir .gp_hub_repo

2.1) 启动本地模拟云服务(Flask)

gp-hub serve-cloud --host 127.0.0.1 --port 5000 --storage-dir .gp_hub_cloud

2.2) 发布到云(HTTP)

gp-hub publish dist/gp_hub-0.1.0.tar.gz --target cloud --cloud-url http://127.0.0.1:5000

3) 从仓库安装(本地/云)

gp-hub install gp_hub --version 0.1.0 --repo-dir .gp_hub_repo --project-dir .

# 或从云仓库安装
gp-hub install gp_hub --target cloud --cloud-url http://127.0.0.1:5000 --project-dir .

4) 列出仓库包

gp-hub list --repo-dir .gp_hub_repo

5) 搜索仓库包

gp-hub search gp --repo-dir .gp_hub_repo

6) 查看包信息

gp-hub info gp_hub --repo-dir .gp_hub_repo

7) 查询当前项目已安装包

gp-hub installed-list --project-dir .
gp-hub installed-search gp --project-dir .
gp-hub installed-info gp_hub --project-dir .

8) 卸载当前项目已安装包

# 卸载指定版本
gp-hub uninstall gp_hub --version 0.1.0 --project-dir .

# 卸载该包全部已安装版本
gp-hub uninstall gp_hub --project-dir .

配置文件(可选)

支持简单文本配置文件 gp_hub.confkey = value,支持 # 注释):

  • 当前目录:./gp_hub.conf
  • 其次:$HOME/.gp_hub/gp_hub.conf

可配置项:

  • default_target = local|cloud
  • default_cloud_url = http://127.0.0.1:5000
  • default_repo_dir = .gp_hub_repo

命令行参数优先级高于配置文件;当 publish/install/list/search/info 未显式传 --target/--cloud-url/--repo-dir 时,会使用配置默认值。

本地仓库结构

默认仓库目录:.gp_hub_repo/

  • .gp_hub_repo/index.json:包索引
  • .gp_hub_repo/<name>/<version>/<artifact>.tar.gz:产物文件

本地云服务存储目录(模拟云端)默认:.gp_hub_cloud/

  • .gp_hub_cloud/index.json:云包索引
  • .gp_hub_cloud/<name>/<version>/<artifact>.tar.gz:云产物文件

安装记录位于:.gp_hub/installed.json

示例与测试

  • 示例:python examples/example_mvp_flow.py
  • 测试:python -m pytest -q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

gp_hub-0.1.4-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file gp_hub-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: gp_hub-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for gp_hub-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2d25aac3bdd8e9a3b69444a8a9d95219e38e704b3f8f16d0ec23126b24437bce
MD5 9a4d75fd41fc9ec30a688948b49a6346
BLAKE2b-256 61983492e0916b1168562ceab84744d67f6ca4e49510ecbf9ab5877ba0a0762c

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