简体   繁体   English

如何在没有 setup.py 的情况下为 python 项目创建 deb package

[英]How to create a deb package for a python project without setup.py

Any documentation I've found about this topic mentions that the "only" requirement to build a deb package is to have a correct setup.py (and requirements.txt ).我发现的有关此主题的任何文档都提到构建 deb package 的“唯一”要求是具有正确的setup.py (和requirements.txt )。 For instance in dh-virtualenv tutorial , stdeb documentation and the Debian's library style guide for python .例如,在dh-virtualenv 教程stdeb 文档Debian 的 python 库样式指南中

But nowadays new (amazing) tools like poetry allow to develop (and upload to PyPI) python projects without any setup.py (this file and several others including requirements.txt are all replaced by pyproject.toml ).但是现在像诗歌这样的新(惊人)工具允许在没有任何setup.py的情况下开发(并上传到 PyPI)python 项目(这个文件和包括requirements.txt在内的其他几个文件都被pyproject.toml替换)。 I believe flit allows this too.我相信flit也允许这样做。

I have developed a python project managed by poetry and would like to package it for Ubuntu/Debian.我已经开发了一个由诗歌管理的 python 项目,并希望将它用于 Ubuntu/Debian。 I guess, as a workaround I can still write a setup.py file that would take its values from pyproject.toml and a requirements.txt file (written by hand using values from poetry.lock ).我想,作为一种解决方法,我仍然可以编写一个setup.py文件,该文件将从pyproject.toml和一个requirements.txt文件中获取它的值(使用来自poetry.lock的值手工编写)。

But, is there a way to do this without any setup.py file?但是,有没有办法在没有任何setup.py文件的情况下做到这一点?

setuptools , and the setup.py file that it requires, has been the de-facto packaging standard in python for the longest time. setuptools和它所需的setup.py文件,一直是 python 中事实上的打包标准最长的时间。 The new package managers you mention were enabled by the introduction of PEP 517 and PEP 518 (or read this for a high-level description on the topic), which provide a standardized way of specifying the build backend without the need of a setup.py (and the ensuing hen-egg problem where you already need setuptools to correctly parse it).您提到的新 package 管理器是通过引入PEP 517PEP 518 (或阅读主题以获得有关该主题的高级描述)启用的,它们提供了一种指定构建后端的标准化方法,而无需setup.py (以及随之而来的鸡蛋问题,您已经需要setuptools来正确解析它)。

Anyway, it's all still very fresh, and the linux packaging community hasn't caught up yet.反正一切还是很新鲜的,linux封装社区还没有赶上。 I found no recent discussion regarding debian packages, but the rpm side sums it up neatly over here .我发现最近没有关于 debian 包的讨论,但是rpm方面在这里总结得很清楚。

So, the short answer is to just wait a while, and google debian packaging pep517 support every now and then.因此,简短的回答是稍等片刻,谷歌debian packaging pep517 support

Until then, you can use dephell to generate the setup.py for you as a workaround:在此之前,您可以使用dephell为您生成setup.py作为解决方法:

dephell deps convert --from=poetry --to=setuppy

And, during the build, tell your pyproject.tom that you plan to use setuptools for the build instead of poetry :并且,在构建过程中,告诉您的pyproject.tom您计划使用setuptools来构建而不是poetry

[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM