From 2c35387d66c14e30fe19320f553db1b29125d6aa Mon Sep 17 00:00:00 2001 From: SharzyL Date: Tue, 14 May 2024 01:58:41 +0800 Subject: [PATCH] use PDM, bump toolchain --- .envrc | 1 - .github/workflows/bump-version.yml | 17 ++- .github/workflows/check_version.sh | 2 +- .gitignore | 3 + CHANGELOG.md | 1 + Dockerfile | 36 ++--- doc/deploy.md | 13 +- flake.lock | 14 +- flake.nix | 13 +- nix/searcher-pkg.nix | 33 ++++- pdm.lock | 210 +++++++++++++++++++++++++++++ pyproject.toml | 50 +++++++ setup.py | 49 ------- tg_searcher/__init__.py | 2 + tg_searcher/__main__.py | 2 +- 15 files changed, 348 insertions(+), 98 deletions(-) delete mode 100644 .envrc create mode 100644 pdm.lock create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.envrc b/.envrc deleted file mode 100644 index 175de89..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -layout python diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index d91db1c..c7baccc 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -9,19 +9,18 @@ jobs: push_to_pypi: name: Push package to PyPI runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check version run: bash .github/workflows/check_version.sh - - name: Build and upload package - run: | - python3 -m pip install build twine - python3 -m build . - python3 -m twine upload --non-interactive --skip-existing dist/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} + - uses: pdm-project/setup-pdm@v3 + + - name: Publish package distributions to PyPI + run: pdm publish diff --git a/.github/workflows/check_version.sh b/.github/workflows/check_version.sh index 3218ef4..ffaaf56 100644 --- a/.github/workflows/check_version.sh +++ b/.github/workflows/check_version.sh @@ -3,6 +3,6 @@ set -xe version=$(git tag --points-at=HEAD | head -1) [ "${version:0:1}" = "v" ] version=${version:1} -grep -q "$version" __version__ +grep -q "$version" tg_searcher/__init__.py grep -q "\[$version\]" CHANGELOG.md diff --git a/.gitignore b/.gitignore index 00d4387..e4aa675 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ __pycache__ *.egg-info /.direnv +.envrc +.pdm-python +.pdm-build diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff45b9..f984868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Changed - When downloding history, now the backend will store all messages in memory and write them to index at once, to avoid blocking regular update +- Use PDM package manager ## [0.4.0] - 2023.2.2 diff --git a/Dockerfile b/Dockerfile index c17daae..cc5b625 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,23 @@ -FROM python:3.9 AS BUILDER -# Because cryptg builds some native library -# use multi-stage build reduce image size +ARG PYTHON_BASE=3.9-slim +FROM python:$PYTHON_BASE AS builder -WORKDIR /app +# install PDM +RUN pip install -U pdm +ENV PDM_CHECK_UPDATE=false +COPY pyproject.toml pdm.lock README.md /project/ +COPY tg_searcher /project/tg_searcher -COPY . /app +# install dependencies and project into the local packages directory +WORKDIR /project +RUN pdm install --check --prod --no-editable -RUN pip install \ - --no-cache-dir \ - --trusted-host pypi.python.org \ - --disable-pip-version-check \ - /app +# run stage +FROM python:$PYTHON_BASE -FROM python:3.9-slim +# retrieve packages from build stage +COPY --from=builder /project/.venv/ /project/.venv +ENV PATH="/project/.venv/bin:$PATH" +COPY tg_searcher /project/tg_searcher +WORKDIR /project +CMD ["python", "tg_searcher/__main__.py"] -RUN mkdir /usr/local/lib/python3.9 -p -COPY --from=BUILDER \ - /usr/local/lib/python3.9/site-packages \ - /usr/local/lib/python3.9/site-packages - -ENTRYPOINT ["python", "-m", "tg_searcher"] -CMD ["-f", "./config/searcher.yaml"] diff --git a/doc/deploy.md b/doc/deploy.md index 037a191..074b8a1 100644 --- a/doc/deploy.md +++ b/doc/deploy.md @@ -2,11 +2,11 @@ 我们提供了三种部署的方法:手动部署,使用 docker-compose 部署和 nix flake 部署。 -## 手动运行 +## 手动运行(使用 PDM) 1. 安装 Redis 并运行(可以按照[这里](https://redis.io/topics/quickstart)的操作指示)。 -2. 确保 python 版本在 3.7 或以上。 +2. 安装 PDM 包管理器(参考[官方文档](https://pdm-project.org/en/latest/#installation))。 ```shell script # install from pip @@ -15,12 +15,17 @@ python3 -m pip install -U tg-searcher # or install from github python3 -m pip install -U git+https://github.com/SharzyL/tg_searcher -# or install locally +# or install locally, using PDM package manager git clone https://github.com/SharzyL/tg_searcher && cd tg_searcher python3 -m pip install -e . ``` -参考 [configuration.md](./configuration.md) 填写配置文件之后,运行 `python3 -m tg_searcher -f /path/to/config.yaml` 即可。如果 pip 安装可执行文件的目录在 `PATH` 中,也可以直接 `tg-searcher -f /path/to/config.yaml`。 +3. 参考 [configuration.md](./configuration.md) 填写配置文件之后, +```console +$ pdm install + +$ pdm run start -f /path/to/config.yaml +``` 首次运行时需要填写验证码(如果设置了两步验证,还需填写密码)。运行成功后 bot 会在 Telegram 中向管理员发送一条包含服务器状态的消息。 diff --git a/flake.lock b/flake.lock index 11e2719..da39612 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -19,10 +19,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699781429, - "narHash": "sha256-UYefjidASiLORAjIvVsUHG6WBtRhM67kTjEY4XfZOFs=", - "path": "/nix/store/0y446mjvwzrhv723jh0lpkaz9gw8jzbq-source", - "rev": "e44462d6021bfe23dfb24b775cc7c390844f773d", + "lastModified": 1715266358, + "narHash": "sha256-doPgfj+7FFe9rfzWo1siAV2mVCasW+Bh8I1cToAXEE4=", + "path": "/nix/store/asymc3nsl739p1wwr0w6xbjnqs3qb94p-source", + "rev": "f1010e0469db743d14519a1efd37e23f8513d714", "type": "path" }, "original": { diff --git a/flake.nix b/flake.nix index b3449b2..1e56d19 100644 --- a/flake.nix +++ b/flake.nix @@ -19,13 +19,16 @@ inherit system; overlays = [ overlay ]; }; - tg-searcher = pkgs.tg-searcher; + pkg = pkgs.tg-searcher; in { - packages.default = tg-searcher; - legacyPackages = pkgs; - devShells.default = tg-searcher; - apps.default = flake-utils.lib.mkApp { drv = tg-searcher; }; + packages.default = pkg; + + devShell = pkg.overrideAttrs (oldAttrs: { + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.pdm ]; + }); + + apps.default = flake-utils.lib.mkApp { drv = pkg; }; } ) // { diff --git a/nix/searcher-pkg.nix b/nix/searcher-pkg.nix index 9ecbd02..6ea2448 100644 --- a/nix/searcher-pkg.nix +++ b/nix/searcher-pkg.nix @@ -1,5 +1,8 @@ { buildPythonPackage +, fetchFromGitHub , lib +, pdm-backend + , whoosh , telethon , jieba @@ -9,19 +12,43 @@ , cryptg }: +let + telethon_1_35 = telethon.overridePythonAttrs (oldAttrs: rec { + version = "1.35.1"; + src = fetchFromGitHub { + owner = "LonamiWebs"; + repo = "Telethon"; + rev = "refs/tags/v${version}"; + hash = "sha256-expJdVvR8yxVC1e+v/hH81TKZ1HJceWBv6BqD15aOFU="; + }; + doCheck = false; + }); +in buildPythonPackage { - version = lib.removeSuffix "\n" (builtins.readFile ../__version__); + version = lib.head + (builtins.match ".*__version__ = \"([0-9.]+)\".*" + (builtins.readFile ./../tg_searcher/__init__.py)); + + pyproject = true; + nativeBuildInputs = [ pdm-backend ]; + pname = "tg-searcher"; - src = builtins.path { path = ./..; name = "tg-searcher"; }; + + src = with lib.fileset; toSource { + root = ./..; + fileset = fileFilter (file: file.name != "flake.nix" && file.name != "nix") ./..; + }; + propagatedBuildInputs = [ whoosh - telethon + telethon_1_35 jieba python-socks pyyaml redis cryptg ]; + doCheck = false; # since we have no test } diff --git a/pdm.lock b/pdm.lock new file mode 100644 index 0000000..0ba6af6 --- /dev/null +++ b/pdm.lock @@ -0,0 +1,210 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + +[metadata] +groups = ["default"] +strategy = ["cross_platform", "inherit_metadata"] +lock_version = "4.4.1" +content_hash = "sha256:e1d8106e4d5087de1288ef03d8e7815d9374c7e521092fae020f82ef4f085374" + +[[package]] +name = "async-timeout" +version = "4.0.3" +requires_python = ">=3.7" +summary = "Timeout context manager for asyncio programs" +groups = ["default"] +files = [ + {file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"}, + {file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"}, +] + +[[package]] +name = "cryptg" +version = "0.4.0" +requires_python = ">=3.7" +summary = "Cryptographic utilities for Telegram." +groups = ["default"] +files = [ + {file = "cryptg-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:59a6c881535bd3ff406855122484daf46a3f7b105a3c9e0cde294ff72e68f4e8"}, + {file = "cryptg-0.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:7a045a8af59814a50787cce9965743fa67e6c4b948305139aa3c216ecfb45b7f"}, + {file = "cryptg-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cabdd52e7f3e24a800b4769d9e4b9da45aeb7065b986c16fc946e6798ed09525"}, + {file = "cryptg-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67d408d335f99dd850f69fb2aed99e6469e6e046d5d4b870271bc932d7f102d4"}, + {file = "cryptg-0.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3cbf215e88f07656ac96bb59efa04d27134be85788e14d4f3898ee0b2a7f7d70"}, + {file = "cryptg-0.4.0-cp310-cp310-win32.whl", hash = "sha256:9f2f63aa12965e99824a05147b4cef26c4988630181f8e55f13050d7ac86bbc5"}, + {file = "cryptg-0.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:adcf175908a93557ef2e53ffba62706ae4afb8bb3489cecc6672c7c9d99585ef"}, + {file = "cryptg-0.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:88df8cd6f2222570f34ee054a7a92d3c44816acc689bbbebe9a95f94f328c1a3"}, + {file = "cryptg-0.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ad2c2a615dbd64b35f42ceca7f1f3ccc7c3f1275d833ae7eac3e4672678a8e96"}, + {file = "cryptg-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a0fbaf9de1166ace65a3c589ef9db5b42d88728ae5f6b3ebe6f42846efc72d7"}, + {file = "cryptg-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:96f4415910dec41671a422d7fc29cef434b62e8c84908bf8e585a9dac66caa71"}, + {file = "cryptg-0.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:16d33f8213f480e895eab0bad6faaedd8d54da51b066373ccd5840a7a951dd37"}, + {file = "cryptg-0.4.0-cp311-cp311-win32.whl", hash = "sha256:72875d7129cdb7f9a4be68854c77cb569857d736f0cbc7753cadc577f13360bd"}, + {file = "cryptg-0.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:47a249a242497ba0fffe87067e0d5ef99b21c4081fe490a08c596b6184dda2dd"}, + {file = "cryptg-0.4.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2da433484653470cba6b3e8c4c874ea9ba142c66d0214968c58ec8bed1fb5981"}, + {file = "cryptg-0.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:951ebab677abfa661356eff578988eb3e9d5e6e6b46c876731051a01616cfb18"}, + {file = "cryptg-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c720ebec7c5fe65d6843a24495a4012b02fbca98f93a687f143864fa1333949a"}, + {file = "cryptg-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb564dbc370476e299c56d35a33aa8b8ec3df00184d5c78a0f73eebc2a3f057c"}, + {file = "cryptg-0.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d1e547e5ca4665d413397a43453ad867a78b0959362a056460ee3f4936da6728"}, + {file = "cryptg-0.4.0-cp312-cp312-win32.whl", hash = "sha256:975e53f1d713ef5733bf160ef1dce473519c93e5d27ec19013766f1f81224b0f"}, + {file = "cryptg-0.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:6a914b1b7199b9bb0bb20a11572f160bdc23b50575895112ca37395f2ad598db"}, + {file = "cryptg-0.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c781f20b30a0831c9d1e7cc55526f854c57ece147a2ccc9d290c7e230cd6c7a1"}, + {file = "cryptg-0.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4c1ca745b5e90513a7a58d1dc982d6fd96e3a3e23065c0147c2ed192aa2e1e88"}, + {file = "cryptg-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8eaeeb065b7a2ef8d5e8006e64821dae73890e9fba95749804babfefcc7e29b7"}, + {file = "cryptg-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:05df4812d592410c3e738207368cc6ee3d757401f979eb76281343e1f28f4b8a"}, + {file = "cryptg-0.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:932e131a73bc1bd01457c8eaecb04b91f714051d0ba549f5301e4545d294628a"}, + {file = "cryptg-0.4.0-cp39-cp39-win32.whl", hash = "sha256:717c65ca5c753d89b111938329379df59ffd43b80678c07e4338ff46be554a72"}, + {file = "cryptg-0.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:64f205d02fbadfe5415e3050388727c9de65eaea20948d8fd444b73a391f54fa"}, + {file = "cryptg-0.4.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:b29dc778f811db9a1ca40cae9f187e9413c0592c8ea404f63356583a54f81fcd"}, + {file = "cryptg-0.4.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5658eb76f46315e2539e831a9f53117cd908ccc95faa053df77fadf7e7a35e16"}, + {file = "cryptg-0.4.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7459b9d4a79bccba6e31d3e955245659ee813466ab048881958757bb799602e7"}, + {file = "cryptg-0.4.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a03b9a11ddb133dabbd642386a8d6f66af8e691faf5a18a99a39c4658df7aa9e"}, + {file = "cryptg-0.4.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:551c8452fce4601b01d5a6490738683bc46e67a9201626267309369672d0e3f3"}, + {file = "cryptg-0.4.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:39e89cca35430569d79db118da9112efc7d4834b5bb5db1d1674afaca6d78e8f"}, + {file = "cryptg-0.4.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:edb0e7dd994d6547e24fdec41facd373fbe31f9551edc3258da17a82838a6442"}, + {file = "cryptg-0.4.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c7a5052c81e27cb13e4d4354caf3619d27bea8cf2da2dcad2a1e225119054a7"}, + {file = "cryptg-0.4.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a05e20b992b46413204df78349c70a41753ee98d487e8e681f060f87bf813c51"}, + {file = "cryptg-0.4.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:52e05ccaafed67d827690303e745facd7a16576d7e06bf3a83d2d94349c16b97"}, + {file = "cryptg-0.4.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7c4c34377bbf69b1124953c38a14fc18e28e7871006ae7d0686a2d84b600ef83"}, + {file = "cryptg-0.4.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8514d9300bc846825391bfebf7148d163456a882ecf32d2cd7347c5234745927"}, + {file = "cryptg-0.4.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94573f1eeec18871c54b866eed942f85011f093eac7dd0ed387e18f3e2ae4568"}, + {file = "cryptg-0.4.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c60cf65e9cb0fcdf67353b003b8459e06a987933f957d47f578492527be522e5"}, + {file = "cryptg-0.4.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:4d5f4021285ec0784019a1d52e435af2f1ecfd3f05a44681410efc84f1e413b4"}, + {file = "cryptg-0.4.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2a40dc8167d7a00d8ebc08784e022dcfa8919d0540c0956cf6a3b067a0233314"}, + {file = "cryptg-0.4.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3940c533af77128ea56fa7420ee652f1d061d0de09dd8a38ac493228bf170b64"}, + {file = "cryptg-0.4.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fa16e8691d83d5c665e4bdf82a2a66257fecc5d32b60d888c95a7f5caa154d0d"}, + {file = "cryptg-0.4.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0f3200c8c783c11198373a1e614654df88617b4ca260700e155d7be8c3144e7b"}, + {file = "cryptg-0.4.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:19b61547eead81a3a8aca68e30673d439fc577dedd068d86d970da923035471d"}, + {file = "cryptg-0.4.0.tar.gz", hash = "sha256:38f918c685c305569d7cee3795a932e28f61e633eeac452032a76f242ae7eb69"}, +] + +[[package]] +name = "jieba" +version = "0.42.1" +summary = "Chinese Words Segmentation Utilities" +groups = ["default"] +files = [ + {file = "jieba-0.42.1.tar.gz", hash = "sha256:055ca12f62674fafed09427f176506079bc135638a14e23e25be909131928db2"}, +] + +[[package]] +name = "pyaes" +version = "1.6.1" +summary = "Pure-Python Implementation of the AES block-cipher and common modes of operation" +groups = ["default"] +files = [ + {file = "pyaes-1.6.1.tar.gz", hash = "sha256:02c1b1405c38d3c370b085fb952dd8bea3fadcee6411ad99f312cc129c536d8f"}, +] + +[[package]] +name = "pyasn1" +version = "0.6.0" +requires_python = ">=3.8" +summary = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)" +groups = ["default"] +files = [ + {file = "pyasn1-0.6.0-py2.py3-none-any.whl", hash = "sha256:cca4bb0f2df5504f02f6f8a775b6e416ff9b0b3b16f7ee80b5a3153d9b804473"}, + {file = "pyasn1-0.6.0.tar.gz", hash = "sha256:3a35ab2c4b5ef98e17dfdec8ab074046fbda76e281c5a706ccd82328cfc8f64c"}, +] + +[[package]] +name = "python-socks" +version = "2.4.4" +summary = "Core proxy (SOCKS4, SOCKS5, HTTP tunneling) functionality for Python" +groups = ["default"] +files = [ + {file = "python-socks-2.4.4.tar.gz", hash = "sha256:e5a8e4f78203612c813946feacd87b98943965a04389fe221fa1e9ab263ad22e"}, + {file = "python_socks-2.4.4-py3-none-any.whl", hash = "sha256:fda465d3ef229119ee614eb85f2b7c0ad28be6dd40e0ef8dd317c49e8725e514"}, +] + +[[package]] +name = "pyyaml" +version = "6.0.1" +requires_python = ">=3.6" +summary = "YAML parser and emitter for Python" +groups = ["default"] +files = [ + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, +] + +[[package]] +name = "redis" +version = "5.0.4" +requires_python = ">=3.7" +summary = "Python client for Redis database and key-value store" +groups = ["default"] +dependencies = [ + "async-timeout>=4.0.3; python_full_version < \"3.11.3\"", +] +files = [ + {file = "redis-5.0.4-py3-none-any.whl", hash = "sha256:7adc2835c7a9b5033b7ad8f8918d09b7344188228809c98df07af226d39dec91"}, + {file = "redis-5.0.4.tar.gz", hash = "sha256:ec31f2ed9675cc54c21ba854cfe0462e6faf1d83c8ce5944709db8a4700b9c61"}, +] + +[[package]] +name = "rsa" +version = "4.9" +requires_python = ">=3.6,<4" +summary = "Pure-Python RSA implementation" +groups = ["default"] +dependencies = [ + "pyasn1>=0.1.3", +] +files = [ + {file = "rsa-4.9-py3-none-any.whl", hash = "sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7"}, + {file = "rsa-4.9.tar.gz", hash = "sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21"}, +] + +[[package]] +name = "telethon" +version = "1.35.0" +requires_python = ">=3.5" +summary = "Full-featured Telegram client library for Python 3" +groups = ["default"] +dependencies = [ + "pyaes", + "rsa", +] +files = [ + {file = "Telethon-1.35.0.tar.gz", hash = "sha256:99d7a2e161e9af1cdf03feef7a3fea6eef304a9caf620fe13aefc53099845555"}, +] + +[[package]] +name = "whoosh" +version = "2.7.4" +summary = "Fast, pure-Python full text indexing, search, and spell checking library." +groups = ["default"] +files = [ + {file = "Whoosh-2.7.4-py2.py3-none-any.whl", hash = "sha256:aa39c3c3426e3fd107dcb4bde64ca1e276a65a889d9085a6e4b54ba82420a852"}, + {file = "Whoosh-2.7.4.tar.gz", hash = "sha256:7ca5633dbfa9e0e0fa400d3151a8a0c4bec53bd2ecedc0a67705b17565c31a83"}, + {file = "Whoosh-2.7.4.zip", hash = "sha256:e0857375f63e9041e03fedd5b7541f97cf78917ac1b6b06c1fcc9b45375dda69"}, +] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8e58410 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[project] +name = "tg-searcher" +dynamic = [ "version" ] +description = "Telegram searcher bot for Chinese" +readme = "README.md" +authors = [ + {name = "SharzyL", email = "me@sharzy.in"}, +] +dependencies = [ + "Telethon<2.0.0,>=1.32.0", + "python-socks<3.0.0,>=2.4.4", + "cryptg<1.0.0,>=0.4.0", + "async-timeout<5.0.0,>=4.0.3", + "jieba>=0.42.1", + "pyyaml>=6.0.1", + "redis>=5.0.3", + "whoosh>=2.7.4", +] +requires-python = "<4.0,>=3.9" +license = {text = "MIT"} +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", + "Intended Audience :: End Users/Desktop", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Topic :: Communications :: Chat", + "Topic :: Utilities" +] + +[project.urls] +changelog = "https://github.com/SharzyL/tg_searcher/blob/master/CHANGELOG.md" +homepage = "https://github.com/SharzyL/tg_searcher" +repository = "https://github.com/SharzyL/tg_searcher.git" + +[project.scripts] +tg-searcher = "tg_searcher:main" + +[tool.pdm.scripts] +start = { call = "tg_searcher:main" } + +[tool.pdm.version] +source = "file" +path = "tg_searcher/__init__.py" + +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" + diff --git a/setup.py b/setup.py deleted file mode 100644 index da36203..0000000 --- a/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -from setuptools import setup, find_packages - -import pathlib -here = pathlib.Path(__file__).parent.resolve() -long_description = (here / 'README.md').read_text(encoding='utf-8') - -__version__ = (here / '__version__').read_text().strip() - -setup( - name='tg-searcher', - version=__version__, - packages=find_packages(), - description='Telegram searcher bot for Chinese', - long_description=long_description, - long_description_content_type="text/markdown", - include_package_data=True, - package_data={ - 'tg_searcher': ['../__version__'], - }, - author='Sharzy L', - author_email='me@sharzy.in', - url='https://github.com/SharzyL/tg_searcher', - license='MIT', - python_requires='>=3.8', - install_requires=[ - 'telethon~=1.32.1', - 'cryptg', - 'whoosh~=2.7.4', - 'python-socks[asyncio]', - 'jieba', - 'pyyaml', - 'redis', - ], - classifiers=[ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: MIT License", - "Intended Audience :: Developers", - "Intended Audience :: End Users/Desktop", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Topic :: Communications :: Chat", - "Topic :: Utilities" - ], - entry_points={ - 'console_scripts': ['tg-searcher=tg_searcher:main'] - } -) - diff --git a/tg_searcher/__init__.py b/tg_searcher/__init__.py index c28a133..89c6a93 100644 --- a/tg_searcher/__init__.py +++ b/tg_searcher/__init__.py @@ -1 +1,3 @@ from .main import main + +__version__ = "0.4.0" diff --git a/tg_searcher/__main__.py b/tg_searcher/__main__.py index 5d6a810..aeeb79e 100644 --- a/tg_searcher/__main__.py +++ b/tg_searcher/__main__.py @@ -1,3 +1,3 @@ -from .main import main +from tg_searcher.main import main main()