如何将开源 Python 包发布到 PyPI 存储库
2022/11/1 23:24:52
本文主要是介绍如何将开源 Python 包发布到 PyPI 存储库,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
项目结构:
myproject-source-dir/ ├── LICENSE ├── pyproject.toml ├── README.md ├── magic_config/ │ └── magic_config/ │ ├── __init__.py │ └── lib.py ├── .gitignore ├── tests/ └── setup.py
Cat pyproject.toml
[build-system] requires = [ "setuptools>=42", "wheel", ] build-backend = "setuptools.build_meta" [project] name = "magic-config" version = "0.1.5" authors = [ { name = "Alexander Majorov", email = "alexander.majorov@gmail.com" }, ] description = "A simple library" readme = "README.md" requires-python = ">=3.10.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] [project.urls] "Homepage" = "https://github.com/frontdevops/magic-config" "Documentation" = "https://github.com/frontdevops/magic-config/blob/main/README.md" "Bug Tracker" = "https://github.com/frontdevops/magic-config/issues"
为了方便起见,为了不对多个文件进行编辑,我这样做是为了使文件从文件中获取所有数据setup.py
pyproject.toml
猫 setup.py
生成分发存档并上传到 PyPi
确保您拥有最新版本并安装了:setuptools
wheel
pip install --user --upgrade setuptools wheel
现在从所在的同一目录运行此命令:setup.py
python -m build python -m twine upload --verbose dist/*
为方便起见,您可以在文件中写入您的登录名:~/.pypirc
这篇关于如何将开源 Python 包发布到 PyPI 存储库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-25Python编程基础:变量与类型
- 2024-11-25Python编程基础与实践
- 2024-11-24Python编程基础详解
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器