在Ubuntu上打包发布Python项目,可参考以下步骤:
my_package代码目录、tests测试目录、README.md文档、setup.py配置文件、LICENSE许可证文件等。setup.py:用setuptools定义项目元数据和依赖,例如name、version、packages、install_requires等参数。pip install setuptools wheel安装setuptools和wheel。python setup.py sdist bdist_wheel,生成.tar.gz源分发包和.whl二进制轮子包,存于dist目录。twine工具,使用twine upload dist/*将包上传到PyPI。也可先上传到TestPyPI测试,命令为twine upload --repository-url https://test.pypi.org/legacy/ dist/*。此外,还可使用CI/CD工具如GitHub Actions实现自动化打包发布。