Build a deb for a Python3 Program that has modules

  deb, debian, linux, python-3.x

I’ve been searching for months for a clean way to build a deb for Linux with a Python3 program that has modules and nothing seems to work well. I’ve tried stdeb but it does not respect my python3 >= 3.6 and it puts the modules in the python3 library so local testing is not simple as I have to change the import back and forth from import stuff to import myscript.stuff as stuff. I find tons of examples that work for a single python file or just don’t work at all.

My example files are:

simqt_0.0-1
   simqt
   simqt.ui
   stuff.py

simqt contains

#!/usr/bin/python3

import sys, os
from functools import partial
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import uic

import stuff

class main(QMainWindow):
    def __init__(self):
        super().__init__()
        path, filename = os.path.split(os.path.realpath(__file__))
        uic.loadUi(os.path.join(path, 'simqt.ui'), self)
        self.setGeometry(50, 50, 500, 300)
        self.setWindowTitle("PyQT5 Minimal!")
        self.pushButton.clicked.connect(partial(stuff.reply, self))
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    gui = main()
    sys.exit(app.exec_())

stuff.py

def reply(parent):
    parent.label.setText("Reply from Stuff")

simqt.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>200</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="1">
     <widget class="QLabel" name="label_2">
      <property name="text">
       <string>Load ui file</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
     </widget>
    </item>
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>Minimal</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
     </widget>
    </item>
    <item row="1" column="0">
     <widget class="QPushButton" name="pushButton">
      <property name="text">
       <string>Get Reply</string>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>400</width>
     <height>25</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

Source: Python-3x Questions

LEAVE A COMMENT