PyO3 / maturin-action

GitHub Action to install and run a custom maturin command with built-in support for cross compilation
MIT License
132 stars 37 forks source link

'target' option is ignored if `args` contains `--` #139

Closed Smertig closed 1 year ago

Smertig commented 1 year ago

I'm using maturin-action in the following way:

- uses: PyO3/maturin-action@v1.35.0
  with:
    maturin-version: 'v0.13.7'
    target: x86
    command: publish
    args: "-- -Ctarget-feature=+crt-static"

My build fails with the output:

  --- stderr
  error: your Rust target architecture (64-bit) does not match your python interpreter (32-bit)
warning: build failed, waiting for other jobs to finish...
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--release" "--message-format" "json" "--lib" "--crate-type" "cdylib" "--" "-Ctarget-feature=+crt-static" "--target" "i686-pc-windows-msvc"`

I think the reason is that maturin is being called in this way:

maturin.exe publish -- -Ctarget-feature=+crt-static --target i686-pc-windows-msvc
...

The --target option is ignored because it's specified after all the arguments that may contain -- delimiter. When I changed my config to this one:

- uses: PyO3/maturin-action@v1.35.0
  with:
    maturin-version: 'v0.13.7'
    command: publish
    args: "--target i686-pc-windows-msvc -- -Ctarget-feature=+crt-static"

I've got what I expected:

maturin.exe publish --target i686-pc-windows-msvc -- -Ctarget-feature=+crt-static
...
messense commented 1 year ago

Interesting, thanks for the report! I think change from Array.push to Array.unshift should fix it: https://github.com/PyO3/maturin-action/pull/140.

messense commented 1 year ago

Please try v1.35.2.

Smertig commented 1 year ago

It works like a charm! Thank you for such a great support.