I'm getting myself thoroughly confused how to correctly package my python3 based application.
My application uses a Makefile to install stuff to the correct file locations e.g.
/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.
When I try to Debian package my rules are very straightforward:
#!/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:
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.
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
Now I know I cannot byte-compile during the build process - Debian rules forbid having a .deb with byte-compiled modules. So somehow I need to get debhelper to work for me.
Looking at the Debian packaging guide they mention stuff like cdbs, distutils etc - any debhelper examples always use syntax like:
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.
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;
dh_python3would just make things easier if you were using distutils. Since you're not, you should simply proceed as if you were using something other than 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_installand 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). The maintainer scripts thatdh_python3produces may provide a good starting point (which you can probably find in most files matching/var/lib/dpkg/info/python3-*.postinstand.postrmon your system).