piwheels / packages

Issue tracker for piwheels package issues
https://github.com/piwheels/packages/issues
20 stars 5 forks source link

Broken package: uWSGI #292

Closed cuu508 closed 2 years ago

cuu508 commented 2 years ago

Package name

uWSGI

Package version

20.0.20

PyPI URL

https://pypi.org/project/uWSGI/

piwheels URL

https://www.piwheels.org/project/uWSGI/

Python version

I am the maintainer

More information

I'm using uwsgi in a Docker environment. A minimal Dockerfile to demonstrate the issue:

FROM python:3.9-slim-buster
RUN printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf
RUN pip install uwsgi 
CMD [ "uwsgi", "--version"]

When I build and run it, I get:

$ docker run --rm -it $(docker build -q .) 
uwsgi: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

I think this may in fact be an issue with the "python:3.9-slim-buster" base image – the base image may have removed something that the binary uwsgi package relied on. If I install uwsgi in the Raspbian host OS, it works.

Perhaps somebody more experienced than me can see right away what the issue is, and see if there's an easy workaround. If this is indeed an issue with the base image, and there is no reasonable fix on piwheels side, then please close this issue, and sorry for the bother.

bennuttall commented 2 years ago

The comments in here may be of use: https://github.com/piwheels/packages/issues/247

cuu508 commented 2 years ago

FWIW, I also tested python:3.9-buster (non-slim) base image and got the same error. I also tested with libxml2 package installed, and got a different error message about another missing dependency (unfortunately don't have the error message handy – but I can reproduce it if it would help).

For time being, my workaround is to not use uwsgi binary package from piwheels, but but build it from source.

bennuttall commented 2 years ago

Are you definitely using the armhf image?

cuu508 commented 2 years ago

The Dockerfile I'm using is:

FROM python:3.9-slim-buster
RUN printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf
RUN pip install uwsgi 
CMD [ "uwsgi", "--version"]

And I'm building it on Pi 400:

docker run --rm -it $(docker build -q .) 
bennuttall commented 2 years ago

What are the Python dependencies of uwsgi? If any of the packages in the dependency tree require apt packages, that might be it. Check each package's project page to be sure, e.g. numpy: https://www.piwheels.org/project/numpy/

cuu508 commented 2 years ago

I did a couple more experiments. First, here's the error when I use the python:3.9-buster base image:

uwsgi: /lib/arm-linux-gnueabihf/libcrypt.so.1: version `XCRYPT_2.0' not found (required by uwsgi)
uwsgi: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.29' not found (required by uwsgi)

Looking at https://www.piwheels.org/project/uwsgi/ I'm guessing the py3.9 version of the wheel was built on Debian bullseye, but I'm trying to use it on Debian buster, which has different glibc version and that's probably where the problem is.

OK, next I tried the python:3.9-bullseye base image:

$ docker build .
Sending build context to Docker daemon  475.6kB
Step 1/4 : FROM python:3.9-bullseye
3.9-bullseye: Pulling from library/python
17a41fc76249: Pull complete 
9173ee01c42f: Pull complete 
f119f27841bd: Pull complete 
3b827df064e1: Pull complete 
679a4f7c8e65: Pull complete 
f46d8776b187: Pull complete 
6f544cc219ce: Pull complete 
dc157c9ef889: Pull complete 
2ad971f60bd0: Pull complete 
Digest: sha256:1f7b4d6a14489f570000aa763cbbde71d5fe404cc43563c82f9b807c757a2113
Status: Downloaded newer image for python:3.9-bullseye
 ---> 355c3062baa7
Step 2/4 : RUN printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf
 ---> Running in 1faffa6ec9bb
Removing intermediate container 1faffa6ec9bb
 ---> df9a583eda6a
Step 3/4 : RUN pip install uwsgi
 ---> Running in 0396223eb4a9
Fatal Python error: init_interp_main: can't initialize time
Python runtime state: core initialized
PermissionError: [Errno 1] Operation not permitted

Current thread 0xb6fc1010 (most recent call first):
<no Python frame>
The command '/bin/sh -c pip install uwsgi' returned a non-zero code: 1

I'm not sure what the error message means exactly here, but it's probably an issue with the base image, not with the uwsgi package – I get the same error when installing e.g. numpy. So I think the uwsgi package is fine, and the problem was/is:

  1. I was using it with the wrong base image
  2. The correct base image appears to be currently broken (or I'm holding it wrong)
bennuttall commented 2 years ago

Ah, yes. Wheels are built on and for the same OS version.