Sometimes packages need to perform some kind of post-install step. The distutils way of doing this seems to be by registering an install_data command (see this example). We could generate a debian/.postinst script that calls this command.
For now, the workaroud is to do it manually:
Do "python setup.py debianize" to create a debian directory with stdeb. (You need stdeb in your --command-packages to do this step.) Then create a file in debian/<python-packagename>.postinst which will be run when the package is installed. (Unfortunately, this would not be carried in the plain distutils source, but only in the debian/ directory. Which is why I filed this ticket.)
In terms of previous art, I note that the Enthought enstaller appears to have something like this.
this doesn't seem to work - i create a debian/.postinst script, but it is not executed at installation. what's wrong ?
Sorry, markdown gobbled some important missing characters. The file to create is:
I have updated my entry above to reflect this, but am making a new comment here to note that my initial entry has been updated.
I'm not sure what's going wrong for you. I just verified that it works for me. I created a file called debian/python-svgstack.postinst:
And then build the package with "dpkg-buildpackage -rfakeroot -uc -us" and then install it with "cd ..; sudo dpkg -i python-svgstack_0.0.1-1_all.deb" The output includes "HELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOO".
yep, i hear you on markdown removing stuff, happened to me as well when i updated my first comment. i removed the second part so it doesn't seem quite so confusing to anyone reading this later on.
still no luck on the actual issue though. what i'm doing is this:
1. create a 'debian' folder in the directory that contains the setup.py and stdeb.cfg files
2. in the debian folder, i create a file python-mypackage.postinst which is a shell script that echos a message to indicate it is being called (and also creates a few symlinks). mypackage is the same string i pass as 'name' to the setup function in setup.py.
3. in the folder with setup.py and stdeb.cfg, i run
python setup.py --command-packages=stdeb.command bdist_deb
4. i copy the generated deb_dist/python-mypackage.126.96.36.199-1_all.deb to my local repository and do the usual debian stuff to update the package index
5. i install the package
there is no message during the installation which makes me think the postinst script does not get called. also, the symlinks are not created.
should i see any output during package creation about the postinst script being included in the deb package ?
If you do:
dpkg-deb -e python-mypackage_0.0.1-1_all.deb
And then look in the DEBIAN directory, is there a postinst file and if so, what are its contents?
sorry for the late response, i got sidetracked.
i cleared out all the temporary files in my project folder and went through the package building process again, step by step. both the postinst as well as the prerm scripts are now executed when installing and uninstalling the package. YAY!
case closed - at least as far as i'm concerned.
thanks for your help! :-)
This is a problem for Twisted and all packages which provide plugins for Twisted that want to be installed via stdeb. I would like to recommend users 'sudo pypi-install' rather than 'sudo pip install' as a matter of habit, since dpkg will provide a more reliable installation environment and package removal.
Have a look at this stack overflow question for more details. I hope that someone subscribed to this issue might take a moment to add a workaround that might be able to be included in the setup.py file itself.
I got the same results just by including a debian/package.postinst in my package, and using the standard sdist_dsc and bdist_deb commands.