首页
/ GitHub Hosted PyPi 项目教程

GitHub Hosted PyPi 项目教程

2024-08-25 10:12:22作者:毕习沙Eudora

1. 项目的目录结构及介绍

GitHub Hosted PyPi 项目的目录结构如下:

github-hosted-pypi/
├── public_hello/
│   └── __init__.py
├── private_hello/
│   └── __init__.py
├── static/
│   ├── style.css
│   └── script.js
├── transformers/
│   └── __init__.py
├── .gitignore
├── LICENSE.md
├── README.md
├── index.html
├── pkg_template.html
└── update_pkgs.py

目录介绍

  • public_hello/private_hello/:包含示例 Python 包的目录。
  • static/:包含静态文件,如 CSS 和 JavaScript 文件。
  • transformers/:另一个示例 Python 包的目录。
  • .gitignore:Git 忽略文件。
  • LICENSE.md:项目许可证文件。
  • README.md:项目说明文件。
  • index.html:主页 HTML 文件。
  • pkg_template.html:包模板 HTML 文件。
  • update_pkgs.py:更新包的 Python 脚本。

2. 项目的启动文件介绍

项目的启动文件是 index.html,这是访问 GitHub Hosted PyPi 索引的入口点。用户可以通过浏览器访问该文件来查看和管理包。

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>GitHub Hosted PyPi</title>
    <link rel="stylesheet" href="static/style.css">
    <script src="static/script.js"></script>
</head>
<body>
    <h1>GitHub Hosted PyPi</h1>
    <p>Your own private PyPi index, github-hosted.</p>
    <!-- 其他内容 -->
</body>
</html>

3. 项目的配置文件介绍

项目的配置文件主要是 update_pkgs.py,这是一个 Python 脚本,用于自动注册、更新和删除索引中的包。

update_pkgs.py

# update_pkgs.py
import os
import requests

def update_package(package_name, version):
    # 更新包的逻辑
    pass

def register_package(package_name, version):
    # 注册新包的逻辑
    pass

def delete_package(package_name):
    # 删除包的逻辑
    pass

# 其他配置和逻辑

该脚本通过调用 GitHub Actions 来实现包的自动管理。用户可以通过触发相应的 GitHub Actions 工作流来执行这些操作。

登录后查看全文
热门项目推荐