From fb2f897f1f3f7215963def9aa8e6eea19d1865f8 Mon Sep 17 00:00:00 2001 From: student_2333 Date: Tue, 12 Nov 2024 12:36:41 +0800 Subject: [PATCH] up --- .github/workflows/pypi-publish.yml | 3 +- pyproject.toml | 4 -- scripts/render.py | 61 +----------------------------- 3 files changed, 4 insertions(+), 64 deletions(-) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index a02d10e..e7ac22a 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -25,6 +25,7 @@ jobs: - name: Build and Publish distribution 📦 to PyPI run: |- - pdm install -G:all + # pdm install --prod pdm render + pdm install -G:all pdm pub-all diff --git a/pyproject.toml b/pyproject.toml index 7313f09..7cc2595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,12 +8,8 @@ readme = "README.md" [tool.pdm.dev-dependencies] dev = [ - "httpx>=0.27.2", - "beautifulsoup4>=4.12.3", - "lxml>=5.3.0", "-e file:///${PROJECT_ROOT}/packages/nonebot-plugin-nailongremove-base#egg=nonebot-plugin-nailongremove-base", "-e file:///${PROJECT_ROOT}/packages/nonebot-plugin-nailongremove#egg=nonebot-plugin-nailongremove", - # "-e file:///${PROJECT_ROOT}/packages/nonebot-plugin-nailongremove-gpu#egg=nonebot-plugin-nailongremove-gpu", ] [build-system] diff --git a/scripts/render.py b/scripts/render.py index cad9789..a5b1cad 100644 --- a/scripts/render.py +++ b/scripts/render.py @@ -1,11 +1,8 @@ import re from pathlib import Path -from typing import List, Optional, TypedDict, cast +from typing import TypedDict -import bs4 -import httpx import tomllib -from packaging.version import Version from .utils import PACKAGES_PATH @@ -50,63 +47,9 @@ def get_version() -> str: VERSION = get_version() -def format_markers(m: re.Match[str]) -> Optional[str]: - g = cast(PkgFilenameReGroups, m.groupdict()) - if (not g["py"].startswith("cp")) or (g["abi"].endswith("m")): - return None - - markers: List[str] = [] - markers.append(f"python_version == '{g['py'][2]}.{g['py'][3:]}'") - - common_os = { - "win": "win32", - "linux": "linux", - } - if x := next((x for x in common_os if g["platform"].startswith(f"{x}_")), None): - markers.extend( - ( - f"sys_platform == '{common_os[x]}'", - f"platform_machine == '{g['platform'][len(x) + 1:]}'", - ), - ) - - return " and ".join(markers) - - -def get_torch_deps() -> str: - def get_deps(pkg: str) -> List[str]: - html = httpx.get(f"{TORCH_INDEX}/{pkg}/").raise_for_status().text - soup = bs4.BeautifulSoup(html, "lxml") - tags: "bs4.ResultSet[bs4.Tag]" = soup.find_all("a") - links = [ - (m, f"{TORCH_BASE}{h}") - for x in tags - if ( - isinstance((h := x.get("href")), str) - and (m := PKG_FILENAME_RE.match(x.text)) - ) - ] - links.sort(key=lambda x: Version(x[0]["ver"]), reverse=True) - ver: str = links[1][0]["ver"] - links = [x for x in links if x[0]["ver"] == ver] - return [f"{pkg} @ {x} ; {ms}" for m, x in links if (ms := format_markers(m))] - - deps = [ - *get_deps("torch"), - *get_deps("torchvision"), - ] - return "\n ".join(f'"{x}",' for x in deps).strip(",") - - -# TORCH = get_torch_deps() - - def process(file_path: Path): file_path.with_name(file_path.name.replace(".template", "")).write_text( - ( - file_path.read_text(encoding="u8").replace("%%version%%", VERSION) - # .replace('"%%torch%%"', TORCH) - ), + file_path.read_text(encoding="u8").replace("%%version%%", VERSION), "u8", )