Skip to main content

Python Package Template

📦 一个快速上传到 PyPI 的 Python Package 模版。

上传到 PyPI 后可以使用 pip install 安装。

1 使用方法

  1. 点击本项目右上角的绿色按钮 Use this template(使用此模板),输入名称和说明,完成创建;

  2. 将项目克隆到本地,这里以本项目为例,实际操作时这里需要替换你自己的项目;

    git clone https://github.com/Ailln/python-package-template.git --depth 1
    
  3. 修改配置,文件中有提示;

    cd your_package_name
    
    # 1. 替换默认项目名称 package_name 为你的项目名称
    # Usage: bash scripts/set_package_name.sh os_name old_name new_name
    # os_name 支持的有 `mac` 和 `linux`
    # old_name 是 package_name
    # new_name 是你的项目名称
    bash scripts/set_package_name.sh mac package_name your_package_name
    
    # 2. 将 `README.md` 修改为你的项目介绍,也就是你当前在读的这个文本。
    
  4. 编写你的 Package 代码,并进行测试。

    # 在本地进行充分测试
    bash scripts/local_test.sh
    
  5. 上传到 PyPi(需要注册),参考如何发布自己的包到 pypi;

    bash scripts/upload_pypi.sh
    
  6. 更新到 Github。

    git push
    

2 项目结构

.
├── package_name # 项目名称
│    ├── shell # 在命令行中执行的代码
│    │    ├── __init__.py
│    │    └── usage.py
│    └── src # 静态资源
│          └── temp.txt
├── scripts
│    ├── set_package_name.sh # 批量替换默认的项目名称
│    ├── local_install.sh
│    ├── local_test.sh
│    └── upload_pypi.sh
├── README.md # 项目文档
├── requirements.txt # 包依赖
├── .gitignore # 忽略文件
├── MANIFEST.in # 要包含在 sdist 命令构建的分发中的文件列表。
├── LICENSE # 这里面的内容为本项目的 License,你需要手动替换它。
└── setup.py # 安装配置

3 TODO

  • 增加 test 相关代码。

4 许可

5 参考

Metadata

Release files for cangjielang 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cangjielang 0.0.1
File Size Uploaded
cangjielang-0.0.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cangjielang 0.0.1
File Interpreter ABI Platform
cangjielang-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / cangjielang-0.0.1.tar.gz

Download URL cangjielang-0.0.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
36303397317ee9f8d868ded78614d3a7e650d7d0962f39aafcb946fd3a85218f
BLAKE2b-256 checksum
How to use checksums
c3f615f78c26419d3d410ae587bfa625a029b87322499df4d5a498ef80535f4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / cangjielang-0.0.1-py3-none-any.whl

Download URL cangjielang-0.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba9e563b690d4a9d331a5416e1947553db28d73fbde380bab4414f6f1b829eb8
BLAKE2b-256 checksum
How to use checksums
1d4a1cb07fb435712588f28b5ffc2b262614ea0f438a26c8a5a86d0633ba009f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page