how to create a deb package for a python project without

  • Last Update :
  • Techknowledgy :

Until then, you can use dephell to generate the, and poetry to generate the requirements.txt for you as a workaround to keep using the existing tools:

dephell deps convert--from = poetry--to = setuppy
export -f requirements.txt - o requirements.txt

And, during the build, tell your pyproject.tom that you plan to use setuptools for the build instead of poetry:

[build - system]
requires = ["setuptools >= 40.6.0", "wheel"]
build - backend = "setuptools.build_meta"

Suggestion : 2

I have a single python script that I want to distribute as a deb package. It is a indicator which shows local date in Unity panel. I did follow create a .deb Package from scripts or binaries but I could not create a deb package because it fails. , 17 As a packager (and a backporter), I package python scripts fairly often. I can safely say that this answer here is the most complete explanation of what to do to create a package for a single python script. – Thomas Ward ♦ Dec 31, 2011 at 0:24 ,To build the .deb file, you need the git, devscripts, build-essential, lintian, and pandoc packages installed. I'm aware that some of these packages come pre-installed, but I also wanted this guide to work on Debian, so I included them here regardless. You can install them with these commands.,This will create a functional deb package. Lintian is going to throw a few warnings regarding the lack of an orig.tar.gz, but unless you plan on creating a proper upstream project that makes tarball releases you'll probably just want to ignore that for now.

Here's your basic source package layout:

my - script /
   --debian /

debian/copyright should look like:

Upstream-Name: myScript
Upstream-Contact: Name, <email@address>

   Files: *
   Copyright: 2011, Name, <email@address>
      License: (GPL-2+ | LGPL-2 | GPL-3 | whatever)
      Full text of licence.
      Unless there is a it can be found in /usr/share/common-licenses


#!/usr/bin/make -f

dh $ @--with python2


myScript usr / bin /

Open 'control' and type as follows and save it on DEBIAN

Package: mypyscript
Version: 0.01
Architecture: all
Maintainer: your name<your mail id>
   Installed-Size: 2
   Depends: python-appindicator
   Section: extras
   Priority: optional
   Homepage: your homepage
   Description: describe

From now on, unless otherwise mentioned, I will assume you are in the work/hello-world-1.0.0 directory.

work / ├─hello - world - 1.0 .0 / │├─hello - world

Here is the Python script I will use as an example. As mentioned above, it is named hello-world (without a file extension).

#!/usr/bin/env python3

def hello_world():
   print("Hello world!")

if __name__ == "__main__":

First, just make sure that the code works by running it:

$ chmod + x. / hello - world
$. / hello - world
Hello world!

Your directory tree should now look like this

work / ├─hello - world - 1.0 .0 / │├─debian / ││├─source / │││├─format││├─ changelog││├─ compat││├─ control││├─ copyright││├─ install││├─ rules│├─ hello - world

You can mostly ignore this, but if you are wondering, it is explained in §5.22 in the Debian documentation.


Install via:

sudo apt install pkgme

Run via:


This is a Gui Interface to create packages and stuff you can use the PPA also if you dont want to download it from the website that is listed above.

sudo add-apt-repository ppa:antumdeluge/<ppaname>; sudo apt update; sudo apt install debreate

Suggestion : 3

This document shows how to create a Debian package for an existing Python library.,This document shows how to package the existing flask-jwt-extended library into a Debian pacakge.,In this case, as per the, flask-jwt-extended depends on:,This document shows how to create a simple Debian package for a Python library.

$ pip3 download flask - jwt - extended--dest.--no - binary: all: --no - deps
$ mv Flask - JWT - Extended - 3.8 .1.tar.gz flask - jwt - extended - 3.8 .1.tar.gz
$ apt install - y python3 - flask python3 - jwt
$ python3
   import flask >>>
   flask.__file__ # To be sure that this is imported from the system package, not a user - local version '/usr/lib/python3/dist-packages/flask/' >>>
   flask.__version__ '0.12.2' >>>
   import jwt >>>
   jwt.__file__ '/usr/lib/python3/dist-packages/jwt/' >>>
   jwt.__version__ '1.5.3' >>>
$ mkdir flask - jwt - extended - 3.8 .1
$ cd flask - jwt - extended - 3.8 .1
$ git init
$ gbp
import -orig - u 3.8 .1--pristine - tar--sign - tags--no - interactive.. / flask - jwt - extended - 3.8 .1.tar.gz
$ debmake - b ":python3"
$ debmake - b ":python3"
E: unknown python version.check

Suggestion : 4

The bdist command has a --formats option, similar to the sdist command, which you can use to select the types of built distribution to generate: for example,,The usual way to create an RPM of your module distribution is to run the bdist_rpm command:,The RPM format is used by many popular Linux distributions, including Red Hat, SuSE, and Mandrake. If one of these (or any of the other RPM-based Linux distributions) is your usual environment, creating RPM packages for other users of that same distribution is trivial. Depending on the complexity of your module distribution and differences between Linux distributions, you may also be able to create RPMs that work on different RPM-based distributions.,The former allows you to specify RPM-specific options; the latter allows you to easily specify multiple formats in one run. If you need to do both, you can explicitly specify multiple bdist_* commands and their options:

python bdist
python bdist--format = zip
python bdist_rpm
python bdist--formats = rpm
python bdist_rpm --packager="John Doe <>"
python build--plat - name = win - amd64