Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 27 additions & 22 deletions src/compas_invocations2/grasshopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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


Expand All @@ -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):
Expand Down
23 changes: 23 additions & 0 deletions tests/test_grasshopper.py
Original file line number Diff line number Diff line change
@@ -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}"
Loading