如何做Debian包装的Python包? [英] How do I do Debian packaging of a Python package?
问题描述
我需要使用Python包编写或找到一个脚本来创建一个使用python-support的Debian软件包。 Python包将是纯Python,没有C扩展。
I need to write, or find, a script to create a Debian package, using python-support, from a Python package. The Python package will be pure Python with no C extensions.
用于测试目的的Python包将只是一个空的目录,$ _ c $ c> __ init__.py 文件和单个Python模块 package_test.py
。
The Python package for testing purposes will just be a directory with an empty __init__.py
file and a single Python module, package_test.py
.
打包脚本必须使用python-support来提供正确的字节码,以便在目标平台(即Ubuntu Jaunty上的v2.5和v2.6)上进行多次安装Python。
The packaging script must use python-support to provide the correct bytecode for possible multiple installations of Python on a target platform, i.e. v2.5 and v2.6 on Ubuntu Jaunty.
我在google上找到的大多数建议只不过是甚至没有使用python支持或python-central的讨厌的黑客的例子。
Most advice I find while googling are just examples of nasty hacks that don't even use python-support or python-central.
我花了几个小时研究这个,最好的办法是从现有的开源项目中抄袭脚本,但是我不知道哪个
I have spent hours researching this, and the best I can come up with is to hack around the script from an existing open source project, but I don't know which bits are required for what I'm doing.
有没有人在这里以合理的非黑客方式从Python包中创建了Debian包?
Has anyone here made a Debian package out of a Python package in a reasonably non-hacky way?
我开始认为,从Debian包装和python支持的知识到一个工作脚本,我需要一个多星期的时间。多少钱需要别人?
I'm starting to think that it will take me more than a week to go from no knowledge of Debian packaging and python-support to getting a working script. How long has it taken others?
推荐答案
我将使用现有Debian软件包的来源,并替换其中的实际软件包与你的包装要查找依赖于python支持的软件包列表,请执行
I would take the sources of an existing Debian package, and replace the actual package in it with your package. To find a list of packages that depend on python-support, do
apt-cache rdepends python-support
选择一个包架构:所有
,所以它是一个纯Python包。通过这个列表,我发现例如python-flup可能是一个很好的起点。
要获取一个这样的包的来源,请执行
Pick a package that is Architecture: all
, so that it is a pure-Python package. Going through this list, I found that e.g. python-flup might be a good starting point.
To get the source of one such package, do
apt-get source <package>
要构建它,请执行
cd <packagesrc>
dpkg-buildpackage -rfakeroot
编辑时,希望只需要文件 debian
文件夹;使用您自己的软件包名称替换所有对flup的引用。
When editing it, expect that you only need the files in the debian
folder; replace all references to flup with your own package name.
一旦你开始,它应该需要一天的时间才能完成。
Once you get started, it should take you a day to complete.
这篇关于如何做Debian包装的Python包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!