perl error building rust-openssl with maturin, ubuntu and manylinux

While building Python packages for Xvc with maturin, I was receiving in Github Actions CI for Linux packages.

Can't locate IPC/ in @INC (@INC contains: /home/runner/work/ /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /home/runner/work/

The issue seemed to be a missing perl package. Building rust-openssl now seems to require perl-core package.

I added a apt-get update && apt-get install perl-core to the CI configuration. But that didn’t work.

Because, as this Github issue comment said maturin with its manylinux support uses different kind of Docker containers to build the packages. We must detect if it’s a CentOS or Debian based container and install missing packages.

Building wheels step in the config should be similar to:

      - name: Build wheels
        uses: PyO3/maturin-action@v1
          target: ${{ }}
          manylinux: auto
          args: --release --out dist
          before-script-linux: |
            # If we're running on rhel centos, install needed packages.
            if command -v yum &> /dev/null; then
                yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic

                # If we're running on i686 we need to symlink libatomic
                # in order to build openssl with -latomic flag.
                if [[ ! -d "/usr/lib64" ]]; then
                    ln -s /usr/lib/ /usr/lib/
                # If we're running on debian-based system.
                apt update -y && apt-get install -y libssl-dev openssl pkg-config

This will the specified script before running the maturin build command in the container and add missing packages.