Bug 14721

Summary: python-argon2_cffi no longer works
Product: buildroot Reporter: Emile Cormier <emile.cormier.jr>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: arnout, buildroot, yann.morin.1998
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: Snippet of the build log concerning argon2-cffi and argon2-cffi-bindings

Description Emile Cormier 2022-03-30 00:39:59 UTC
Created attachment 9256 [details]
Snippet of the build log concerning argon2-cffi and argon2-cffi-bindings

Commit https://github.com/buildroot/buildroot/commit/e2957f5ce743cfaf4fb3aaa98d619e83e8e6989e breaks the argon2-cffi Python package for my ARM target (Beaglebone Black).

The installation of the argon2-cffi Python package somehow got broken with the version bump. Just before that commit, I get (via serial terminal):

# python -c 'help("modules")' | grep argon2
__future__          argon2              gzip                selectors

# python -c 'from argon2 import PasswordHasher; print(PasswordHasher().hash("cor
rect horse battery staple"));'
$argon2id$v=19$m=102400,t=2,p=8$qHc/evoNvfGlp98pE26Ayw$tZWcHYjxFTKDUoaSysapPA

And just after that commit, I get:
# python -c 'help("modules")' | grep argon2
_argon2_cffi_bindings ast                 hmac                shutil

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'argon2'

argon2-cffi is the only Python package I have enabled via menu xconfig for this test.

I've attached a snippet of the build log concerning argon2-cffi and argon2-cffi-bindings.
Comment 1 Emile Cormier 2022-03-30 03:17:59 UTC
TL;DR: The new Python flit setup infrastructure seems to be deploying to the wrong destination directory.

-----

I see now that argon2-cffi now uses the new flit setup type. The argon2-cffi package now gets installed under

    /lib/python3.10/site-packages/argon2

whereas it used to be installed under

    /usr/lib/python3.10/site-packages


Here's the output of 'python -m site' on my BeagleBone Black device:

sys.path = [
    '/lib/python3.10/site-packages/argon2',
    '/usr/lib/python310.zip',
    '/usr/lib/python3.10',
    '/usr/lib/python3.10/lib-dynload',
    '/usr/lib/python3.10/site-packages',
]
USER_BASE: '/root/.local' (doesn't exist)
USER_SITE: '/root/.local/lib/python3.10/site-packages' (doesn't exist)
ENABLE_USER_SITE: True


If I add /lib/python3.10/site-packages to the "real" system-wide site-packages via:

    echo "/lib/python3.10/site-packages" > /usr/lib/python3.10/site-packages/extra.pth

then argon2 now appears in

    python -c 'help("modules")'

and the following test command works!

    # python -c 'from argon2 import PasswordHasher; print(PasswordHasher().hash("correct horse battery staple"));'
    $argon2id$v=19$m=65536,t=3,p=4$CZO2H3qcZr/Vp9w0qVpLxA$eAz24Ry+cvSdRTJaPYDcf9HTc/Zyq/PmoFkFFPcQHm0
Comment 2 Emile Cormier 2022-03-30 04:11:23 UTC
I've tracked it down to package/pkg-python.mk using

/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages

instead of

/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages

Submitted a patch via the mailing list: https://lists.buildroot.org/pipermail/buildroot/2022-March/639798.html

I can import and use the argon2 module in a Python program with those changes.
Comment 3 Yann E. MORIN 2022-04-03 09:42:18 UTC
Emile, All,

Thans for your bug report. We believe this has now been fixed with
commit 5bea8c9521b3 (package/pkg-python.mk: fix PEP517 paths).

Regards,
Yann E. MORIN.
Comment 4 Emile Cormier 2022-04-03 19:15:05 UTC
I confirm that the PasswordHasher test works for me with the latest master.