Skip to content

Fix CI failures in Windows#1402

Merged
ia0 merged 1 commit into
google:mainfrom
ia0:debug-win25
May 20, 2026
Merged

Fix CI failures in Windows#1402
ia0 merged 1 commit into
google:mainfrom
ia0:debug-win25

Conversation

@ia0

@ia0 ia0 commented May 20, 2026

Copy link
Copy Markdown
Member

This is vibe-coded. Below is what the agent had to say.


This PR fixes a FileNotFoundError that occurs on Windows CI runners during package testing.

The Problem

When building mixed Rust/Python packages with maturin using bindings = "bin", maturin packages the Rust CLI binary inside the wheel and installs a small Python launcher script (which handles DLL loading for onnxruntime on Windows) into the wheel's scripts directory.

On Windows, pip installs this launcher script into the environment's Scripts folder as magika without a .exe extension. Because it lacks an extension, Windows' CreateProcess API (invoked by Python's subprocess.run(..., shell=False)) fails to execute it directly, resulting in:

FileNotFoundError: [WinError 2] The system cannot find the file specified

The Solution

Instead of trying to alter how maturin or pip packages the wheel on Windows, this PR implements a robust, portable workaround in the test/check scripts (run_quick_test_magika_cli.py and pre_release_check.py):

  1. Script Directory Resolution: On Windows, if the CLI tool cannot be found via shutil.which (due to the missing extension), the scripts now manually locate it in the active environment's standard Scripts directory using sysconfig.get_path("scripts").
  2. Shebang Detection: If an extensionless candidate is found, the script peeks at the first line. If it contains a Python shebang (#!), it is identified as the launcher script.
  3. Explicit Python Invocation: The command is rewritten to run explicitly via the current Python interpreter (sys.executable):
    python.exe C:\...\Scripts\magika --version
    This bypasses the Windows execution limitation and successfully boots the Rust client via the launcher.

Why this approach?

  • No bash dependency: Avoids assuming bash is present, ensuring the test suite remains runnable locally for Windows developers using standard PowerShell/CMD.
  • Zero Path/Escaping Issues: Avoids POSIX path conversion errors that commonly happen when passing Windows backslash paths to bash.
  • Clean & Standard: Leverages sysconfig to find the installation directory reliably across all Python versions (3.8+).

@ia0 ia0 requested a review from reyammer as a code owner May 20, 2026 09:01
@ia0 ia0 force-pushed the debug-win25 branch 5 times, most recently from f18eedb to 0ad35e3 Compare May 20, 2026 09:44
@ia0 ia0 merged commit 007f0dc into google:main May 20, 2026
162 of 165 checks passed
@ia0 ia0 deleted the debug-win25 branch May 20, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants