From 7cc1e55de8f8965e1c78b30a36f20964c6638d70 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Mon, 25 Mar 2024 17:41:14 +0800 Subject: [PATCH] chore: update github action versions Signed-off-by: Frost Ming --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 12 +++++------- src/findpython/providers/rye.py | 15 +++++++-------- src/findpython/providers/winreg.py | 4 ++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 427b921..a768ac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: arch: x86 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up PDM - uses: pdm-project/setup-pdm@v3 + uses: pdm-project/setup-pdm@v4 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.arch }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 256ff70..696a56e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 - run: npx changelogithub continue-on-error: true @@ -27,8 +27,7 @@ jobs: python-version: "3.10" - name: Build artifacts run: | - pip install build - python -m build + pipx run build - name: Test Build run: | python -m venv fresh_env @@ -37,5 +36,4 @@ jobs: findpython --all - name: Upload to Pypi run: | - pip install twine - twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} dist/* + pipx run twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} dist/* diff --git a/src/findpython/providers/rye.py b/src/findpython/providers/rye.py index 3c6d605..7eaf892 100644 --- a/src/findpython/providers/rye.py +++ b/src/findpython/providers/rye.py @@ -1,6 +1,6 @@ from __future__ import annotations -import shutil +import os import typing as t from pathlib import Path @@ -10,19 +10,18 @@ class RyeProvider(BaseProvider): - def __init__(self) -> None: - self.root = Path.home() / ".rye" - self.rye_bin = shutil.which("rye") + def __init__(self, root: Path) -> None: + self.root = root @classmethod def create(cls) -> t.Self | None: - return cls() + root = Path(os.getenv("RYE_PY_ROOT", "~/.rye/py")).expanduser() + return cls(root) def find_pythons(self) -> t.Iterable[PythonVersion]: - py_root = self.root / "py" - if not py_root.exists(): + if not self.root.exists(): return - for child in safe_iter_dir(py_root): + for child in safe_iter_dir(self.root): if child.is_symlink(): # registered an existing python continue for intermediate in ("", "install/"): diff --git a/src/findpython/providers/winreg.py b/src/findpython/providers/winreg.py index f5c764c..37b47bd 100644 --- a/src/findpython/providers/winreg.py +++ b/src/findpython/providers/winreg.py @@ -35,10 +35,10 @@ def find_pythons(self) -> t.Iterable[PythonVersion]: except AttributeError: continue if path.exists(): - version = getattr(version.info, "version", None) + py_version = getattr(version.info, "version", None) py_ver = self.version_maker( path, - Version(version) if version else None, + Version(py_version) if py_version else None, getattr(version.info, "sys_architecture", SYS_ARCHITECTURE), path, )