Packaging a python app for Ubuntu using dh-virtualenv

For a while I've been trying to find the best way to package a python app as a debian file that I can distribute for installing on Ubuntu.
I also didn't necessarily want to rely on the python packages that are distributed with the system because with python you tend to get used to having the latest packages installed through pip.
Then I found dh-virtualenv which is a very neat way of packaging python into debs with the key advantage that these apps are packaged as a virtualenv so that the latest packages can be included without relying on the packages on the system... But system packages can also be used.
In this post I've created an that example illustrates how to package a python script as a .deb using dh-virtualenv. The example can be found on github.

       ExImView/image_app.py


               sudo apt-get install python-dev git

  • Create a virtualenv (so that the latest pip and setuptools can be install and activate)

              virtualenv virt-example   
source ~/virt-example/bin/activate

Build the example debian package of the GUI

Download the example

             git clone https://github.com/benjaminirving/python-debian-packaging-example.git   
cd python-debian-packaging-example
In the folder containing the source run
                
                         dpkg-buildpackage -us -uc -b
                
        
This should build a debian outside the folder that can be installed

Screenshots

The newly created debian package can be installed as you would any other package
[Obviously this is just an illustrative example so make sure that the installed files don't overwrite any existing applications. But I wouldn't expect anything to be called eximview or eximview2]

Explanations of the packaging files



This script is used to copy the .desktop entry, the icon and a bask script to run the app into the appropriate system folders.

eximview2
This is the script that is copied to usr/bin and basically runs the app in the virtualenv that has been created by the deb install.

Notes

Note that this example doesn't take advantage of the main use of dh-virtualenv, which is packaging the latest dependencies with the app. But this can be done trivially by adding them to the requirements.txt file as explained in the dh-virtualenv documentation. ::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::