Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seems missing _ffi.abi3.so when pip installing in docker #67

Closed
CACppuccino opened this issue Sep 10, 2020 · 7 comments
Closed

seems missing _ffi.abi3.so when pip installing in docker #67

CACppuccino opened this issue Sep 10, 2020 · 7 comments

Comments

@CACppuccino
Copy link

Hi,

We encountered a weird error when installing the argon2 in Alpine Linux Docker.
When using the argon2 as part of hasher in Django, it triggers an error saying Couldn't load 'Argon2PasswordHasher' algorithm library: No module named 'argon2._ffi'

After we looked into the docker's site-package, we found that the argon2 directory is missing the _ffi.abi3.so file which generates this error. We rebuilt the docker several times and the error still exists, it can be reproduced every time.

Python: 3.6.10
Docker base image: python3.6-alpine3.10
Django: 2.2.4
Argon2: 19.1.0

So is there any better solutions than copying so file directly into docker? and I was wondering what makes this happen?

@hynek
Copy link
Owner

hynek commented Sep 10, 2020

Could it be that the build of the C extension fails? When use alpine, you can't use wheels and have to compile all your C extensions yourself.

@CACppuccino
Copy link
Author

Could it be that the build of the C extension fails? When use alpine, you can't use wheels and have to compile all your C extensions yourself.

This could be the reason, but from the records of building docker, I didn't see any errors generated from there.

Collecting argon2-cffi==19.1.0
  Downloading argon2_cffi-19.1.0.tar.gz (1.8 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'

...

Building wheel for argon2-cffi (setup.py): started
  Building wheel for argon2-cffi (setup.py): finished with status 'done'
  Created wheel for argon2-cffi: filename=argon2_cffi-16.0.0-cp36-cp36m-linux_x86_64.whl size=37754 sha256=e41e66f9f81a7e75bdf69c7c8c8a7ea90a7d95419c22450fec6793591102cc63
  Stored in directory: /tmp/pip-ephem-wheel-cache-bw4l_lpc/wheels/3b/31/e5/816e76bc4496b810ac0eb9452fc96858c08155a06d5c877583

@hynek
Copy link
Owner

hynek commented Sep 10, 2020

There is something going very wrong. It says

Collecting argon2-cffi==19.1.0

But then it says

Created wheel for argon2-cffi: filename=argon2_cffi-16.0.0-cp36-cp36m-linux_x86_64.whl

!?

This looks like an old-fashioned packaging FUBAR to me TBH.

@CACppuccino
Copy link
Author

oh its a mistake of pasting, sry on that part. I did try downgrade the version but still failed on installation

Collecting argon2-cffi==16.0.0
  Downloading argon2_cffi-16.0.0.tar.gz (822 kB)

Building wheel for argon2-cffi (setup.py): started
  Building wheel for argon2-cffi (setup.py): finished with status 'done'
  Created wheel for argon2-cffi: filename=argon2_cffi-16.0.0-cp36-cp36m-linux_x86_64.whl size=37754 sha256=e41e66f9f81a7e75bdf69c7c8c8a7ea90a7d95419c22450fec6793591102cc63
  Stored in directory: /tmp/pip-ephem-wheel-cache-bw4l_lpc/wheels/3b/31/e5/816e76bc4496b810ac0eb9452fc96858c08155a06d5c877583

@CACppuccino
Copy link
Author

# Python build stage
FROM python:3.6-alpine3.10

ENV PYTHONUNBUFFERED 1

RUN apk update \
  # psycopg2 dependencies
  && apk add --virtual build-deps gcc python3-dev musl-dev \
  # Pillow dependencies
  && apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
  # for grpcio
  && apk add linux-headers build-base \ 
  # CFFI dependencies
  && apk add libffi-dev py-cffi

RUN pip install --no-cache-dir argon2-cffi==19.1.0

USER root

WORKDIR /app

ENTRYPOINT ["/bin/sh"]

Thats the simplified version, after goes into shell, when trying to import argon2, there comes

/app # python
Python 3.6.10 (default, May 21 2020, 06:00:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import argon2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/argon2/__init__.py", line 5, in <module>
    from . import exceptions, low_level
  File "/usr/local/lib/python3.6/site-packages/argon2/low_level.py", line 17, in <module>
    from ._ffi import ffi, lib
ModuleNotFoundError: No module named 'argon2._ffi'

@hynek
Copy link
Owner

hynek commented Sep 10, 2020

If I change it to argon2-cffi==20.1.0 it works for me – same for you?

@CACppuccino
Copy link
Author

If I change it to argon2-cffi==20.1.0 it works for me – same for you?

Yes, this resolved my problem, thanks!

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

No branches or pull requests

2 participants