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?