Skip to content

python-cryptography: update to 49.0.0#29942

Open
ognevny wants to merge 1 commit into
msys2:masterfrom
ognevny:update-py-cryptography
Open

python-cryptography: update to 49.0.0#29942
ognevny wants to merge 1 commit into
msys2:masterfrom
ognevny:update-py-cryptography

Conversation

@ognevny

@ognevny ognevny commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@ognevny

ognevny commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author
  error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
    |
    = note: "x86_64-w64-mingw32-gcc" "-Wl,D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\deps\\rustcUiO9xL\\list.def" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\deps\\rustcUiO9xL\\symbols.o" "<17 object files omitted>" "-Wl,-Bstatic" "D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\deps/{libcryptography_cffi-bd59fbee0eb59e02,libcryptography_keepalive-68829479ab813d2d,libself_cell-dea64d1da82648b0,libcryptography_x509_verification-d1592fb74932728d,libcryptography_key_parsing-b9d42456a873803b,libpem-bf6379b5700efa02,libcryptography_openssl-61de2f1aa0bc0fb6,libbase64-f88bccd493762ff7,libcryptography_crypto-00a46ea35fe25c6b,libcryptography_x509-e5db47411c180b2f,libasn1-d1883ac09273dbe3,libitoa-0efe3a9074d82e10,libpyo3-352d5922a6367da2,libonce_cell-768700bda5b9d8a9,libpyo3_ffi-48540323b8c5a3e7,libopenssl-b4da30a6c91bc7ff,libbitflags-b12d13a6d4d3bdf5,libcfg_if-fc26b24cab6e05f5,libforeign_types-784fcf9760e1a679,libforeign_types_shared-75a10d3596a47890,libopenssl_sys-1a20322a1f5be160,liblibc-c87f1baf6bdfeeb6}.rlib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,libwindows_link-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lkernel32" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmingwex" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\build\\cryptography-cffi-7c99c6514e52c864\\out" "-L" "D:/M/msys64/ucrt64/libs" "-o" "D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\deps\\cryptography_rust.dll" "-Wl,--gc-sections" "-shared" "-Wl,--out-implib=D:\\_\\B\\src\\python-build-UCRT64\\target\\release\\deps\\libcryptography_rust.dll.a" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
    = note: some arguments are omitted. use `--verbose` to show all linker arguments
    = note: D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_SSL_set_tlsext_host_name+0x193): undefined reference to `__imp__Py_NoneStruct'
            D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_sk_X509_free+0xd3): undefined reference to `__imp__Py_NoneStruct'
            D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_sk_X509_NAME_free+0xd3): undefined reference to `__imp__Py_NoneStruct'
            D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_X509_free+0xd3): undefined reference to `__imp__Py_NoneStruct'
            D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_X509_VERIFY_PARAM_set_time+0x133): undefined reference to `__imp__Py_NoneStruct'
            D:/M/msys64/ucrt64/lib/gcc/x86_64-w64-mingw32/16.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\_\B\src\python-build-UCRT64\target\release\deps\libcryptography_cffi-bd59fbee0eb59e02.rlib(e926d15ae519cd8f-_openssl.o):_openssl.c:(.text$_cffi_f_X509_VERIFY_PARAM_set_hostflags+0x133): more undefined references to `__imp__Py_NoneStruct' follow
            collect2.exe: error: ld returned 1 exit status
            
    = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
    = note: use the `-l` flag to specify native libraries to link
    = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

@ognevny ognevny force-pushed the update-py-cryptography branch from 03b9cdf to c955a22 Compare June 13, 2026 08:18
@ognevny ognevny marked this pull request as draft June 13, 2026 08:57
@lazka

lazka commented Jun 14, 2026

Copy link
Copy Markdown
Member

@ognevny

ognevny commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator Author

so that's pyo3 regression?

@lazka

lazka commented Jun 14, 2026

Copy link
Copy Markdown
Member

yeah, I don't quite get it... I thought it's because the wrongdir is hardcoded, but it doesn't link anymore as well.

@lazka

lazka commented Jun 14, 2026

Copy link
Copy Markdown
Member

I guess the cause is PyO3/pyo3#5866 - seems they hardcode various things there.

@lazka

lazka commented Jun 14, 2026

Copy link
Copy Markdown
Member

while it builds now, it doesn't work:

$ python3 -c "from cryptography.hazmat.primitives import hashes, hmac"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from cryptography.hazmat.primitives import hashes, hmac
  File "C:/msys64/clang64/lib/python3.14/site-packages/cryptography/hazmat/primitives/hashes.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import openssl as rust_openssl
ImportError: DLL load failed while importing _rust: The specified module could not be found.

@ognevny

ognevny commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator Author

they used cool rust feature, but made it so bad 😩

@ognevny

ognevny commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator Author

while it builds now, it doesn't work:

$ python3 -c "from cryptography.hazmat.primitives import hashes, hmac"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from cryptography.hazmat.primitives import hashes, hmac
  File "C:/msys64/clang64/lib/python3.14/site-packages/cryptography/hazmat/primitives/hashes.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import openssl as rust_openssl
ImportError: DLL load failed while importing _rust: The specified module could not be found.

thankfully we shouldn't rush because pyopenssl still doesn't accept cryptography-49

@lazka

lazka commented Jun 14, 2026

Copy link
Copy Markdown
Member

it seems link against "python3.dll" explicitly instead of "libpython3.dll"

@ognevny

ognevny commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator Author

help wanted in PyO3/pyo3#6159

@ognevny ognevny force-pushed the update-py-cryptography branch 4 times, most recently from 3e6625d to 9f19825 Compare June 28, 2026 10:56
@ognevny ognevny marked this pull request as ready for review June 28, 2026 10:57
@ognevny

ognevny commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

ready with properly patched things

@ognevny ognevny force-pushed the update-py-cryptography branch from 9f19825 to d2a4dd5 Compare July 4, 2026 12:52
@ognevny

ognevny commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

applied PyO3/pyo3#6185 which is seems to be a final solution for the issue (requires an environment variable to be set)

@ognevny ognevny force-pushed the update-py-cryptography branch from d2a4dd5 to 26fa771 Compare July 4, 2026 13:00

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I'm sorry that this has caused such a frustrating breakage for you here.

In hindsight we really should have had the opt-out pathway I'm adding in PyO3/pyo3#6185 as part of PyO3 0.29 when the new raw-dylib linking was introduced. It is clear that with a hardcoded set there it would never work for all users.


build() {
cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

export OPENSSL_NO_VENDOR=1
export PYO3_USE_RAW_DYLIB=0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you shouldn't need to set this - I think that PyO3 should automatically notice that your lib name isn't in the hardcoded set which support raw-dylib linking and toggle this mode automatically.

(Hopefully in the future the raw-dylib link set shouldn't be hardcoded, this seems to be a limitation in rustc and I'll work to fix it there.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without env var it didn't work:(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please retry with latest commit PyO3/pyo3@9451f0e ? I think that should now remove the need for the env var properly (so mingw users do not need to set this for their arbitrary builds)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try later in the evening

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll push these hunks, but it didn't work on my machine

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks. I guess we keep it like this for now in the patch release, I'll work on a better long-term fix upstream.

@ognevny ognevny force-pushed the update-py-cryptography branch from 26fa771 to 8ca5b48 Compare July 5, 2026 15:29
@ognevny ognevny force-pushed the update-py-cryptography branch from 8ca5b48 to ac39f6c Compare July 5, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants