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: 3 comments 4 replies
-
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(feature = "openssl-vendored")]
use openssl_probe;
use pyo3::prelude::*;
#[cfg(feature = "openssl-vendored")]
fn probe_ssl_certs() {
openssl_probe::init_ssl_cert_env_vars();
}
#[cfg(not(feature = "openssl-vendored"))]
fn probe_ssl_certs() {}
#[pyfunction]
pub fn main() {
probe_ssl_certs();
} Tip The implemented |
Beta Was this translation helpful? Give feedback.
-
Very glad to have found this (may solve my issue at #326) however I would note that I did not need the openssl-vendored feature for macOS, for me those wheels built fine without it - it is just aarch64 that is failing for me P.S. it should be feature not features when used in // See discussion 162
// https://github.com/PyO3/maturin-action/discussions/162#discussioncomment-7978369
#[cfg(feature = "openssl-vendored")]
use openssl_probe;
...
// See discussion 162
#[cfg(feature = "openssl-vendored")]
fn probe_ssl_certs() {
openssl_probe::init_ssl_cert_env_vars();
}
// See discussion 162
#[cfg(not(feature = "openssl-vendored"))]
fn probe_ssl_certs() {} |
Beta Was this translation helpful? Give feedback.
Try the
before-script-linux
option, see #157