I am trying to build cryptography 42.0.8 with custom OpenSSL 3.0.13.
It fails with following error.
Building wheels for collected packages: cryptography
Building wheel for cryptography (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for cryptography (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [514 lines of output]
running bdist_wheel
running build
running build_py
creating build
running build_ext
running build_rust
Updating crates.io index
Downloading crates ...
Downloaded autocfg v1.1.0
Downloaded asn1_derive v0.15.5
Downloaded openssl-src v300.3.1+3.3.1
cargo rustc --lib --message-format=json-render-diagnostics --manifest-path src\rust\Cargo.toml --release -v --features pyo3/extension-module --crate-type cdylib --
Compiling proc-macro2 v1.0.78
Compiling cc v1.0.83
...
Compiling openssl-src v300.3.1+3.3.1
Running `C:\Users\Devbox\buildarea\build_rust\Rustup\toolchains\1.78.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name openssl_src --edition=2021 C:\Users\Devbox\buildarea\build_rust\Cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-src-300.3.1+3.3.1\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg "feature=\"default\"" --cfg "feature=\"legacy\"" -C metadata=de2977b02223dfb8 -C extra-filename=-de2977b02223dfb8 --out-dir C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps -L dependency=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps --extern cc=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libcc-f78a0dc4481fc33f.rmeta --cap-lints allow`
...
Compiling lock_api v0.4.11
Running `C:\Users\Devbox\buildarea\build_rust\Rustup\toolchains\1.78.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name build_script_build --edition=2018 C:\Users\Devbox\buildarea\build_rust\Cargo\registry\src\index.crates.io-6f17d22bba15001f\lock_api-0.4.11\build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg "feature=\"atomic_usize\"" --cfg "feature=\"default\"" -C metadata=130183d620d5ad23 -C extra-filename=-130183d620d5ad23 --out-dir C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\build\lock_api-130183d620d5ad23 -L dependency=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps --extern autocfg=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libautocfg-a7af09be6e762f2e.rlib --cap-lints allow`
Running `C:\Users\Devbox\buildarea\build_rust\Rustup\toolchains\1.78.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name proc_macro2 --edition=2021 C:\Users\Devbox\buildarea\build_rust\Cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-macro2-1.0.78\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg "feature=\"default\"" --cfg "feature=\"proc-macro\"" -C metadata=2a3fb08b362d2fb7 -C extra-filename=-2a3fb08b362d2fb7 --out-dir C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps -L dependency=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps --extern unicode_ident=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libunicode_ident-d97b39ed2d23b7bc.rmeta --cap-lints allow --cfg wrap_proc_macro`
Compiling openssl-sys v0.9.102
Running `C:\Users\Devbox\buildarea\build_rust\Rustup\toolchains\1.78.0-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name build_script_main --edition=2018 C:\Users\Devbox\buildarea\build_rust\Cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-sys-0.9.102\build/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg "feature=\"openssl-src\"" --cfg "feature=\"vendored\"" -C metadata=bae7ea7910bbbd9b -C extra-filename=-bae7ea7910bbbd9b --out-dir C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\build\openssl-sys-bae7ea7910bbbd9b -L dependency=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps --extern cc=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libcc-f78a0dc4481fc33f.rlib --extern openssl_src=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libopenssl_src-de2977b02223dfb8.rlib --extern pkg_config=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libpkg_config-1d3a346ac74cc649.rlib --extern vcpkg=C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\deps\libvcpkg-6ffb6f1bae24aa0e.rlib --cap-lints allow`
...
error: failed to run custom build command for `openssl-sys v0.9.102`
Caused by:
process didn't exit successfully: `C:\Users\Devbox\buildarea\build_cryptography\cryptography-42.0.8\src\rust\target\release\build\openssl-sys-bae7ea7910bbbd9b\build-script-main` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
running "perl" "./Configure" "--prefix=C:/Users/Devbox/buildarea/build_cryptography/cryptography-42.0.8/src/rust/target/release/build/openssl-sys-78a038b9f453544a/out/openssl-build/install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-capieng" "no-asm" "VC-WIN64A"
Configuring OpenSSL version 3.3.1 for target VC-WIN64A
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created makefile.in
Created makefile
Created include\openssl\configuration.h
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL.md file first) ***
*** ***
**********************************************************************
running "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\nmake.exe" "build_libs"
...
D"MODULESDIR=\"C:\\Users\\Devbox\\buildarea\\build_cryptography\\cryptography-42.0.8\\src\\rust\\target\\release\\build\\openssl-sys-78a038b9f453544a\\out\\openssl-build\\install\\lib\\ossl-modules\"" -D"OPENSSL_BUILDING_OPENSSL" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG" "apps\lib\fmt.c" > apps\lib\libapps-lib-fmt.d 2>&1"
"cl" /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy -IC:\Users\Devbox\openssl\include -IC:\Users\Devbox\openssl\include\WinNT.10.0.2_x86-64_MSVC.14.3 -I"." -I"include" -I"apps\include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"C:\\Users\\Devbox\\buildarea\\build_cryptography\\cryptography-42.0.8\\src\\rust\\target\\release\\build\\openssl-sys-78a038b9f453544a\\out\\openssl-build\\install\\SYS\ANAGER:[OPENSSL]\"" -D"ENGINESDIR=\"C:\\Users\\Devbox\\buildarea\\build_cryptography\\cryptography-42.0.8\\src\\rust\\target\\release\\build\\openssl-sys-78a038b9f453544a\\out\\openssl-build\\install\\lib\\engines-3\"" -D"MODULESDIR=\"C:\\Users\\Devbox\\buildarea\\build_cryptography\\cryptography-42.0.8\\src\\rust\\target\\release\\build\\openssl-sys-78a038b9f453544a\\out\\openssl-build\\install\\lib\\ossl-modules\"" -D"OPENSSL_BUILDING_OPENSSL" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"NDEBUG" -c /Foapps\lib\libapps-lib-http_server.obj "apps\lib\http_server.c"
http_server.c
apps\lib\http_server.c(207): error C2065: 'OSSL_TRACE_CATEGORY_HTTP': undeclared identifier
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33521 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1077: '"cl" /Zi /Fdossl_static.pdb /MT /Zl /Gs0 /GF /Gy -IC:\Users\Devbox\openssl\include -IC:\Users\Devbox\openssl\include\WinNT.10.0.2_x86-64_MSVC.14. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path src\rust\Cargo.toml --release -v --features pyo3/extension-module --crate-type cdylib --` failed with code 101
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Failed to build one or more wheels
Root cause:
While building openssl-sys it is looking for symbol which is not present in OpenSSL 3.0.13.
OSSL_TRACE_CATEGORY_HTTP
is introduced in OpenSSL3.1.0
openssl/include/openssl/trace.h at openssl-3.1.0 · openssl/openssl · GitHub
I think forcing cargo to pick openssl-src 300.0.13+3.0.8
should resolve this issue.
I tried updating src/rust/Cargo.toml
as follows but it is still failing with above error.
openssl-src = { version = "300.0.13+3.0.8" }
openssl = { version = "0.10", features = ["vendored"] }
openssl-sys = { version = "0.9.92", optional = true }
Versions:
python 3.9.19
rustup 1.27.1
rustc 1.78.0
Host:
Windows 2022 Server
Visual Studio 2022
Steps to reproduce.
On Windows 2022 server with Visual Studio 2022,
- Install python 3.9.19
- Install rustc 1.78.0
- Install OpenSSL 3.0.13 at custom location
python -m pip download --no-binary :all: --no-deps cryptography==42.0.8
tar xmf cryptography-42.0.8.tar.gz
cd cryptography-42.0.8
export CFLAGS=/path/to/openssl-3.0.13/include
export LDFLAGS=/path/to/openssl-3.0.13/lib
export OPENSSL_DIR=/path/to/openssl-3.0.13
- make following changes in rust/src/Cargo.toml
openssl-src = { version = "300.0.13+3.0.8" }
openssl = { version = "0.10", features = ["vendored"] }
openssl-sys = { version = "0.9.92", optional = true }
python -m pip wheel . -w dist/
Note: I am running above commands in cygwin3.5.3 terminal.
Query:
Even after defining openssl-src 300.0.13+3.0.8 in Cargo.toml it is still building with openssl-src v300.3.1+3.3.1
is there some other place where we can define dependencies so that it will pick lower version of openssl while compiling Cryptography?