Skip to content

Commit

Permalink
Fix Nuitka changed option --include-data-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Erriez committed Aug 5, 2024
1 parent 0e5aae3 commit 3ebeebf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ jobs:
script-name: main.py
output-dir: .
output-file: erriez-midi-sysex-io-linux
include-data-dir: images=images,data=data
include-data-dir: |
images=images
data=data
standalone: true
onefile: true
enable-plugins: pyside6
Expand Down
36 changes: 15 additions & 21 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,15 @@
SYSEX_KN2000_SEQ = bytes([0xf0, 0x50, 0x2d, 0x01, 0x18, 0x10, 0x60])


# Find images with Nuitka build option "--include-data-dir=src=dst"
def resource_path(filename):
# Get the absolute path of the directory containing the executable
exe_dir = os.path.dirname(os.path.abspath(__file__))

# Construct the path to the dst file
dst_path = os.path.join(exe_dir, filename)

# Return the image path
return dst_path
# Path to data and images relative from this script directory
# Used by running Python source and Nuitka deployment executable
path_data = os.path.join(Path(__file__).resolve().parent, 'data')
path_images = os.path.join(Path(__file__).resolve().parent, 'images')


def get_app_version():
app_version = 'Unknown'
version_file = resource_path(r'data/version.txt')
version_file = os.path.join(path_data, 'version.txt')
if version_file:
try:
with open(version_file, 'r') as f:
Expand Down Expand Up @@ -486,7 +480,7 @@ def __init__(self, sysex_file=None, sysex_transmit=False, verbose=False):
# Set window title
self.setWindowTitle('{} v{} by {}'.format(APP_NAME, get_app_version(), APP_DEVELOPER))
# Set window icon
self.setWindowIcon(QIcon(os.path.join(path, 'images', 'midi.png')))
self.setWindowIcon(QIcon(os.path.join(path_images, 'midi.png')))

self.lbl_midi_in = QLabel('MIDI IN:')
self.lbl_midi_out = QLabel('MIDI OUT:')
Expand Down Expand Up @@ -530,22 +524,22 @@ def __init__(self, sysex_file=None, sysex_transmit=False, verbose=False):
menubar = self.menuBar()

# Add File menu
self.file_new_action = QAction(QIcon(os.path.join(path, 'images', 'new.png')), '&New', self)
self.file_new_action = QAction(QIcon(os.path.join(path_images, 'new.png')), '&New', self)
self.file_new_action.setShortcut('Ctrl+N')
self.file_new_action.triggered.connect(self.file_new)

self.file_open_action = QAction(QIcon(os.path.join(path, 'images', 'open.png')), '&Open', self)
self.file_open_action = QAction(QIcon(os.path.join(path_images, 'open.png')), '&Open', self)
self.file_open_action.setShortcut('Ctrl+O')
self.file_open_action.setStatusTip('Open SYSEX file')
self.file_open_action.triggered.connect(self.file_open)

self.file_save_action = QAction(QIcon(os.path.join(path, 'images', 'save.png')), '&Save', self)
self.file_save_action = QAction(QIcon(os.path.join(path_images, 'save.png')), '&Save', self)
self.file_save_action.setShortcut('Ctrl+S')
self.file_save_action.setStatusTip('Save SYSEX to file')
self.file_save_action.setEnabled(False)
self.file_save_action.triggered.connect(self.file_save)

self.file_exit_action = QAction(QIcon(os.path.join(path, 'images', 'exit.png')), '&Exit', self)
self.file_exit_action = QAction(QIcon(os.path.join(path_images, 'exit.png')), '&Exit', self)
self.file_exit_action.setShortcut('Ctrl+Q')
self.file_exit_action.setStatusTip('Exit application')
self.file_exit_action.triggered.connect(self.close)
Expand Down Expand Up @@ -576,18 +570,18 @@ def __init__(self, sysex_file=None, sysex_transmit=False, verbose=False):
menu_edit.addAction(self.select_all_action)

# Add MIDI menu
self.transmit_sysex_action = QAction(QIcon(os.path.join(path, 'images', 'sysex_transmit.png')),
self.transmit_sysex_action = QAction(QIcon(os.path.join(path_images, 'sysex_transmit.png')),
'&Transmit SYSEX', self)
self.transmit_sysex_action.setShortcut('Ctrl+T')
self.transmit_sysex_action.setStatusTip('Transmit SYSEX to device')
self.transmit_sysex_action.setEnabled(False)
self.transmit_sysex_action.triggered.connect(self.midi_transmit_sysex)
self.receive_sysex_action = QAction(QIcon(os.path.join(path, 'images', 'sysex_receive.png')),
self.receive_sysex_action = QAction(QIcon(os.path.join(path_images, 'sysex_receive.png')),
'&Receive SYSEX', self)
self.receive_sysex_action.setShortcut('Ctrl+R')
self.receive_sysex_action.setStatusTip('Receive SYSEX from device')
self.receive_sysex_action.triggered.connect(self.midi_receive_sysex)
self.midi_refresh_action = QAction(QIcon(os.path.join(path, 'images', 'midi.png')), '&Refresh ports', self)
self.midi_refresh_action = QAction(QIcon(os.path.join(path_images, 'midi.png')), '&Refresh ports', self)
self.midi_refresh_action.setShortcut('F5')
self.midi_refresh_action.setStatusTip('Refresh MIDI ports')
self.midi_refresh_action.triggered.connect(self.midi_refresh_ports)
Expand All @@ -614,12 +608,12 @@ def __init__(self, sysex_file=None, sysex_transmit=False, verbose=False):
menu_view.addAction(self.view_statistics_action)

# Add Help menu
self.help_action = QAction(QIcon(os.path.join(path, 'images', 'web.png')), '&Help', self)
self.help_action = QAction(QIcon(os.path.join(path_images, 'web.png')), '&Help', self)
self.help_action.setShortcut('F1')
self.help_action.setStatusTip('Open developers website on Github')
self.help_action.triggered.connect(self.help_website)

self.about_action = QAction(QIcon(os.path.join(path, 'images', 'about.png')), '&About', self)
self.about_action = QAction(QIcon(os.path.join(path_images, 'about.png')), '&About', self)
self.about_action.setShortcut('Ctrl+?')
self.about_action.setStatusTip('About application')
self.about_action.triggered.connect(self.help_about)
Expand Down

0 comments on commit 3ebeebf

Please sign in to comment.