0

I have a complex program I need to package somehow (by "somehow" I mean PyInstaller is not mandatory, but it seems to be a popular choice, so...) to distribute it to run under Linux with minimal hassle.

Program is very complex and uses several heavyweight libs, including PyQt5, PyQt5-QtWeb, pyqtlet2, matplotlib and numpy.

First stumbling block is pyqtlet2 which is a thin wrapper around Leaflet package (JavaScript).

A simple example:

import os
import sys
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget
from pyqtlet2 import L, MapWidget


class MapWindow(QWidget):
    def __init__(self):
        # Setting up the widgets and layout
        super().__init__()
        self.mapWidget = MapWidget()
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.mapWidget)
        self.setLayout(self.layout)

        # Working with the maps with pyqtlet
        self.map = L.map(self.mapWidget)
        self.map.setView([12.97, 77.59], 10)
        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(self.map)
        self.marker = L.marker([12.934056, 77.610029])
        self.marker.bindPopup('Maps are a treasure.')
        self.map.addLayer(self.marker)
        self.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    widget = MapWindow()
    sys.exit(app.exec_())

lifted directly from pyqtlet2 on GitHub works as expected if launched directly:

python3 -m venv venv
venv/bin/pip install -U pip wheel pyqtlet2[pyqt5] PyInstaller
venv/bin/python test.py

but fails if packaged with PyInstaller:

( . venv/bin/activate ; pyinstaller test.py )
( cd dist/test/ ; ./test )

A quick perusal of generated dist directory shows it doesn't contain the needed pyqtlet2 files, so I assume I need to instruct PyInstaller to handle pyqtlet2, but I don't know how to do that, if at all possible.

Question is: how do I convince PyInstaller to correctly package pyqtlet2?

ZioByte
  • 2,690
  • 1
  • 32
  • 68

1 Answers1

0

I am not sure that it is the best decision, but I add it to command line:

--hidden-import='PyQt5.QtWebEngineWidgets' --hidden-import='pyqtlet'

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 17 '23 at 05:24