diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fec8d94..7b95a64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python: ["3.9", "3.12"] + python: ["3.11", "3.12"] include: - os: macos-latest python: "3.12" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e3a9abd..296223c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,5 +17,6 @@ jobs: - uses: compas-dev/compas-actions.docs@v5 with: github_token: ${{ secrets.GITHUB_TOKEN }} + python: "3.12" generator: mkdocs extras: dev,mkdocs \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c3b61..4d3e38c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Changed `yakerize` and `publish_yak` to download a versioned, platform-specific `yak` CLI instead of the deprecated `latest/yak.exe`. + ### Removed +* Removed the Mono fallback for running `yak.exe` on non-Windows platforms. + ## [1.3.0] 2026-08-14 ### Added diff --git a/src/compas_invocations2/grasshopper.py b/src/compas_invocations2/grasshopper.py index 98f18b3..3620b3c 100644 --- a/src/compas_invocations2/grasshopper.py +++ b/src/compas_invocations2/grasshopper.py @@ -22,7 +22,8 @@ from compas_invocations2.console import chdir -YAK_URL = r"https://files.mcneel.com/yak/tools/latest/yak.exe" +# https://developer.rhino3d.com/guides/yak/yak-cli-reference/#downloads +YAK_VERSION = "0.19.1" # The `yak` CLI shipped inside the Rhino application bundle on macOS. RHINO_YAK_PATHS = [ @@ -32,15 +33,29 @@ ] +def _get_yak_url() -> str: + """Return the download URL of the yak CLI build matching the current platform.""" + base_url = f"https://files.mcneel.com/yak/tools/{YAK_VERSION}" + arch = "arm64" if platform.machine().lower() in ("arm64", "aarch64") else "x64" + system = platform.system() + if system == "Windows": + return f"{base_url}/win-{arch}/yak.exe" + if system == "Darwin": + return f"{base_url}/osx-universal/yak" + return f"{base_url}/linux-{arch}/yak" + + def _download_yak_executable(target_dir: str): - response = requests.get(YAK_URL) + url = _get_yak_url() + response = requests.get(url) if response.status_code != 200: - raise ValueError(f"Failed to download the yak.exe from url:{YAK_URL} with error : {response.status_code}") + raise ValueError(f"Failed to download the yak executable from url:{url} with error : {response.status_code}") # absolute, because callers run yak from inside a different working directory - target_path = os.path.abspath(os.path.join(target_dir, "yak.exe")) + target_path = os.path.abspath(os.path.join(target_dir, url.rsplit("/", 1)[-1])) with open(target_path, "wb") as f: f.write(response.content) + os.chmod(target_path, 0o755) return target_path @@ -53,27 +68,17 @@ def _find_native_yak() -> Optional[str]: def _get_yak_command(download_dir: str) -> List[str]: - """Return the argv prefix used to invoke yak, downloading ``yak.exe`` if needed. + """Return the argv prefix used to invoke yak, downloading the CLI if needed. - The only yak binary McNeel publishes for download is a .NET Framework ``yak.exe``. - On Windows it runs as-is. Elsewhere it needs a runtime, so we prefer the native - ``yak`` CLI that ships inside the Rhino application bundle (macOS) or is otherwise - on PATH, and fall back to running the downloaded ``yak.exe`` under Mono. + On Windows the CLI is always downloaded. Elsewhere we prefer the native ``yak`` CLI + that ships inside the Rhino application bundle (macOS) or is otherwise on PATH. """ - if platform.system() == "Windows": - return [_download_yak_executable(download_dir)] - - native_yak = _find_native_yak() - if native_yak: - return [native_yak] + if platform.system() != "Windows": + native_yak = _find_native_yak() + if native_yak: + return [native_yak] - mono = shutil.which("mono") - if not mono: - raise invoke.Exit( - "No yak executable available. Install Rhino (which bundles the `yak` CLI) " - "or install Mono (`brew install mono`) so that the downloaded yak.exe can be run." - ) - return [mono, _download_yak_executable(download_dir)] + return [_download_yak_executable(download_dir)] def _set_version_in_manifest(manifest_path: str, version: str): diff --git a/tests/test_grasshopper.py b/tests/test_grasshopper.py new file mode 100644 index 0000000..cfc4e5c --- /dev/null +++ b/tests/test_grasshopper.py @@ -0,0 +1,23 @@ +import pytest + +from compas_invocations2 import grasshopper + + +@pytest.mark.parametrize( + "system, machine, expected", + [ + ("Windows", "AMD64", "win-x64/yak.exe"), + ("Windows", "ARM64", "win-arm64/yak.exe"), + ("Darwin", "arm64", "osx-universal/yak"), + ("Darwin", "x86_64", "osx-universal/yak"), + ("Linux", "x86_64", "linux-x64/yak"), + ("Linux", "aarch64", "linux-arm64/yak"), + ], +) +def test_get_yak_url(monkeypatch, system, machine, expected): + monkeypatch.setattr(grasshopper.platform, "system", lambda: system) + monkeypatch.setattr(grasshopper.platform, "machine", lambda: machine) + + url = grasshopper._get_yak_url() + + assert url == f"https://files.mcneel.com/yak/tools/{grasshopper.YAK_VERSION}/{expected}"