[英]how can I create a debian package to distribute python modules without using distutils?
I'm getting myself thoroughly confused how to correctly package my python3 based application . 我让自己彻底困惑如何正确打包基于python3的应用程序 。
My application uses a Makefile to install stuff to the correct file locations eg 我的应用程序使用Makefile将内容安装到正确的文件位置,例如
/usr/lib/rhythmbox/plugins/foo/myfoo.plugin
/usr/lib/rhythmbox/plugins/foo/myfoo/po/translation.mo
/usr/lib/rhythmbox/plugins/foo/myfoo_module.py
/usr/lib/rhythmbox/plugins/foo/myfoo_module2.py
I'm not using a python distutils setup.py type installation - just a straightforward sudo make install
based method. 我没有使用python distutils setup.py类型安装-只是一个简单的基于sudo make install
的方法。
When I try to Debian package my rules are very straightforward: 当我尝试Debian打包时,我的规则非常简单:
#!/usr/bin/make -f %: dh $@ --parallel --with autoreconf,python3 override_dh_autoreconf: dh_autoreconf -- ./autogen.sh override_dh_auto_configure: dh_auto_configure -- --libdir="\$${exec_prefix}/lib"
My debian/control file "build-depends" is again straightword: 我的debian / control文件“ build-depends”再次是直截了当的:
Build-Depends: debhelper (>= 9), dh-autoreconf, dh-python (>= 1.20130903), gir1.2-glib-2.0, gir1.2-gstreamer-1.0, gir1.2-gtk-3.0, gir1.2-peas-1.0, gir1.2-rb-3.0, gobject-introspection (>= 0.10.0), intltool (>= 0.35.0), libglib2.0-dev, python3
That works just fine - I can run debuild -us -uc
and it creates my .deb and when I install via sudo dpkg -i myfoo-0.1_all.deb
everything is installed in the correct file locations. 那工作得很好-我可以运行debuild -us -uc
并创建我的.deb,当我通过sudo dpkg -i myfoo-0.1_all.deb
安装时,所有内容均安装在正确的文件位置。
Except one small matter - each python module should be byte-compiled so that on installation there is a subfolder /usr/lib/rhythbox/plugins/foo/__pycache__
containing myfoo_module.pyc
and myfoo_module2.pyc
除了一个小问题外,每个python模块都应按字节进行编译,以便在安装时有一个子文件夹/usr/lib/rhythbox/plugins/foo/__pycache__
其中包含myfoo_module.pyc
和myfoo_module2.pyc
Now I know I cannot byte-compile during the build process - Debian rules forbid having a .deb with byte-compiled modules. 现在我知道我无法在构建过程中进行字节编译-Debian规则禁止将.deb与字节编译模块一起使用。 So somehow I need to get debhelper to work for me. 因此,我需要某种方式让debhelper为我工作。
Looking at the Debian packaging guide they mention stuff like cdbs, distutils etc - any debhelper examples always use syntax like: 在查看Debian打包指南时,他们提到了诸如cdbs,distutils等之类的东西-任何debhelper示例始终使用如下语法:
override_dh_auto_install: dh_auto_install python setup.py install --root=$(CURDIR)/debian/$(DEB_SOURCE) --install-layout=deb)
... but I'm not using a distutils setup.py to install my application. ...但是我没有使用distutils setup.py来安装我的应用程序。
So I'm must be missing something pretty obvious - any thoughts? 因此,我必须缺少一些显而易见的东西-有什么想法吗?
You don't need to use distutils or a setup.py to create a valid deb for a Python program; 您无需使用distutils或setup.py即可为Python程序创建有效的deb。 dh_python3
would just make things easier if you were using distutils. dh_python3
只会使事情变得更容易,如果你使用的distutils。 Since you're not, you should simply proceed as if you were using something other than Python. 由于您不是,所以您应该像在使用Python以外的其他东西一样简单地进行操作。
Since I don't know exactly what your structure is, I can't describe the exact steps, but in general you should install the right files to the right places with dh_install
and create appropriate maintainer scripts to do whatever work is necessary for byte-compiling (on install or update) and removing the byte-compiled files (on remove or purge). 由于我不知道确切的结构,因此无法描述确切的步骤,但是通常,您应该使用dh_install
将正确的文件安装到正确的位置,并创建适当的维护程序脚本来执行字节操作所需的任何工作。编译(在安装或更新时)并删除字节编译的文件(在删除或清除时)。 The maintainer scripts that dh_python3
produces may provide a good starting point (which you can probably find in most files matching /var/lib/dpkg/info/python3-*.postinst
and .postrm
on your system). dh_python3
生成的维护程序脚本可以提供一个很好的起点(您可能会在系统上与/var/lib/dpkg/info/python3-*.postinst
和.postrm
匹配的大多数文件中找到该起点)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.