From 99b5c722e1eccaba25c49f8be86e0bc2887c0cf5 Mon Sep 17 00:00:00 2001 From: delewer <108271242+IMDelewer@users.noreply.github.com> Date: Thu, 19 Mar 2026 01:33:12 +0700 Subject: [PATCH] build: migrate deps to pyproject.toml (#201) --- .github/workflows/build.yml | 4 +-- README.md | 39 ++++++++++++++++++--- proxy/__init__.py | 1 + pyproject.toml | 69 +++++++++++++++++++++++++++++++++++++ requirements-win7.txt | 7 +--- requirements.txt | 4 +++ windows.py | 5 +-- 7 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 proxy/__init__.py create mode 100644 pyproject.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac716ee..4bf2274 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: cache: "pip" - name: Install dependencies - run: pip install -r requirements.txt + run: pip install ".[win10]" - name: Install pyinstaller run: pip install "pyinstaller==6.13.0" @@ -58,7 +58,7 @@ jobs: cache: "pip" - name: Install dependencies (Win7-compatible) - run: pip install -r requirements-win7.txt + run: pip install ".[win7]" - name: Install pyinstaller run: pip install "pyinstaller==5.13.2" diff --git a/README.md b/README.md index 68271c4..94562ce 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,34 @@ Telegram Desktop → SOCKS5 (127.0.0.1:1080) → TG WS Proxy → WSS → Telegra ### MacOS (Tray-приложение) +<<<<<<< build/pyproject-migration +```bash +pip install -e ".[win10]" +``` + +### Windows 7 + +```bash +pip install -e ".[win7]" +``` + +### Windows (Tray-приложение) + +```bash +tg-ws-proxy-tray +``` +======= Перейдите на [страницу релизов](https://github.com/Flowseal/tg-ws-proxy/releases) и скачайте **`TgWsProxy.dmg`** — универсальная сборка для Apple Silicon и Intel. 1. Открыть образ 2. Перенести **TG WS Proxy.app** в папку **Applications** 3. При первом запуске macOS может попросить подтвердить открытие: **Системные настройки → Конфиденциальность и безопасность → Всё равно открыть** +>>>>>>> main ### Консольный режим из исходников ```bash -python proxy/tg_ws_proxy.py [--port PORT] [--dc-ip DC:IP ...] [-v] +tg-ws-proxy [--port PORT] [--host HOST] [--dc-ip DC:IP ...] [-v] ``` **Аргументы:** @@ -59,6 +77,7 @@ python proxy/tg_ws_proxy.py [--port PORT] [--dc-ip DC:IP ...] [-v] | Аргумент | По умолчанию | Описание | |---|---|---| | `--port` | `1080` | Порт SOCKS5-прокси | +| `--host` | `127.0.0.1` | Хост SOCKS5-прокси | | `--dc-ip` | `2:149.154.167.220`, `4:149.154.167.220` | Целевой IP для DC (можно указать несколько раз) | | `-v`, `--verbose` | выкл. | Подробное логирование (DEBUG) | @@ -66,13 +85,25 @@ python proxy/tg_ws_proxy.py [--port PORT] [--dc-ip DC:IP ...] [-v] ```bash # Стандартный запуск -python proxy/tg_ws_proxy.py +tg-ws-proxy # Другой порт и дополнительные DC -python proxy/tg_ws_proxy.py --port 9050 --dc-ip 1:149.154.175.205 --dc-ip 2:149.154.167.220 +tg-ws-proxy --port 9050 --dc-ip 1:149.154.175.205 --dc-ip 2:149.154.167.220 # С подробным логированием -python proxy/tg_ws_proxy.py -v +tg-ws-proxy -v +``` + +## CLI-скрипты (pyproject.toml) + +CLI команды объявляются в `pyproject.toml` в секции `[project.scripts]` и должны указывать на `module:function`. + +Пример: + +```toml +[project.scripts] +tg-ws-proxy = "proxy.tg_ws_proxy:main" +tg-ws-proxy-tray = "windows:main" ``` ## Настройка Telegram Desktop diff --git a/proxy/__init__.py b/proxy/__init__.py new file mode 100644 index 0000000..f74f503 --- /dev/null +++ b/proxy/__init__.py @@ -0,0 +1 @@ +__version__ = "1.1.3" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ab2f8c0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,69 @@ +[build-system] +requires = ["hatchling>=1.25.0"] +build-backend = "hatchling.build" + +[project] +name = "tg-ws-proxy" +dynamic=["version"] + +description = "Telegram Desktop WebSocket Bridge Proxy" +readme = "README.md" +requires-python = ">=3.8" + +license = { name = "MIT", file = "LICENSE" } + +authors = [ + { name = "Flowseal" } +] + +keywords = [ + "telegram", + "proxy", + "websocket" +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: Win32 (MS Windows)", + "Intended Audience :: Customer Service", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: Microsoft :: Windows", + "Topic :: System :: Networking :: Firewalls", +] + +dependencies = [ + "customtkinter==5.2.2", + "pystray==0.19.5", + "pyperclip==1.9.0", +] + +[project.optional-dependencies] +win7 = [ + "cryptography==41.0.7", + "Pillow==10.4.0", + "psutil==5.9.8", +] + +win10 = [ + "cryptography==46.0.5", + "Pillow==12.1.1", + "psutil==7.0.0", +] + +[project.scripts] +tg-ws-proxy = "proxy.tg_ws_proxy:main" +tg-ws-proxy-tray = "windows:main" + +[project.urls] +Source = "https://github.com/Flowseal/tg-ws-proxy" +Issues = "https://github.com/Flowseal/tg-ws-proxy/issues" + +[tool.hatch.build.targets.wheel] +packages = ["proxy"] + +[tool.hatch.build.force-include] +"windows.py" = "windows.py" + +[tool.hatch.version] +path = "proxy/__init__.py" diff --git a/requirements-win7.txt b/requirements-win7.txt index 41a8174..f73b306 100644 --- a/requirements-win7.txt +++ b/requirements-win7.txt @@ -1,6 +1 @@ -cryptography==41.0.7 -customtkinter==5.2.2 -Pillow==10.4.0 -psutil==5.9.8 -pystray==0.19.5 -pyperclip==1.9.0 +-e .[win7] diff --git a/requirements.txt b/requirements.txt index ab67f74..e4ecb10 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,10 @@ +<<<<<<< build/pyproject-migration +-e .[win10] +======= cryptography==46.0.5 customtkinter==5.2.2 Pillow==12.1.0 psutil==7.0.0 pystray==0.19.5 pyperclip==1.9.0 +>>>>>>> main diff --git a/windows.py b/windows.py index 8e8ed5d..94ea7b0 100644 --- a/windows.py +++ b/windows.py @@ -9,12 +9,13 @@ import sys import threading import time import webbrowser -import pystray import pyperclip import asyncio as _asyncio -import customtkinter as ctk from pathlib import Path from typing import Dict, Optional + +import pystray +import customtkinter as ctk from PIL import Image, ImageDraw, ImageFont import proxy.tg_ws_proxy as tg_ws_proxy