1
0
Fork 0
mirror of https://github.com/EDeev/school_table.git synced 2026-10-07 20:49:37 +03:00

Одиночный SchoolTable.exe: пустая база и иконка вшиты и при первом запуске кладутся рядом; .exe — в релизе отдельным файлом

This commit is contained in:
Деев Егор Викторович 2026-10-06 22:20:47 +03:00
parent 4fe87b12ba
commit 4403827c26
4 changed files with 14 additions and 7 deletions

View file

@ -16,10 +16,10 @@ jobs:
python-version: "3.12"
- run: pip install pyinstaller -r requirements.txt
- name: Сборка .exe
run: pyinstaller --onefile --windowed --icon image.ico --name SchoolTable main.py
run: pyinstaller --onefile --windowed --icon image.ico --add-data "table.db;." --add-data "image.ico;." --name SchoolTable main.py
- name: Архив с программой, пустой базой и иконкой
run: Compress-Archive -Path dist/SchoolTable.exe, table.db, image.ico -DestinationPath SchoolTable-windows.zip
- name: Файл в релиз
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.ref_name }}" SchoolTable-windows.zip --clobber
run: gh release upload "${{ github.ref_name }}" dist/SchoolTable.exe SchoolTable-windows.zip --clobber

View file

@ -26,9 +26,9 @@ on their own. The interface is in Russian.
## Running
A ready-made Windows build is `SchoolTable-windows.zip` in the
[releases](https://github.com/EDeev/school_table/releases): unpack it and run `SchoolTable.exe` (keep
`table.db` next to it).
A ready-made Windows build is in the [releases](https://github.com/EDeev/school_table/releases):
`SchoolTable.exe` — just run it (an empty `table.db` and the icon appear next to it on first start), or
`SchoolTable-windows.zip` — the same with the database and icon in an archive.
From source:

View file

@ -26,8 +26,9 @@
## Запуск
Готовая сборка для Windows — `SchoolTable-windows.zip` в [релизах](https://github.com/EDeev/school_table/releases):
распакуйте и запустите `SchoolTable.exe` (база `table.db` должна лежать рядом).
Готовая сборка для Windows — в [релизах](https://github.com/EDeev/school_table/releases): `SchoolTable.exe` — просто
запустите (при первом запуске рядом появятся пустая база `table.db` и иконка), или `SchoolTable-windows.zip` — то же
с базой и иконкой в архиве.
Из исходников:

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import datetime as dt
import os
import shutil
import sqlite3
import sys
@ -1325,6 +1326,11 @@ class MyWidget(QMainWindow, Ui_MainWindow):
if __name__ == '__main__':
# table.db ищется рядом с программой (или с .exe), а не в текущей папке терминала
os.chdir(os.path.dirname(sys.executable if getattr(sys, "frozen", False) else os.path.abspath(__file__)))
if getattr(sys, "frozen", False):
# одиночный .exe: пустая база и иконка вшиты внутрь и при первом запуске кладутся рядом
for name in ("table.db", "image.ico"):
if not os.path.exists(name):
shutil.copy(os.path.join(sys._MEIPASS, name), name)
app = QApplication(sys.argv)
ex = MyWidget()
ex.show()