Community Packages

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#70258 - [python-pycryptodome] Somehow avoid running gcc at import time

Attached to Project: Community Packages
Opened by Mantas Mikulėnas (grawity) - Thursday, 01 April 2021, 19:25 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 01 April 2021, 19:52 GMT
Task Type Feature Request
Category Packages
Status Assigned
Assigned To Ike Devolder (BlackEagle)
Felix Yan (felixonmars)
Johannes Löthberg (demize)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


With Cryptodome 3.10, doing `import Crypto.Cipher.AES` will spawn gcc ~18 times *during import*, i.e. every time the program starts up. This takes ~500ms, so in my case importing Crypto takes several times longer than running the actual program that uses it.

(Apparently this was not the case in Cryptodome 3.9.)

According to #python, this is done by cffi. Is it possible to make it do the necessary things at package build time, instead of import time? (I mean, without uninstalling python-cffi, because I have other packages which need it.)
This task depends upon

Comment by Eli Schwartz (eschwartz) - Thursday, 01 April 2021, 19:44 GMT
It's not "done by cffi" as it turns out. In Crypto.Util._raw_api

load_lib() tries to cffi.FFI().dlopen() the full path to a filename, and if it fails because the filename does not exist, it runs the compiler weirdly, does nothing with it, and raises OSError.

load_pycryptodome_raw_lib() tries to load several different possible versions of any given *.so filename, and in the process uses a try/except for load_lib() which succeeds after a couple different filenames.
Comment by Eli Schwartz (eschwartz) - Thursday, 01 April 2021, 19:52 GMT
Should apply to both pycryptodome and pycryptodomex, not sure of the solution.

The upstream import shim looks... nuts...