From 4ccd22904b9ae76541019abca163d937e7e69562 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 9 Apr 2026 21:45:43 +0900 Subject: [PATCH 1/7] add lib dir to dynamic linker path on macos --- qret_cli_bundle/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qret_cli_bundle/__init__.py b/qret_cli_bundle/__init__.py index 7b3a74a..744108e 100644 --- a/qret_cli_bundle/__init__.py +++ b/qret_cli_bundle/__init__.py @@ -98,6 +98,8 @@ def ensure_qret_on_path() -> None: _append_env_path("PATH", str(bin_dir)) if platform.system() == "Linux": _append_env_path("LD_LIBRARY_PATH", str(lib_dir)) + elif platform.system() == "Darwin": + _append_env_path("DYLD_FALLBACK_LIBRARY_PATH", str(lib_dir)) if not (bin_dir / "qret").exists() or not (bin_dir / "gridsynth").exists(): asset_name = _platform_asset_name() From cf4894413c558ed90a2e38ce7f7b56ef7dd10923 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 9 Apr 2026 21:45:43 +0900 Subject: [PATCH 2/7] fix: stabilize bundle resolution in CI --- .github/workflows/test.yml | 2 ++ qret_cli_bundle/__init__.py | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ba5dcd..0a8c7c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -72,4 +72,6 @@ jobs: "$env:GITHUB_WORKSPACE/.ci-bin" | Out-File -FilePath $env:GITHUB_PATH -Append - name: Run pytest + env: + GITHUB_TOKEN: ${{ github.token }} run: pytest -q tests/test_qret_cli_bundle.py diff --git a/qret_cli_bundle/__init__.py b/qret_cli_bundle/__init__.py index 744108e..64c9139 100644 --- a/qret_cli_bundle/__init__.py +++ b/qret_cli_bundle/__init__.py @@ -38,15 +38,25 @@ def _platform_asset_name() -> str: raise QretBundleError(f"Unsupported platform: {system} ({machine})") +def _github_headers(accept: str) -> dict[str, str]: + headers = {"Accept": accept} + # Use a token in CI to avoid GitHub API rate limits; local environments can + # continue to fall back to unauthenticated requests when no token is set. + github_token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN") + if github_token: + headers["Authorization"] = f"Bearer {github_token}" + return headers + + def _release_json() -> dict: url = f"{API_BASE}/repos/{DEFAULT_REPO}/releases/latest" - req = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json"}) + req = urllib.request.Request(url, headers=_github_headers("application/vnd.github+json")) with urllib.request.urlopen(req, timeout=60) as response: return json.load(response) def _download_file(url: str, path: Path) -> None: - req = urllib.request.Request(url, headers={"Accept": "application/octet-stream"}) + req = urllib.request.Request(url, headers=_github_headers("application/octet-stream")) with urllib.request.urlopen(req, timeout=300) as response: path.write_bytes(response.read()) @@ -90,6 +100,14 @@ def _append_env_path(var_name: str, entry: str) -> None: os.environ[var_name] = current + os.pathsep + entry if current else entry +def _find_executable(bin_dir: Path, *names: str) -> Path | None: + for name in names: + candidate = bin_dir / name + if candidate.exists(): + return candidate + return None + + def ensure_qret_on_path() -> None: install_root = Path(__file__).parent / "bundle" @@ -100,7 +118,6 @@ def ensure_qret_on_path() -> None: _append_env_path("LD_LIBRARY_PATH", str(lib_dir)) elif platform.system() == "Darwin": _append_env_path("DYLD_FALLBACK_LIBRARY_PATH", str(lib_dir)) - if not (bin_dir / "qret").exists() or not (bin_dir / "gridsynth").exists(): asset_name = _platform_asset_name() release = _release_json() @@ -120,8 +137,9 @@ def ensure_qret_on_path() -> None: _extract_archive(archive_path, install_root) archive_path.unlink(missing_ok=True) - if (bin_dir / "gridsynth").exists(): - os.environ["GRIDSYNTH_PATH"] = str(bin_dir / "gridsynth") + gridsynth_path = _find_executable(bin_dir, "gridsynth", "gridsynth.exe", "gridsynth.cmd") + if gridsynth_path is not None: + os.environ["GRIDSYNTH_PATH"] = str(gridsynth_path) ensure_qret_on_path() From d98b1cfaf58b9863af79ea187b3b4e43dd41eed0 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 23 Apr 2026 10:52:51 +0900 Subject: [PATCH 3/7] comment out debug code --- .github/workflows/test.yml | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a8c7c4..c6cbf02 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,26 +35,27 @@ jobs: with: python-version: "3.11" - - name: Install package and test deps - run: | - python -m pip install --upgrade pip - python -m pip install -e ".[test]" + ## leaving this for future debug purpose + # - name: Install package and test deps + # run: | + # python -m pip install --upgrade pip + # python -m pip install -e ".[test]" - - name: Prepare qret stub for test (Unix) - if: runner.os != 'Windows' - run: | - mkdir -p .ci-bin - cat > .ci-bin/qret <<'EOF' - #!/usr/bin/env sh - echo "qret 0.0.0-ci" - EOF - cat > .ci-bin/gridsynth <<'EOF' - #!/usr/bin/env sh - echo "gridsynth 0.0.0-ci" - EOF - chmod +x .ci-bin/qret - chmod +x .ci-bin/gridsynth - echo "$GITHUB_WORKSPACE/.ci-bin" >> "$GITHUB_PATH" + # - name: Prepare qret stub for test (Unix) + # if: runner.os != 'Windows' + # run: | + # mkdir -p .ci-bin + # cat > .ci-bin/qret <<'EOF' + # #!/usr/bin/env sh + # echo "qret 0.0.0-ci" + # EOF + # cat > .ci-bin/gridsynth <<'EOF' + # #!/usr/bin/env sh + # echo "gridsynth 0.0.0-ci" + # EOF + # chmod +x .ci-bin/qret + # chmod +x .ci-bin/gridsynth + # echo "$GITHUB_WORKSPACE/.ci-bin" >> "$GITHUB_PATH" - name: Prepare qret stub for test (Windows) if: runner.os == 'Windows' From f6be3e6dabbd9df2ebd51dc09a5bafa44d5b8ba0 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 23 Apr 2026 10:53:14 +0900 Subject: [PATCH 4/7] improve executable existance check --- qret_cli_bundle/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qret_cli_bundle/__init__.py b/qret_cli_bundle/__init__.py index 64c9139..341b99f 100644 --- a/qret_cli_bundle/__init__.py +++ b/qret_cli_bundle/__init__.py @@ -118,7 +118,7 @@ def ensure_qret_on_path() -> None: _append_env_path("LD_LIBRARY_PATH", str(lib_dir)) elif platform.system() == "Darwin": _append_env_path("DYLD_FALLBACK_LIBRARY_PATH", str(lib_dir)) - if not (bin_dir / "qret").exists() or not (bin_dir / "gridsynth").exists(): + if _find_executable(bin_dir, "qret", "qret.exe", "qret.cmd") is None or _find_executable(bin_dir, "gridsynth", "gridsynth.exe", "gridsynth.cmd") is None: asset_name = _platform_asset_name() release = _release_json() assets = {asset["name"]: asset["browser_download_url"] for asset in release.get("assets", [])} From 4f32c53edff2608b96293d245106971b370caf44 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 23 Apr 2026 11:01:10 +0900 Subject: [PATCH 5/7] fix workflog --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6cbf02..f60223e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,12 +34,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.11" - - ## leaving this for future debug purpose - # - name: Install package and test deps - # run: | - # python -m pip install --upgrade pip - # python -m pip install -e ".[test]" + - name: Install package and test deps + run: | + python -m pip install --upgrade pip + python -m pip install pytest + ## leaving this for future debug purpose + # python -m pip install -e ".[test]" # - name: Prepare qret stub for test (Unix) # if: runner.os != 'Windows' From 444ddcaf6b53b0d7d6cd2bc5a70e9c3caf4fc159 Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Thu, 23 Apr 2026 11:01:10 +0900 Subject: [PATCH 6/7] fix workflow --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f60223e..a7fa246 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,9 +37,8 @@ jobs: - name: Install package and test deps run: | python -m pip install --upgrade pip - python -m pip install pytest - ## leaving this for future debug purpose - # python -m pip install -e ".[test]" + python -m pip install -e ".[test]" + # - name: Prepare qret stub for test (Unix) # if: runner.os != 'Windows' From e75165f1c92b7014bff5481636d9df4b93f9333b Mon Sep 17 00:00:00 2001 From: Kazutaka333 Date: Mon, 27 Apr 2026 13:45:30 +0900 Subject: [PATCH 7/7] comment out debug step --- .github/workflows/test.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7fa246..853839a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,20 +56,20 @@ jobs: # chmod +x .ci-bin/gridsynth # echo "$GITHUB_WORKSPACE/.ci-bin" >> "$GITHUB_PATH" - - name: Prepare qret stub for test (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - New-Item -ItemType Directory -Force -Path .ci-bin | Out-Null - @' - @echo off - echo qret 0.0.0-ci - '@ | Set-Content -Path .ci-bin/qret.cmd - @' - @echo off - echo gridsynth 0.0.0-ci - '@ | Set-Content -Path .ci-bin/gridsynth.cmd - "$env:GITHUB_WORKSPACE/.ci-bin" | Out-File -FilePath $env:GITHUB_PATH -Append + # - name: Prepare qret stub for test (Windows) + # if: runner.os == 'Windows' + # shell: pwsh + # run: | + # New-Item -ItemType Directory -Force -Path .ci-bin | Out-Null + # @' + # @echo off + # echo qret 0.0.0-ci + # '@ | Set-Content -Path .ci-bin/qret.cmd + # @' + # @echo off + # echo gridsynth 0.0.0-ci + # '@ | Set-Content -Path .ci-bin/gridsynth.cmd + # "$env:GITHUB_WORKSPACE/.ci-bin" | Out-File -FilePath $env:GITHUB_PATH -Append - name: Run pytest env: