could not find system library 'openssl' required by the 'openssl-sys' crate #162
-
it seems I don't have openssl installed during CI (linux) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Try the |
Beta Was this translation helpful? Give feedback.
-
It took me a while, but I was able to augment the maturin-generated CI workflow to use a combination of these tactics: - name: Calculate openssl-vendored
shell: bash
id: is-openssl-vendored
run: |
if [[ "${{ startsWith(matrix.target, 'x86') }}" == "true" ]]; then
echo "enabled=" >> $GITHUB_OUTPUT
else
echo "enabled=--features openssl-vendored" >> $GITHUB_OUTPUT
fi
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter ${{ steps.is-openssl-vendored.outputs.enabled }}
manylinux: auto
before-script-linux: |
case "${{ matrix.target }}" in
"aarch64" | "armv7" | "s390x" | "ppc64le")
# NOTE: pypa/manylinux docker images are Debian based
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
;;
"x86" | "x86_64")
# NOTE: rust-cross/manylinux docker images are CentOS based
yum update -y
yum install -y openssl openssl-devel
;;
esac The secret sauce is in a cargo feature that I added to conditionally invoke the openssl vendored feature: [dependencies]
openssl = { version = "0.10", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1", optional = true }
[features]
openssl-vendored = ["dep:openssl", "dep:openssl-probe"] Note I'm a little worried this conditional feature approach won't work on piwheels because the feature is disabled by default. I'll cross that bridge if ever needed. And use that feature to conditionally invoke #[cfg(features = "openssl-vendored")]
use openssl_probe;
use pyo3::prelude::*;
#[cfg(features = "openssl-vendored")]
fn probe_ssl_certs() {
openssl_probe::init_ssl_cert_env_vars();
}
#[cfg(not(openssl_probe))]
fn probe_ssl_certs() {}
#[pyfunction]
pub fn main() {
probe_ssl_certs();
} Tip The implemented |
Beta Was this translation helpful? Give feedback.
Try the
before-script-linux
option, see #157