Giter Site home page Giter Site logo

pyo3 / maturin-action Goto Github PK

View Code? Open in Web Editor NEW
125.0 4.0 32.0 928 KB

GitHub Action to install and run a custom maturin command with built-in support for cross compilation

License: MIT License

TypeScript 91.68% Rust 1.09% Python 7.23%
maturin pyo3 manylinux rust-cpython cffi github-actions uniffi hacktoberfest

maturin-action's Introduction

PyO3

actions status benchmark codecov crates.io minimum rustc 1.63 discord server contributing notes

Rust bindings for Python, including tools for creating native Python extension modules. Running and interacting with Python code from a Rust binary is also supported.

Usage

PyO3 supports the following software versions:

  • Python 3.7 and up (CPython, PyPy, and GraalPy)
  • Rust 1.63 and up

You can use PyO3 to write a native Python module in Rust, or to embed Python in a Rust binary. The following sections explain each of these in turn.

Using Rust from Python

PyO3 can be used to generate a native Python module. The easiest way to try this out for the first time is to use maturin. maturin is a tool for building and publishing Rust-based Python packages with minimal configuration. The following steps install maturin, use it to generate and build a new Python package, and then launch Python to import and execute a function from the package.

First, follow the commands below to create a new directory containing a new Python virtualenv, and install maturin into the virtualenv using Python's package manager, pip:

# (replace string_sum with the desired package name)
$ mkdir string_sum
$ cd string_sum
$ python -m venv .env
$ source .env/bin/activate
$ pip install maturin

Still inside this string_sum directory, now run maturin init. This will generate the new package source. When given the choice of bindings to use, select pyo3 bindings:

$ maturin init
โœ” ๐Ÿคท What kind of bindings to use? ยท pyo3
  โœจ Done! New project created string_sum

The most important files generated by this command are Cargo.toml and lib.rs, which will look roughly like the following:

Cargo.toml

[package]
name = "string_sum"
version = "0.1.0"
edition = "2021"

[lib]
# The name of the native library. This is the name which will be used in Python to import the
# library (i.e. `import string_sum`). If you change this, you must also change the name of the
# `#[pymodule]` in `src/lib.rs`.
name = "string_sum"
# "cdylib" is necessary to produce a shared library for Python to import from.
#
# Downstream Rust code (including code in `bin/`, `examples/`, and `tests/`) will not be able
# to `use string_sum;` unless the "rlib" or "lib" crate type is also included, e.g.:
# crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.22.0", features = ["extension-module"] }

src/lib.rs

use pyo3::prelude::*;

/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
    Ok((a + b).to_string())
}

/// A Python module implemented in Rust. The name of this function must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn string_sum(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
    Ok(())
}

Finally, run maturin develop. This will build the package and install it into the Python virtualenv previously created and activated. The package is then ready to be used from python:

$ maturin develop
# lots of progress output as maturin runs the compilation...
$ python
>>> import string_sum
>>> string_sum.sum_as_string(5, 20)
'25'

To make changes to the package, just edit the Rust source code and then re-run maturin develop to recompile.

To run this all as a single copy-and-paste, use the bash script below (replace string_sum in the first command with the desired package name):

mkdir string_sum && cd "$_"
python -m venv .env
source .env/bin/activate
pip install maturin
maturin init --bindings pyo3
maturin develop

If you want to be able to run cargo test or use this project in a Cargo workspace and are running into linker issues, there are some workarounds in the FAQ.

As well as with maturin, it is possible to build using setuptools-rust or manually. Both offer more flexibility than maturin but require more configuration to get started.

Using Python from Rust

To embed Python into a Rust binary, you need to ensure that your Python installation contains a shared library. The following steps demonstrate how to ensure this (for Ubuntu), and then give some example code which runs an embedded Python interpreter.

To install the Python shared library on Ubuntu:

sudo apt install python3-dev

To install the Python shared library on RPM based distributions (e.g. Fedora, Red Hat, SuSE), install the python3-devel package.

Start a new project with cargo new and add pyo3 to the Cargo.toml like this:

[dependencies.pyo3]
version = "0.22.0"
features = ["auto-initialize"]

Example program displaying the value of sys.version and the current user name:

use pyo3::prelude::*;
use pyo3::types::IntoPyDict;

fn main() -> PyResult<()> {
    Python::with_gil(|py| {
        let sys = py.import_bound("sys")?;
        let version: String = sys.getattr("version")?.extract()?;

        let locals = [("os", py.import_bound("os")?)].into_py_dict_bound(py);
        let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
        let user: String = py.eval_bound(code, None, Some(&locals))?.extract()?;

        println!("Hello {}, I'm Python {}", user, version);
        Ok(())
    })
}

The guide has a section with lots of examples about this topic.

Tools and libraries

  • maturin Build and publish crates with pyo3, rust-cpython or cffi bindings as well as rust binaries as python packages
  • setuptools-rust Setuptools plugin for Rust support.
  • pyo3-built Simple macro to expose metadata obtained with the built crate as a PyDict
  • rust-numpy Rust binding of NumPy C-API
  • dict-derive Derive FromPyObject to automatically transform Python dicts into Rust structs
  • pyo3-log Bridge from Rust to Python logging
  • pythonize Serde serializer for converting Rust objects to JSON-compatible Python objects
  • pyo3-asyncio Utilities for working with Python's Asyncio library and async functions
  • rustimport Directly import Rust files or crates from Python, without manual compilation step. Provides pyo3 integration by default and generates pyo3 binding code automatically.

Examples

  • autopy A simple, cross-platform GUI automation library for Python and Rust.
    • Contains an example of building wheels on TravisCI and appveyor using cibuildwheel
  • ballista-python A Python library that binds to Apache Arrow distributed query engine Ballista.
  • bed-reader Read and write the PLINK BED format, simply and efficiently.
    • Shows Rayon/ndarray::parallel (including capturing errors, controlling thread num), Python types to Rust generics, Github Actions
  • cryptography Python cryptography library with some functionality in Rust.
  • css-inline CSS inlining for Python implemented in Rust.
  • datafusion-python A Python library that binds to Apache Arrow in-memory query engine DataFusion.
  • deltalake-python Native Delta Lake Python binding based on delta-rs with Pandas integration.
  • fastbloom A fast bloom filter | counting bloom filter implemented by Rust for Rust and Python!
  • fastuuid Python bindings to Rust's UUID library.
  • feos Lightning fast thermodynamic modeling in Rust with fully developed Python interface.
  • forust A lightweight gradient boosted decision tree library written in Rust.
  • greptimedb Support Python scripting in the database
  • haem A Python library for working on Bioinformatics problems.
  • html-py-ever Using html5ever through kuchiki to speed up html parsing and css-selecting.
  • hyperjson A hyper-fast Python module for reading/writing JSON data using Rust's serde-json.
  • inline-python Inline Python code directly in your Rust code.
  • johnnycanencrypt OpenPGP library with Yubikey support.
  • jsonschema-rs Fast JSON Schema validation library.
  • mocpy Astronomical Python library offering data structures for describing any arbitrary coverage regions on the unit sphere.
  • opendal A data access layer that allows users to easily and efficiently retrieve data from various storage services in a unified way.
  • orjson Fast Python JSON library.
  • ormsgpack Fast Python msgpack library.
  • point-process High level API for pointprocesses as a Python library.
  • polaroid Hyper Fast and safe image manipulation library for Python written in Rust.
  • polars Fast multi-threaded DataFrame library in Rust | Python | Node.js.
  • pydantic-core Core validation logic for pydantic written in Rust.
  • pyheck Fast case conversion library, built by wrapping heck.
    • Quite easy to follow as there's not much code.
  • pyre Fast Python HTTP server written in Rust.
  • pyreqwest_impersonate The fastest python HTTP client that can impersonate web browsers by mimicking their headers and TLS/JA3/JA4/HTTP2 fingerprints.
  • ril-py A performant and high-level image processing library for Python written in Rust.
  • river Online machine learning in python, the computationally heavy statistics algorithms are implemented in Rust.
  • rust-python-coverage Example PyO3 project with automated test coverage for Rust and Python.
  • tiktoken A fast BPE tokeniser for use with OpenAI's models.
  • tokenizers Python bindings to the Hugging Face tokenizers (NLP) written in Rust.
  • tzfpy A fast package to convert longitude/latitude to timezone name.
  • utiles Fast Python web-map tile utilities
  • wasmer-python Python library to run WebAssembly binaries.

Articles and other media

Contributing

Everyone is welcomed to contribute to PyO3! There are many ways to support the project, such as:

  • help PyO3 users with issues on GitHub and Discord
  • improve documentation
  • write features and bugfixes
  • publish blogs and examples of how to use PyO3

Our contributing notes and architecture guide have more resources if you wish to volunteer time for PyO3 and are searching where to start.

If you don't have time to contribute yourself but still wish to support the project's future success, some of our maintainers have GitHub sponsorship pages:

License

PyO3 is licensed under the Apache-2.0 license or the MIT license, at your option.

Python is licensed under the Python License.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in PyO3 by you, as defined in the Apache License, shall be dual-licensed as above, without any additional terms or conditions.

Deploys by Netlify

maturin-action's People

Contributors

adriangb avatar dariocurr avatar dependabot[bot] avatar github-actions[bot] avatar ijl avatar konstin avatar messense avatar orf avatar plied avatar tpt avatar wfxr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maturin-action's Issues

Can't set MACOSX_DEPLOYMENT_TARGET for macos wheels

Trying to build wheels for both our Linux servers and our local macOS M1 machines I struggled with the latter. maturin-action currently hard sets MACOSX_DEPLOYMENT_TARGET to 10.9 (here) which generates a ...macosx_10_9_arm64.whl wheel not installable on macOS M1 13.0.1 (no idea if it doesn't work "at all" or specifically with my project or macOS 13.0.1).

Setting MACOSX_DEPLOYMENT_TARGET to 11.0 or simply letting rustc/cargo use their default values both seem to work, generating a functional/installable ...macosx_11_0_arm64.whl wheel (setting to 11.0 and no value).

What would be the best course forward? Would you accept a PR removing the default value?

Maturin failed to find python interpreter

When setting manylinux=auto or (lower than 2_24), the pipeline fails as it cannot find a python interpreter.

This is the yaml snippet:

  build_manylinux:
    name: Create Release manylinux
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Prepare maturin publish
        shell: bash
        run: |
          rm py-polars/README.md
          cp README.md py-polars/README.md

      - uses: actions/setup-python@v2
        with:
          python-version: 3.7
          architecture: x64

      - name: publish x64_64
        uses: messense/maturin-action@v1
        env:
          MATURIN_PASSWORD: ${{ secrets.PYPI_PASS }}
          RUSTFLAGS: '-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma'
        with:
          rust-toolchain: nightly-2022-08-22
          maturin-version: '0.13.0'
          command: publish
          args: -m py-polars/Cargo.toml --skip-existing -o wheels -i python -u ritchie46

This is the error in question:

Run messense/maturin-action@v1
Pull Docker image
Cleanup build scripts artifact directory
/usr/bin/docker run --rm --workdir /home/runner/work/polars/polars -e DEBIAN_FRONTEND=noninteractive -e ARCHFLAGS -e _PYTHON_SYSCONFIGDATA_NAME -e MATURIN_PASSWORD -e RUSTFLAGS -v /home/runner/work/polars/polars:/home/runner/work/polars/polars quay.io/pypa/manylinux2014_x86_64:latest /home/runner/work/polars/polars/run-maturin-action.sh
Install Rust
Install maturin
๐Ÿ“ฆ Including license file "py-polars/LICENSE"
๐Ÿน Building a mixed python/rust project
๐Ÿ”— Found pyo3 bindings with abi3 support for Python โ‰ฅ 3.7
๐Ÿ Not using a specific python interpreter
๐Ÿ’ฅ maturin failed
  Caused by: Failed to find any python interpreter

linux build not installing correct version

Hi

I'm using the default action and default CI to install a mixed python rust library.
This will install on mac correctly and installs the latest version 0.1.7 (or i can do pip install library==0.1.17) all fine.
I changed the action previously to -o dist instead of -o target/dist. This got the build seemingly working and ive been testing on mac, everything working fine.

When i tried to build the linux version the installer installs an old version 0.0.2 (i think this was from before i changed the -o) however if i change the linux action to dist the build fails completely:

๐Ÿ’ฅ maturin failed
  Caused by: Failed to build source distribution
  Caused by: Attempting to include the sdist output tarball dist/fastqlapi-0.2.0.tar.gz into itself! Check 'cargo package --list' output.
Error: The process '/usr/bin/docker' failed with exit code 1

After changing env imports arnt working

Hi there

im on python_version = "3.10", ["maturin>=0.13,<0.14"]

I had a library releasing as expected via the actions but after changing env and then changing back (to the original env i had been using) the following stopped working.

in python/fastqlapi/_init.py

from .fastqlapi import *
from .server import fastql_server

my structure was
/python
/fastqlapi
server.py
init.py

and im getting this error from the deployed code when i try to import the library:

Traceback (most recent call last):
File "model.py", line 4, in
from fastqlapi import fastql_server
File "/home/ubuntu/.local/lib/python3.8/site-packages/fastqlapi/init.py", line 5, in
from .server import fastql_server
ModuleNotFoundError: No module named 'fastqlapi.server'

Im looking at the diff of the two commits and absolutely nothing has changed apart from some small changes in some rust code which has no relation to py03 and the version number

Option for git credential store using access token to clone private repositories

I'm trying to run this action to create python bindings for a project that contains a git dependency in Cargo.toml. Normally I can use something like de-vri-es/setup-git-credentials to store an access token so that cargo build will complete without issues.

However, due to the use of docker in maturin-action I believe that these credentials are not being passed into the container. Therefore, the internal maturin commands fail for me with:

Caused by:
  failed to load source for dependency `$private_repo`
Caused by:
  failed to authenticate when downloading repository
  * attempted to find username/password via git's `credential.helper` support, but failed
  if the git CLI succeeds then `net.git-fetch-with-cli` may help here
 [ https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-c](https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli)

would it be possible to add a git_token input (or similar) to this project so that projects with private repos can be built? Alternatively, perhaps copy any .git-credentials files into the container so that they are configured externally?

Example Action

I can also put together a minimal repo with a private git dep to demonstrate the issue if needed

name: pybindings

on:
  push:
  pull_request:

jobs:
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [x86_64, i686]
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: 3.9
        architecture: x64
    # add git credentials so we can `cargo build` the repo with git dependencies
    - name: add git credentials for clone
      uses: de-vri-es/setup-git-credentials@v2
      with:
        credentials: ${{secrets.GIT_CREDENTIALS}}
    # build
    - name: Build repo with private deps
      run: cargo build --color=always
    # verify that we can run `maturin build` naturally without maturin-action
    - name: Build python bindings manually
      run: |
        cd pybind
        cargo install maturin
        maturin build
    # then do the manylinux build with maturin-action
    # //this fails//
    - name: build python wheels
      uses: messense/maturin-action@v1
      with:
        target: ${{ matrix.target }}
        manylinux: auto
        args: --release --out dist -m pybind/Cargo.toml

Username and password were incorrect on default CI.yaml

Hi, you closed this but I did indeed try using PYPY_API_TOKEN secret value to set MATURIN_PYPI_TOKEN env variable

I've tried with two different pypy accounts and with one of them I even tried setting the token value to the env variable without using a secret.. (as below) this isn't working in Maturin 0.14

Hi

Im just using the autogenerated CI.yaml

I added my pypyp API token to the Action secrets space as MATURIN_PYPI_TOKEN

Have also tried:

  - name: Publish to PyPI
    uses: messense/maturin-action@v1
    env:
      MATURIN_USERNAME: my_username
      MATURIN_PASSWORD: my_password
    with:
      command: upload
      args: --skip-existing *

I get the following error:

2022-12-02T13:22:59.6828501Z [command]/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin upload --skip-existing /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp310-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp311-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp37-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp38-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp39-none-win_amd64.whl
2022-12-02T13:22:59.6860026Z ๐Ÿš€ Uploading 10 packages
2022-12-02T13:23:00.4949066Z โ›” Username and/or password are wrong
2022-12-02T13:23:00.4976272Z ๐Ÿ’ฅ maturin failed
2022-12-02T13:23:00.4976880Z   Caused by: Username and/or password are wrong
2022-12-02T13:23:00.5014062Z Error: The process '/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin' failed with exit code 1
2022-12-02T13:23:00.5035140Z ##[error]The process '/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin' failed with exit code 1
2022-12-02T13:23:00.5036757Z     at ExecState._setResult (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1702:25)
2022-12-02T13:23:00.5037520Z     at ExecState.CheckComplete (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1685:18)
2022-12-02T13:23:00.5038359Z     at ChildProcess.<anonymous> (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1579:27)
2022-12-02T13:23:00.5038814Z     at ChildProcess.emit (node:events:390:28)
2022-12-02T13:23:00.5039543Z     at maybeClose (node:internal/child_process:1064:16)
2022-12-02T13:23:00.5039885Z     at Socket.<anonymous> (node:internal/child_process:450:11)
2022-12-02T13:23:00.5040485Z     at Socket.emit (node:events:390:28)
2022-12-02T13:23:00.5040755Z     at Pipe.<anonymous> (node:net:687:12)
2022-12-02T13:23:00.5204636Z Cleaning up orphan processes

Fail to build on target aarch64

Hi,

I try to build python extension with different platforms (test project). However, I encounter an error when trying to build on non x86_64 and x64:

Run messense/maturin-action@v1
  with:
    manylinux: auto
    target: aarch6[4](https://github.com/binh-vu/rust-python-template/runs/7050414502?check_suite_focus=true#step:3:4)
    command: build
    args: --release -o dist
    maturin-version: latest

Caused by: Couldn't find any python interpreters. Please specify at least one with -i

This is the build configuration that leads to the error:

jobs:
  linux:
    strategy:
      matrix:
        target: [aarch64]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: messense/maturin-action@v1
        with:
          manylinux: auto
          target: ${{ matrix.target }}
          command: build
          args: --release -o dist

The error message seems straightforward, I only need to supply the python version via -i. Checking some of your examples, I found that by providing -i 3.8, it found and used the one at /usr/bin/python3.8. The behavior seems odd to me since it couldn't find any interpreters before.

However, when I dug deeper, I think I found in the Docker image used to build, /usr/bin/python3.8 may be not the one in the target architecture. I ran this command: /usr/bin/python3.8 -c 'import platform; print(platform.machine())' and it printed: x86_64. Checking the Dockerfile), I notice that the python built for aarch64 architecture is copied to /opt/python and while the image that /usr/bin/python3.8 is built from ubuntu:20.04.

So, I think /usr/bin/python3.8 may not be the correct python. How can I specify the interpreter I want in /opt/python to maturin? I tried: -i /opt/python/cp38-cp38/bin/python but it doesn't work (Invalid python interpreter version)

Thank you

Support for `working-directory`

Hello, and merry Christmas!

Maybe I am missing something, but is there a way to run this action in some sub-folder of the repository?

I am trying to have a Rust library and its Python bindings in the same repository, but keep the bindings as a separate project (i.e. something like a bindings-py sub-directory that is technically independent of the main Rust library).

However, no matter what I do, the action always seems to run in the repository root.

If this is not possible yet, how hard would it be to implement?

default to maturin 0.13.0 (and maybe allow specifying a Python version?)

maturin 0.13.0 came out today which is great and exciting!

It would be cool for maturin-action to use it. I see there's some infra for bumping the version but I'm not sure how it's meant to be used or I'd produce a PR myself!

Using maturin-version: 0.13.0, however, seems to fail in my CI runs because PyO3 has dropped their support for Python 3.6 while something in maturin-action is attempting to run on it. For example, this failed CI run says:

 error: the configured Python interpreter version (3.6) is lower than PyO3's minimum supported version (3.7)

There doesn't seem to be to adjust the Python interpreter version, either. I've changed my own pyproject.toml to require a Python version >=3.7, but that wasn't the trick.

Thanks so much for this software!

Attempting to include the sdist output tarball [...] into itself

For one of my packages, the Linux build fails with the following message:

Run messense/maturin-action@v1
Found maturin version requirement maturin>=0.13,<0.14 specified in pyproject.toml
Found maturin release from manifest: v0.13.7
Found Rust toolchain stable in rust-toolchain.toml 
Pull Docker image
Cleanup build scripts artifact directory
/usr/bin/docker run --rm --workdir /home/runner/work/LiberTEM-dectris-rs/LiberTEM-dectris-rs -e DEBIAN_FRONTEND=noninteractive -e ARCHFLAGS -e _PYTHON_SYSCONFIGDATA_NAME -v /home/runner/work/LiberTEM-dectris-rs/LiberTEM-dectris-rs:/home/runner/work/LiberTEM-dectris-rs/LiberTEM-dectris-rs ghcr.io/libertem/manylinux2014_x[8](https://github.com/LiberTEM/LiberTEM-dectris-rs/actions/runs/3429314498/jobs/5714765736#step:3:9)6_64:latest /home/runner/work/LiberTEM-dectris-rs/LiberTEM-dectris-rs/run-maturin-action.sh
Install Rust
Install maturin
๐Ÿ”— Found pyo3 bindings with abi3 support for Python โ‰ฅ 3.7
๐Ÿ Not using a specific python interpreter
๐Ÿ’ฅ maturin failed
  Caused by: Failed to build source distribution
  Caused by: Attempting to include the sdist output tarball dist/libertem_dectris-0.2.2.tar.gz into itself! Check 'cargo package --list' output.
Error: The process '/usr/bin/docker' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1702:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:157[9](https://github.com/LiberTEM/LiberTEM-dectris-rs/actions/runs/3429314498/jobs/5714765736#step:3:10):27)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:[10](https://github.com/LiberTEM/LiberTEM-dectris-rs/actions/runs/3429314498/jobs/5714765736#step:3:11)64:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
Error: The process '/usr/bin/docker' failed with exit code 1

Full log available here: https://github.com/LiberTEM/LiberTEM-dectris-rs/actions/runs/3429314498/jobs/5714765736

Previous builds (without configuration changes beyond now using a new maturin version), and the corresponding Mac OS / Windows builds, complete successfully. Manually building on Linux doesn't reproduce the issue, so it could be a problem in this action or how we are using it. Thanks!

ppc64le naming is wrong?

Hi!

Thanks again for putting this together, I've recently made a release with the new archs added in your PR from earlier: milesgranger/cramjam#54

In a separate build for cramjam I'm getting a cramjam-2.3.0-cp37-cp37m-manylinux_2_24_ppc64le.whl is not a supported wheel on this platform. Note that this build for conda is merely just installing the wheels from PyPi.

When I look at a project like retworkx their ppc64le is formatted like retworkx-0.8.0-cp36-cp36m-manylinux2014_ppc64le.whl
where mine is cramjam-2.3.0-cp36-cp36m-manylinux_2_24_ppc64le.whl

Makes me believe the naming is all that is off. What do you think?

Ref: conda-forge/cramjam-feedstock#14

Option to run maturin within subfolder

I like to arrange my rust/python projects like this:

  • rust_lib
    • Cargo.toml
  • python_wrapper
    • Cargo.toml (imports rust_lib as a local dependency)
    • pyproject.toml
  • README.md

So that the rust project can potentially be deployed to crates.io without any of the python stuff. E.g. https://github.com/benblack769/box-intersect-py/tree/main/fast-box-lib-py

  1. Is this a reasonable pattern? Is there any more standard alternative structure?
  2. If so, then would it be possible to configure this action to run maturin from a particular subdirectory of the main project? Would this require any code changes? If so, I could submit a PR to add this functionality in.

sdist not built

We've just had a problem on watchfiles where we forgot to include source distributions. samuelcolvin/watchfiles#175

I'm not sure what changed between v0.15 and v0.16, could it have been something to do with maturin/maturin-action?

This issue is just an alert in case others have encountered the same problem, I've fixed this in watchfiles, see samuelcolvin/watchfiles#176.

Feel free to close the issue.

Parse toolchain seems wrong?

Hi there, latest few builds of my CI failed with similar message:
error: Pre-checks for host and toolchain failed: invalid toolchain name: '[toolchain]' (Linux)

Judge from other other output the toolchain value is not parse correctly, they all display [toolchain]

I also tried with previous v1.27.0 and everything works fine.

linking with 'cc' cannot find -lpythonXX

Hi and first, thank you for this project, it's been extremely helpful!

I'm hoping you can help me out with the following error i get using the maturin-action. I've got a stripped down project that I'm using as a proof of concept to see. It only contains the Using Python from Rust example from pyo3, and pyproject.toml from maturin new -b bin command.

I continue to receive the following error when building for linux (building MacOS universal2 wheels also has problems, windows wheels build fine) I also don't have this problem building wheels on the desktop (both on linux X86_64 and MacOS arm64)

error: linking with `cc` failed: exit status: 1
...
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: cannot find -lpython3.XX # where XX is the python version

full logs here https://github.com/dpgraham4401/quil/actions/runs/3345795050

I figure this is user error, is there something in pyo3/maturins/maturin-actions documentation that I'm missing or is building wheels this way not a supported feature?

The full workflow file can be found here, this is the linux job based on the examples in maturin-action's README.

jobs:
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [ x86_64 ]
        py-version: ['3.9', '3.10']
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.py-version }}

      - name: build wheels
        uses: messense/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          manylinux: auto
          maturin-version: latest
          args: --release -i ${{ matrix.py-version }} --out dist

Error installing on osx10.15

Hi there

My build works on linux, but trying to install on mac 10.15.5 (with just vanilla pip install fastqlapi==0.3.3) returns:

Traceback (most recent call last):
File "model.py", line 1, in
from fastqlapi import fastql_server
File "/Users/me/miniconda3/lib/python3.8/site-packages/fastqlapi/init.py", line 2, in
from .fastqlapi import *
ImportError: dlopen(/Users/me/miniconda3/lib/python3.8/site-packages/fastqlapi/fastqlapi.cpython-38-darwin.so, 2): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
Referenced from: /Users/me/miniconda3/lib/python3.8/site-packages/fastqlapi/fastqlapi.cpython-38-darwin.so (which was built for Mac OS X 12.0)
Expected in: /usr/lib/libc++.1.dylib

this is with Python 3.8.3, same error with python 3.10.8

Thanks!

Username and/or password are wrong with default pypi publish example

Hi

Im just using the autogenerated CI.yaml

I added my pypyp API token to the Action secrets space as MATURIN_PYPI_TOKEN

Have also tried:

  - name: Publish to PyPI
    uses: messense/maturin-action@v1
    env:
      MATURIN_USERNAME: my_username
      MATURIN_PASSWORD: my_password
    with:
      command: upload
      args: --skip-existing *

I get the following error:

2022-12-02T13:22:59.6828501Z [command]/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin upload --skip-existing /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp310-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp311-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp37-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp38-none-win_amd64.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl /home/runner/work/FastQL/FastQL/fastql-0.1.0-cp39-none-win_amd64.whl
2022-12-02T13:22:59.6860026Z ๐Ÿš€ Uploading 10 packages
2022-12-02T13:23:00.4949066Z โ›” Username and/or password are wrong
2022-12-02T13:23:00.4976272Z ๐Ÿ’ฅ maturin failed
2022-12-02T13:23:00.4976880Z   Caused by: Username and/or password are wrong
2022-12-02T13:23:00.5014062Z Error: The process '/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin' failed with exit code 1
2022-12-02T13:23:00.5035140Z ##[error]The process '/home/runner/work/_temp/d3a970aa-691e-42ba-be92-302145e91c5f/maturin' failed with exit code 1
2022-12-02T13:23:00.5036757Z     at ExecState._setResult (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1702:25)
2022-12-02T13:23:00.5037520Z     at ExecState.CheckComplete (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1685:18)
2022-12-02T13:23:00.5038359Z     at ChildProcess.<anonymous> (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1579:27)
2022-12-02T13:23:00.5038814Z     at ChildProcess.emit (node:events:390:28)
2022-12-02T13:23:00.5039543Z     at maybeClose (node:internal/child_process:1064:16)
2022-12-02T13:23:00.5039885Z     at Socket.<anonymous> (node:internal/child_process:450:11)
2022-12-02T13:23:00.5040485Z     at Socket.emit (node:events:390:28)
2022-12-02T13:23:00.5040755Z     at Pipe.<anonymous> (node:net:687:12)
2022-12-02T13:23:00.5204636Z Cleaning up orphan processes

Build arm and then x86 in one step๏ผšversion `GLIBC_2.xx' not found

Thank you for your work.
I encountered a problem like #36 when building arm first and then x86. After reversing the order, the problem disappeared.
Is this to be expected, or am I messing something up

Caused by:
  process didn't exit successfully: `/home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build` (exit status: 1)
  --- stderr
  /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build: /lib64/libc.so.6: version `GLIBC_2.29' not found (required by /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build)
  /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build)
  /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/runner/work/biliup-rs/biliup-rs/target/release/build/libc-b9eca4c95c11bcf6/build-script-build)

armv8 support

Hi,

Congratulation for this action, really helpful! I was wondering if it is possible to add support for armv8 as well.

Thank you!

Private repo failed to authenticate when downloading repository

I'm trying to

Run messense/maturin-action@v1
  with:
    target: x86_64
    manylinux: auto
    args: --release --out dist --no-sdist --manifest-path python/Cargo.toml
    command: build
    maturin-version: latest
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.12/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.12/x64/lib
    SSH_AUTH_SOCK: /tmp/ssh-m22O6wxvMNkI/agent.1820
    SSH_AGENT_PID: 1821

Looks like maturin-action didn't use SSH_AUTH_SOCK variable which I set before using webfactory/ssh-agent

/usr/bin/docker run --rm --workdir /home/runner/work/python -e DEBIAN_FRONTEND=noninteractive -e CARGO_TARGET_DIR -e RUSTFLAGS -e RUST_BACKTRACE -e MATURIN_PASSWORD -e MATURIN_PYPI_TOKEN -e ARCHFLAGS -e PYO3_CROSS -e PYO3_CROSS_LIB_DIR -e PYO3_CROSS_PYTHON_VERSION -e _PYTHON_SYSCONFIGDATA_NAME -v /home/runner/work/python:/home/runner/work/python quay.io/pypa/manylinux2010_x86_64:latest /home/runner/work/python/run-maturin-action.sh

Here is the error

๐Ÿน Building a mixed python/rust project
๐Ÿ’ฅ maturin failed
  Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
  Caused by: `cargo metadata` exited with an error:     Updating crates.io index
    Updating git repository `ssh://[email protected]/<my private repo>`
error: failed to get `<my deps>` as a dependency of package `python v1.0.0 (/home/runner/work/python)`

Caused by:
  failed to load source for dependency `<my deps>`

Caused by:
  Unable to update ssh://[email protected]/<my private repo>

Caused by:
  failed to clone into: /root/.cargo/git/db/<my deps>

Caused by:
  failed to authenticate when downloading repository

  * attempted ssh-agent authentication, but no usernames succeeded: `git`

  if the git CLI succeeds then `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  error authenticating: no auth sock variable; class=Ssh (23)
Error: The process '/usr/bin/docker' failed with exit code 1

Setting "target" and "manylinux" to build musl only builds python3.8 wheels

I haven't been able to figure out what exactly causes this, but in this example configuration:

    - uses: messense/maturin-action@v1
      with:
        manylinux: auto
        command: build
        args: --release -o dist --manifest-path crates/stringmetrics_py/Cargo.toml
    # NOTE: Seems to only build musl wheels for cpython 3.8
    - uses: messense/maturin-action@v1
      with:
        target: x86_64-unknown-linux-musl
        manylinux: musllinux_1_1
        command: build
        args: --release -o dist --manifest-path crates/stringmetrics_py/Cargo.toml

The first step generates wheels for 3.7-3.10 as expected, but the second only does 3.8.

LLVM/Clang Support for Linux

I tried to build a Maturin project on linux platform, but I got this error message: "libclang.so, libclang.so.*, ...." not found.

It seems that the manylinux docker image does not have clang/llvm installed.

So, I set container: off, but it can't build manylinux wheel, and the error is 'linux_x86_64' wheel can't be uploaded.

Is there any way that I can build a manylinux wheel for this Maturin Project with Clang using Github Workflow?

Thanks.

error: could not find native static library `python3.8`, perhaps an -L flag is missing?

action fails on the newer code in github action

(build works both on ubuntu 20.04 and mac m1 locally)

https://github.com/007vasy/solana-bigtable-decode/compare/99a2f1667e06f9d812dfb5e2d9d5f8e9c7af9864..e9383e702f8c2bb033b5a168a4ec1da6aa24f6ad

full error message

error: could not find native static library python3.8`, perhaps an -L flag is missing?

error: aborting due to previous error

error: could not compile python3-sys due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
๐Ÿ’ฅ maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit status: 101": cargo rustc --manifest-path Cargo.toml --message-format json --release --lib --
Error: The process '/usr/bin/docker' failed with exit code 1`

Action fails on Windows and macos when using `--cargo-extra-args="--features python"`

I want to build my wheels using maturin-action in a mixed rust-python library. The python feature enables the python part of the crate. When providing cargo-extra-args to args, the action works on linux but fails on windows and macos.

      - name: Build Wheels
        uses: messense/maturin-action@v1
        with:
          manylinux: auto
          command: build
          args: --release --out dist --no-sdist --cargo-extra-args="--features python"

Without the --cargo-extra-args argument (using python as default feature) it works on all platforms.

Question: Is RUSTFLAGS picked up by `maturin-action`

Sorry for this trivial question, but I could not find a way to verifiy that.

Does a shell step like this.

      - name: Prepare maturin publish
        shell: bash
        run: |
          export RUSTFLAGS='-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma'

Ensure that those RUSTFLAGS are used by the maturin-action step later?

error: 'rustfmt' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'

hi thanks for the previous help, now it just stopping on this step (the maturin works flawlessly on local ubuntu 20.04)

can you help me with this issue or this needs other solution?

full error:

error: failed to run custom build command for `solana-storage-proto v1.10.0`

Caused by:
  process didn't exit successfully: `/home/runner/work/solana-bigtable-decode/solana-bigtable-decode/target/release/build/solana-storage-proto-766b0050c1859d92/build-script-build` (exit status: 1)
  --- stdout
  cargo::rerun-if-changed=proto/confirmed_block.proto
  cargo::rerun-if-changed=proto/transaction_by_addr.proto

  --- stderr
  error: 'rustfmt' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'
  To install, run `rustup component add rustfmt`
warning: build failed, waiting for other jobs to finish...
error: build failed
๐Ÿ’ฅ maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `cargo rustc --manifest-path Cargo.toml --message-format json --release --lib --`

Cargo.toml ->

[package]
name = "solana-bigtable-decode"
version = "1.0.0"
edition = "2021"
authors = ["BenFerrum"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "solana_bigtable_decode"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.15.1", features = ["extension-module"] }
solana-storage-bigtable = "1.10.0"
solana-transaction-status = "1.10.0"
bincode = "1.3.3"
enum-iterator = "0.7.0"
serde = "*"
serde_json = "*"
futures = "0.3.21"
solana-sdk = "1.10.0"
tokio = { version = "1.17.0", features = ["full"] }
#cpython = "*"

[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]

Question: cross compile to manylinux: `aarch64-unknown-linux-gnu`

Hi!

I am trying to cross compile polars to manylinux aarch64, but the pipeline fails with:

stacktrace process didn't exit successfully: `/home/runner/work/polars/polars/py-polars/target/release/build/zstd-sys-144b3faaf22a9632/build-script-build` (exit status: 1) --- stdout TARGET = Some("aarch64-unknown-linux-gnu") HOST = Some("x86_64-unknown-linux-gnu") CC_aarch64-unknown-linux-gnu = None CC_aarch64_unknown_linux_gnu = None TARGET_CC = None CC = None CROSS_COMPILE = None CFLAGS_aarch64-unknown-linux-gnu = None CFLAGS_aarch64_unknown_linux_gnu = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") CARGO_CFG_TARGET_FEATURE = Some("fp,neon,pmuv3") running: "aarch64-linux-gnu-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/home/runner/work/polars/polars/py-polars/target/aarch64-unknown-linux-gnu/release/build/zstd-sys-0db46d8e29890f56/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c" running: "aarch64-linux-gnu-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/home/runner/work/polars/polars/py-polars/target/aarch64-unknown-linux-gnu/release/build/zstd-sys-0db46d8e29890f56/out/zstd/lib/common/zstd_common.o" "-c" "zstd/lib/common/zstd_common.c"

--- stderr

error occurred: Failed to find tool. Is aarch64-linux-gnu-gcc installed?

This is my setup. Any ideas?

      - name: Install latest Rust nightly
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly-2022-01-01
          override: true
      - name: Add target
        run: |
          rustup target add aarch64-unknown-linux-gnu
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.7
      - name: Prepare maturin publish
        shell: bash
        run: |
          rm py-polars/README.md
          cp README.md py-polars/README.md
          cd py-polars
          rustup override set nightly-2022-01-01
      - name: Set up QEMU
        id: qemu
        uses: docker/setup-qemu-action@v1
        with:
          image: tonistiigi/binfmt:latest
          platforms: all
      - name: maturin publish
        uses: messense/maturin-action@v1
        env:
          MATURIN_PASSWORD: ${{ secrets.PYPI_PASS }}
        with:
          target: aarch64-unknown-linux-gnu
          maturin-version: 0.12.1
          command: publish
          args: -m py-polars/Cargo.toml --no-sdist -o wheels -i python -u ritchie46 

messense/manylinux2014-cross g++ does not recognize c++17 flag

Using container

      - name: Build Wheels
        uses: messense/maturin-action@v1
        with:
          rust-toolchain: stable
          rustup-components: rustfmt
          target: ${{ matrix.target }}
          manylinux: 2014
          args: --release --out dist --interpreter '3.7 3.8 3.9 3.10 3.11'
          container: messense/manylinux2014-cross:${{ matrix.target }}

Got warning

warning: x86_64-unknown-linux-gnu-g++: error: unrecognized command line option '-std=c++17'.

Does it mean that a newer version of g++ is needed?

maturin-action only builds wheel for one Python version on macOS (and not all installed)

I'm trying to build wheels for multiple Python version in one run. On Linux and Windows this works perfect, but on macOS it only finds a single Python version, while four Python versions (six including PyPy) are installed. For macOS, I'm trying to build universal wheels for x86-64 and Apple Silicon using --universal2.

Windows Server 2019

๐Ÿ Found CPython 3.10 at C:\hostedtoolcache\windows\Python\3.10.0\x64\python.exe, CPython 3.9 at C:\hostedtoolcache\windows\Python\3.9.8\x64\python.exe, CPython 3.8 at C:\hostedtoolcache\windows\Python\3.8.10\x64\python.exe, CPython 3.7 at C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe

Ubuntu 20.04 (with manylinux: auto)

`Found CPython 3.7m at python3.7, CPython 3.8 at python3.8, CPython 3.9 at python3.9, CPython 3.10 at python3.10, PyPy 3.7 at pypy3.7

macOS 11 (with --universal2)

Found CPython 3.9 at python3.9

Install system libraries

Hopefully this is an easy one. I would like to apt-get install a bunch of libraries before starting a build in a 2_24 container, is that a bad idea and if not, how do I go about it? I assume just running the command before the maturin-action step will not affect the container the build itself happens in?

Passing custom environment variables to Docker

Hi!

I am trying to ensure that a custom environment variable that I use at build-time is passed into manylinux builds, but it seems we currently only corner-case certain env var prefixes such as CARGO_* and RUST*.

My use-case here is to create a Rust const that is dependent on environment variables at compilation-time.

My workaround is currently to add a RUST* prefix to my environment variable to circumvent this: Eventual-Inc/Daft#432

However, it would be useful if maturin-action supported the specification of environment variables that are to be passed into the docker container at build-time!

A previous issue that was filed for this same request: #69

Drop Python 3.6 support in Linux.

I use this action from maturin new, and the linux job failed as the following error message.

error: failed to run custom build command for `pyo3-ffi v0.16.0`

Caused by:
  process didn't exit successfully: `/home/runner/work/cotton2k/cotton2k/target/release/build/pyo3-ffi-d1bffb9111c972d8/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG

  --- stderr
  error: the configured Python interpreter version (3.6) is lower than PyO3's minimum supported version (3.7)
warning: build failed, waiting for other jobs to finish...
error: build failed
๐Ÿ’ฅ maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `cargo rustc --message-format json --manifest-path python/Cargo.toml --release --lib --`
Error: The process '/usr/bin/docker' failed with exit code 1

Auto generated pyo3 CI.yml fails

Hi there, thanks for this awesome project!

The file autogenerated by py03 / maturin is below. The Linux step fails with the following logs:

Run messense/maturin-action@v1
Found maturin version requirement maturin>=0.13,<0.14 specified in pyproject.toml
Found maturin release from manifest: v0.13.[7](https://github.com/happy-machine/FastQL/actions/runs/3596488574/jobs/6057218590#step:3:8)
Pull Docker image
Cleanup build scripts artifact directory
/usr/bin/docker run --rm --workdir /home/runner/work/FastQL/FastQL -e DEBIAN_FRONTEND=noninteractive -e ARCHFLAGS -e _PYTHON_SYSCONFIGDATA_NAME -v /home/runner/work/FastQL/FastQL:/home/runner/work/FastQL/FastQL quay.io/pypa/manylinux2014_x[8](https://github.com/happy-machine/FastQL/actions/runs/3596488574/jobs/6057218590#step:3:9)6_64:latest /home/runner/work/FastQL/FastQL/run-maturin-action.sh
Install Rust
Install maturin
๐Ÿ”— Found pyo3 bindings
๐Ÿ Found CPython 3.7m at /usr/local/bin/python3.7, CPython 3.8 at /usr/local/bin/python3.8, CPython 3.[9](https://github.com/happy-machine/FastQL/actions/runs/3596488574/jobs/6057218590#step:3:10) at /usr/local/bin/python3.9, CPython 3.10 at /usr/local/bin/python3.10, CPython 3.11 at /usr/local/bin/python3.11, PyPy 3.7 at /usr/local/bin/pypy3.7, PyPy 3.8 at /usr/local/bin/pypy3.8, PyPy 3.9 at /usr/local/bin/pypy3.9
๐Ÿ’ฅ maturin failed
  Caused by: Failed to build source distribution
  Caused by: Attempting to include the sdist output tarball dist/fastql-0.1.0.tar.gz into itself! Check 'cargo package --list' output.
Error: The process '/usr/bin/docker' failed with exit code 1
Error: The process '/usr/bin/docker' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:[170](https://github.com/happy-machine/FastQL/actions/runs/3596488574/jobs/6057218590#step:3:175)2:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/messense/maturin-action/v1/dist/index.js:1579:27)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

Can you help me fix this please?

name: CI

on:
  push:
    branches:
      - main
      - master
  pull_request:

jobs:
  linux:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: messense/maturin-action@v1
      with:
        manylinux: auto
        command: build
        args: --release --sdist -o dist --find-interpreter
    - name: Upload wheels
      uses: actions/upload-artifact@v2
      with:
        name: wheels
        path: dist

  windows:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v3
    - uses: messense/maturin-action@v1
      with:
        command: build
        args: --release -o dist --find-interpreter
    - name: Upload wheels
      uses: actions/upload-artifact@v2
      with:
        name: wheels
        path: dist

  macos:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v3
    - uses: messense/maturin-action@v1
      with:
        command: build
        args: --release -o dist --universal2 --find-interpreter
    - name: Upload wheels
      uses: actions/upload-artifact@v2
      with:
        name: wheels
        path: dist

  release:
    name: Release
    runs-on: ubuntu-latest
    if: "startsWith(github.ref, 'refs/tags/')"
    needs: [ macos, windows, linux ]
    steps:
      - uses: actions/download-artifact@v2
        with:
          name: wheels
      - name: Publish to PyPI
        uses: messense/maturin-action@v1
        env:
          MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
        with:
          command: upload
          args: --skip-existing *

GLIBC versions not found

This may be a manylinux issue but I'm sure it was working before...

2022-03-20T21:15:58.5505775Z ##[group]Run messense/maturin-action@v1
2022-03-20T21:15:58.5506099Z with:
2022-03-20T21:15:58.5506314Z   maturin-version: latest
2022-03-20T21:15:58.5506551Z   manylinux: auto
2022-03-20T21:15:58.5506786Z   rust-toolchain: nightly
2022-03-20T21:15:58.5507492Z   command: build
2022-03-20T21:15:58.5508140Z   args: --release
2022-03-20T21:15:58.5508363Z ##[endgroup]
2022-03-20T21:15:58.5668682Z ##[command]/usr/bin/docker exec  de6c43a441d76afc6e7aa6deb8219280c54ee0a90106f4888d10314ddeba624e sh -c "cat /etc/*release | grep ^ID"
2022-03-20T21:15:58.7794762Z /__e/node12/bin/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7795590Z /__e/node12/bin/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7796479Z /__e/node12/bin/node: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7797317Z /__e/node12/bin/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7797875Z /__e/node12/bin/node: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7798386Z /__e/node12/bin/node: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7798910Z /__e/node12/bin/node: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /__e/node12/bin/node)
2022-03-20T21:15:58.7907103Z Stop and remove container: a06b5f724f174a38bbd61f7c011ef8d6_konstin2maturinmaster_95bd55

Current directory

Sorry to fire such a stupid issue, but since maturin does not have many configurations (by design) I'm having a hard time in finding a way to run this action in a workflow, when the crate I want to compile is part of a workspace.

Indeed the action is failing with:

๐Ÿ’ฅ maturin failed
  Caused by: Failed to parse Cargo.toml at Cargo.toml
  Caused by: missing field `package` at line 9 column 1

that happens because the Cargo.toml it is looking is the one of the workspace, rather than the one of the crate I would like to package.

Is it possible to get an option to use with with: in order to specify which directory (and thus which crate) to use?
Maybe I'm just too stupid, but I'm not finding a way to make an action run with a specific directory...

Error: Python interpreter version (3.6) is lower than PyO3's minimum supported version (3.7)

  error: the configured Python interpreter version (3.6) is lower than PyO3's minimum supported version (3.7)
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 status: 101": `"cargo" "rustc" "--release" "--target" "x86_64-unknown-linux-gnu" "--manifest-path" "/home/runner/work/nutpie/nutpie/Cargo.toml" "--message-format" "json" "--lib"`
Error: The process '/usr/bin/docker' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1702:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1579:27)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
Error: The process '/usr/bin/docker' failed with exit code 1

This is the PR: pymc-devs/nutpie#29
I don't see Python 3.6 specified anywhere, just 3.9.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.