spotify / dh-virtualenv

Python virtualenvs in Debian packages
http://dh-virtualenv.readthedocs.io/en/latest/
GNU General Public License v2.0
1.61k stars 186 forks source link

pkg.triggers is unused if building with --buildsystem=dh_virtualenv #323

Open adammohammed opened 3 years ago

adammohammed commented 3 years ago

When I create a debian/foo.triggers for a package foo, I'd expect a foo.postinst to be in the control archive. The Debian::Debhelper::Buildsystem::dh_virtualenv perl module doesn't handle inserting the trigger scripts into the postinstall templates. So instead the resulting debian control archive is missing the prerm and postinst scripts which would have the code for the trigger to update the virtual environment when there are python interpreter updates.

A sample makefile to reproduce this:

#!/usr/bin/make -f

export DH_VIRTUALENV_INSTALL_ROOT=/opt/venvs
export DH_VIRTUALENV_ARGUMENTS=--python=/usr/bin/python3
export DH_VERBOSE=1

%:
    dh $@ --buildsystem=dh_virtualenv

and then a foo.triggers that contains:

interest-noawait /usr/bin/python3.7
interest-noawait /usr/bin/python3.8
interest-noawait /usr/bin/python3.9

# Also provide a symbolic trigger for all dh-virtualenv packages
interest dh-virtualenv-interpreter-update
adammohammed commented 3 years ago

I think I see how this is supposed to work... I changed the debian/rules to include both --with python-virtualenv and --buildsystem=dh_virtualenv.

The first one changes the debhelper sequence to include running the dh_virtualenv python script which includes the autoscripts, and the buildsystem is needed for compat 12.

If this is the correct way to do it I can PR an update to the docs.

jqueuniet commented 3 years ago

You're not getting an error when you try to use both?

 debian/rules binary
dh binary --buildsystem dh_virtualenv --with python-virtualenv
   dh_update_autotools_config -O--buildsystem=dh_virtualenv
   dh_autoreconf -O--buildsystem=dh_virtualenv
   dh_auto_configure -O--buildsystem=dh_virtualenv
    mkdir -p build/usr/share/python/blade-boot-api
   create-stamp debian/debhelper-build-stamp
   dh_testroot -O--buildsystem=dh_virtualenv
   dh_prep -O--buildsystem=dh_virtualenv
    rm -f -- debian/blade-boot-api.substvars
    rm -fr -- debian/.debhelper/generated/blade-boot-api/ debian/blade-boot-api/ debian/tmp/
   dh_installdocs -O--buildsystem=dh_virtualenv
    install -d debian/blade-boot-api/usr/share/doc/blade-boot-api
    install -d debian/.debhelper/generated/blade-boot-api
    install -p -m0644 debian/copyright debian/blade-boot-api/usr/share/doc/blade-boot-api/copyright
   dh_installchangelogs -O--buildsystem=dh_virtualenv
    install -p -m0644 debian/changelog debian/blade-boot-api/usr/share/doc/blade-boot-api/changelog
   dh_virtualenv -O--buildsystem=dh_virtualenv
Usage: dh_virtualenv [options]

dh_virtualenv: error: no such option: --buildsystem
make: *** [debian/rules:7: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
adammohammed commented 3 years ago

You're right, using both didn't work. I think I ended up adding an override_dh_virtualenv and removing that flag, but then I ended up with an empty venv.

Should those two options be able to work together?

nailor commented 3 years ago

No, the two options should not work at the same time. Unfortunately the buildsystem is in a somewhat subpar state and not actively maintained. I’m happy to accept patches to it though