diff --git a/.gitignore b/.gitignore index dec04eb..36fd90c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,11 @@ db.sqlite # Docs docs/ + +# AppImage +AppDir/.DirIcon +AppDir/usr/ +dist/python* +dist/packages/ +dist/appimagetool*.AppImage +dist/ClanStat-*.AppImage diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..00e747d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "3rdparty/colors.sh"] + path = 3rdparty/colors.sh + url = https://git.a2s.su/iiiypuk/colors.sh.git diff --git a/3rdparty/colors.sh b/3rdparty/colors.sh new file mode 160000 index 0000000..b4c1b5e --- /dev/null +++ b/3rdparty/colors.sh @@ -0,0 +1 @@ +Subproject commit b4c1b5e3ee7372b93da0f82123df7363f1af1118 diff --git a/AppDir/AppRun b/AppDir/AppRun new file mode 100755 index 0000000..7d1de13 --- /dev/null +++ b/AppDir/AppRun @@ -0,0 +1,5 @@ +#!/bin/sh + +export PYTHONPATH="${PYTHONPATH}:${APPDIR}/usr/lib/python3.13/site-packages" + +${APPDIR}/usr/bin/python3.13 -m ClanStat $1 diff --git a/AppDir/app.desktop b/AppDir/app.desktop new file mode 100644 index 0000000..bd40532 --- /dev/null +++ b/AppDir/app.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=ClanStat +Icon=shield +Terminal=false +Categories=Utility; diff --git a/AppDir/shield.png b/AppDir/shield.png new file mode 100644 index 0000000..9c5dfd3 Binary files /dev/null and b/AppDir/shield.png differ diff --git a/app/__init__.py b/ClanStat/__init__.py similarity index 100% rename from app/__init__.py rename to ClanStat/__init__.py diff --git a/app/__main__.py b/ClanStat/__main__.py similarity index 97% rename from app/__main__.py rename to ClanStat/__main__.py index 7fe6d71..4e5929a 100644 --- a/app/__main__.py +++ b/ClanStat/__main__.py @@ -7,7 +7,7 @@ from .actions import get_top_wins, get_top_donates async def main(): - """Запускак клиента Telegram""" + """Запуск клиента Telegram""" await client.start() logger.info('Клиент Telegram запущен') diff --git a/app/actions.py b/ClanStat/actions.py similarity index 100% rename from app/actions.py rename to ClanStat/actions.py diff --git a/app/collect.py b/ClanStat/collect.py similarity index 100% rename from app/collect.py rename to ClanStat/collect.py diff --git a/app/db.py b/ClanStat/db.py similarity index 100% rename from app/db.py rename to ClanStat/db.py diff --git a/app/utils.py b/ClanStat/utils.py similarity index 100% rename from app/utils.py rename to ClanStat/utils.py diff --git a/dist/.gitkeep b/dist/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index c07e4bb..46bd33f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ loguru==0.7.2 -pdoc==15.0.1 Pyrogram==2.0.106 python-dotenv==1.0.1 TgCrypto==1.2.5 +psycopg2==2.9.10 diff --git a/scripts/make-appimage.sh b/scripts/make-appimage.sh new file mode 100755 index 0000000..8ec600e --- /dev/null +++ b/scripts/make-appimage.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +# Импортирует скрипт с определениями цветов +source ../3rdparty/colors.sh/colors.sh + +APPDIR="../AppDir" +GIT_HASH=$(git rev-parse --short HEAD) + +# Скачивает x86_64 AppImageTool +download_appimage_tool() { + echo -e "${CYAN}Загрузка AppImageTool...${NC}" + + wget -q --show-progress https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage + chmod +x appimagetool-x86_64.AppImage +} + +# Скачивает March Any Linux Python +download_python() { + wget -q --show-progress https://github.com/niess/python-appimage/releases/download/python3.13/python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage + chmod +x python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage + mv python3.13.3-cp313-cp313-manylinux2014_x86_64.AppImage python3.13 + + mkdir -p ${APPDIR}/usr/bin/ + cp ./python3.13 ${APPDIR}/usr/bin/python3.13 +} + +# Загружает Python зависимости проекта +get_requirements() { + ./python3.13 -m pip install --target=$(pwd)/packages -r ../requirements.txt > /dev/null 2>&1 +} + +# Копирует записимости в AppDir +copy_requirements() { + mkdir -p ${APPDIR}/usr/lib/python3.13/site-packages/ + + cp -r packages/* ${APPDIR}/usr/lib/python3.13/site-packages/ +} + +# Копирует приложение в AppDir +copy_app_files() { + echo -e "${GREEN}Копирование файлов ...${NC}" + rm -rf ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat + + cp -r ../ClanStat ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat + rm -rf ${APPDIR}/usr/lib/python3.13/site-packages/ClanStat/__pycache__ +} + +# Выполянет сборку AppImage +make_appimage() { + echo -e "${GREEN}Сборка AppImage...${NC}" + ./appimagetool-x86_64.AppImage ${APPDIR} > /dev/null 2>&1 + mv ./ClanStat-x86_64.AppImage ./ClanStat-${GIT_HASH}-x86_64.AppImage + + echo -e "${RED}Сборка AppImage заверщена${NC}" +} + +# Основная функция +main() { + clear + + echo -e "${YELLOW}Подготовка к сборке AppImage...${NC}" + if [ ! -f "appimagetool-x86_64.AppImage" ]; then + download_appimage_tool + fi + + if [ ! -f "python3.13" ]; then + download_python + get_requirements + copy_requirements + fi + + copy_app_files + make_appimage +} + +# Запускает основную функцию +main