Search code examples
pythonrustpyo3

Using Maturin when external library is needed


I'm trying to make a Python package from a Rust Crate I'm making. The problem is that I need the RGSL crate which needs libgsl0-dev installed in the system.

I'm trying to publish using Maturin which uses Manylinux Docker image to build everything for Linux. The problem is that image doesn't have libgsl0-dev installed, so I made a custom image adding one line:

FROM konstin2/maturin

# To solve problems with CentOS 6 EOL 
RUN echo "https://vault.centos.org/6.10/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/sclo/x86_64/rh" > /var/cache/yum/x86_64/6/centos-sclo-rh/mirrorlist.txt
RUN echo "http://vault.centos.org/6.10/sclo/x86_64/sclo" > /var/cache/yum/x86_64/6/centos-sclo-sclo/mirrorlist.txt

# Installs needed library
RUN yum install -y libgsl0-dev

ENTRYPOINT ["/usr/bin/maturin"]

But when I try to build with:

docker run --rm -v $(pwd):/io custom-image build --cargo-extra-args="--no-default-features"

⚠ Warning: You're building a library without activating pyo3's extension-module feature. See https://pyo3.rs/v0.12.4/building_and_distribution.html#linking 🔗 Found pyo3 bindings 🐍 Found CPython 3.6m at python3.6, CPython 3.7m at python3.7, CPython 3.8 at python3.8, CPython 3.9 at python3.9
Compiling pyo3 v0.12.4 error: could not find native static library python3.6m, perhaps an -L flag is missing

What I'm missing here? Any kind of help would be really appreciated


Solution

  • As an user pointed me out in this issue, there was a problem with the installed GSL version: I was using a function which was added in the last release of the library. Also I have to user the command wheel-repair to include some missing .so files. The entire process is in this issue