diff --git a/build.py b/build.py deleted file mode 100644 index f301d87..0000000 --- a/build.py +++ /dev/null @@ -1,7 +0,0 @@ -# This Python file uses the following encoding: utf-8 - -import PyInstaller.__main__ -import os - -os.system("pyside6-uic form.ui -o ui_form.py") -PyInstaller.__main__.run(['Open-FM.spec']) diff --git a/openfm-qt.pyproject b/openfm-qt.pyproject index d41db86..811e4b4 100644 --- a/openfm-qt.pyproject +++ b/openfm-qt.pyproject @@ -1,3 +1,3 @@ { - "files": ["build.py","openfm_qt/__init__.py","form.ui","main.py","Open-FM.spec","pyproject.toml","openfm_qt/mainwindow.py","icon.ico","README.md","screenshot_linux.png"] +"files": ["build.py","openfm_qt/__init__.py","form.ui","openfm_qt/__main__.py","pyproject.toml","openfm_qt/mainwindow.py","icon.ico","README.md","screenshot_linux.png","build.py"] } diff --git a/openfm_qt/__init__.py b/openfm_qt/__init__.py index a39f6ab..c0f4869 100644 --- a/openfm_qt/__init__.py +++ b/openfm_qt/__init__.py @@ -3,4 +3,5 @@ API_URL = "https://open.fm/radio/api/v2/ofm/stations_slug.json" DEFAULT_VOLUME = 70 +from .ui_form import Ui_MainWindow from .mainwindow import MainWindow diff --git a/main.py b/openfm_qt/__main__.py similarity index 82% rename from main.py rename to openfm_qt/__main__.py index 1671a1b..62493a3 100644 --- a/main.py +++ b/openfm_qt/__main__.py @@ -1,11 +1,14 @@ # This Python file uses the following encoding: utf-8 from PySide6.QtWidgets import QApplication -from openfm_qt import MainWindow +from . import MainWindow import sys -if __name__ == "__main__": +def main(): app = QApplication(sys.argv) widget = MainWindow() widget.show() sys.exit(app.exec()) + +if __name__ == "__main__": + main() diff --git a/openfm_qt/mainwindow.py b/openfm_qt/mainwindow.py index 1ed0051..1f4f309 100644 --- a/openfm_qt/mainwindow.py +++ b/openfm_qt/mainwindow.py @@ -8,10 +8,9 @@ from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput # You need to run the following command to generate the ui_form.py file # pyside6-uic form.ui -o ui_form.py, or # pyside2-uic form.ui -o ui_form.py -from ui_form import Ui_MainWindow import json import requests -from . import API_URL, DEFAULT_VOLUME +from . import API_URL, DEFAULT_VOLUME, Ui_MainWindow class MainWindow(QMainWindow): diff --git a/prebuild.py b/prebuild.py new file mode 100644 index 0000000..78064a4 --- /dev/null +++ b/prebuild.py @@ -0,0 +1,5 @@ +# This Python file uses the following encoding: utf-8 + +import os + +os.system("pyside6-uic form.ui -o openfm_qt/ui_form.py") diff --git a/pyproject.toml b/pyproject.toml index 0bfcc39..c7dbd4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,12 @@ PySide6 = "^6.5.1.1" [tool.poetry.group.dev.dependencies] pyinstaller = "^5.12.0" +[tool.poetry.scripts] +openfm-qt = "openfm_qt.__main__:main" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.poetry.build] +script = "build.py"