Skip to content

Commit

Permalink
Pyinstaller build almost working
Browse files Browse the repository at this point in the history
  • Loading branch information
AmberSahdev committed Feb 27, 2024
1 parent 85f62bc commit 1a73ee2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 32 deletions.
3 changes: 0 additions & 3 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from ui import UI


# Imports to make packaging work
import appdirs

class App:
def __init__(self):
self.core = Core()
Expand Down
5 changes: 4 additions & 1 deletion app/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from utils.screen import Screen
from utils.settings import Settings

from pathlib import Path


class LLM:
"""
Expand Down Expand Up @@ -63,7 +65,8 @@ def __init__(self):
if settings_dict['api_key']:
os.environ["OPENAI_API_KEY"] = settings_dict['api_key']

with open('./resources/context.txt', 'r') as file:
path_to_context_file = Path(__file__).resolve().parent.joinpath('resources', 'context.txt')
with open(path_to_context_file, 'r') as file:
self.context = file.read()

if settings_dict['default_browser']:
Expand Down
8 changes: 5 additions & 3 deletions app/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from PIL import Image, ImageTk

from utils.settings import Settings

from pathlib import Path

def open_link(url):
webbrowser.open_new(url)
Expand Down Expand Up @@ -90,8 +90,10 @@ def __init__(self):
self.minsize(420, 250)

# PhotoImage object needs to persist as long as the app does, hence it's a class object.
self.logo_img = ImageTk.PhotoImage(Image.open('resources/icon.png').resize((50, 50)))
self.mic_icon = ImageTk.PhotoImage(Image.open('resources/microphone.png').resize((18, 18)))
path_to_icon_png = Path(__file__).resolve().parent.joinpath('resources', 'icon.png')
path_to_microphone_png = Path(__file__).resolve().parent.joinpath('resources', 'microphone.png')
self.logo_img = ImageTk.PhotoImage(Image.open(path_to_icon_png).resize((50, 50)))
self.mic_icon = ImageTk.PhotoImage(Image.open(path_to_microphone_png).resize((18, 18)))

# MP Queue to facilitate communication between UI and Core.
# Put user requests received from UI text box into this queue which will then be dequeued in App to be sent
Expand Down
22 changes: 0 additions & 22 deletions build.py

This file was deleted.

9 changes: 6 additions & 3 deletions pyinstaller_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
Can never get pyisntaller to work
NOTES:
1. extra steps before using multiprocessing might be required https://www.pyinstaller.org/en/stable/common-issues-and-pitfalls.html#why-is-calling-multiprocessing-freeze-support-required
"""

import PyInstaller.__main__
Expand Down Expand Up @@ -27,9 +30,9 @@ def build():
'--hidden-import=speech_recognition',
# '--windowed', # Remove this if your application is a console program
'--name=Open Interface',
'--add-data=app/resources/icon.png:img',
'--add-data=app/resources/microphone.png:img',
'--add-data=app/resources/context.txt:data',
'--add-data=app/resources/icon.png:resources',
'--add-data=app/resources/microphone.png:resources',
'--add-data=app/resources/context.txt:resources',
'--add-data=app/core.py:.',
'--add-data=app/interpreter.py:.',
'--add-data=app/llm.py:.',
Expand Down

0 comments on commit 1a73ee2

Please sign in to comment.