dockerpipdebianuwsgi

Cannot install python-uwsgi on Debian bookworm (Docker)


My Dockerfile:

FROM python:3.10-slim-bookworm

RUN apt update
RUN apt install -y build-essential

RUN pip install uwsgi

I get this error at the pip install uwsgi line:

[...]
2.882 Installing collected packages: uwsgi
2.882   Running setup.py install for uwsgi: started
3.154   Running setup.py install for uwsgi: finished with status 'error'
3.158   error: subprocess-exited-with-error
3.158   
3.158   × Running setup.py install for uwsgi did not run successfully.
3.158   │ exit code: 1
3.158   ╰─> [31 lines of output]
3.158       /usr/local/lib/python3.10/site-packages/setuptools/_distutils/dist.py:264: UserWarning: Unknown distribution option: 'descriptions'
3.158         warnings.warn(msg)
3.158       running install
3.158       /usr/local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
3.158         warnings.warn(
3.158       using profile: buildconf/default.ini
3.158       detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/12/include', '/usr/local/include', '/usr/include/x86_64-linux-gnu', '/usr/include']
3.158       Patching "bin_name" to properly install_scripts dir
3.158       detected CPU cores: 4
3.158       Traceback (most recent call last):
3.158         File "<string>", line 2, in <module>
3.158         File "<pip-setuptools-caller>", line 34, in <module>
3.158         File "/tmp/pip-install-dsdnjyg_/uwsgi_05831e8091e9471fb325b94690dc4a2a/setup.py", line 117, in <module>
3.158           setup(
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
3.158           return distutils.core.setup(**attrs)
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
3.158           return run_commands(dist)
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
3.158           dist.run_commands()
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
3.158           self.run_command(cmd)
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
3.158           super().run_command(command)
3.158         File "/usr/local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
3.158           cmd_obj.run()
3.158         File "/tmp/pip-install-dsdnjyg_/uwsgi_05831e8091e9471fb325b94690dc4a2a/setup.py", line 79, in run
3.158           uc.build_uwsgi(conf)
3.158         File "/tmp/pip-install-dsdnjyg_/uwsgi_05831e8091e9471fb325b94690dc4a2a/uwsgiconfig.py", line 325, in build_uwsgi
3.158           print("configured CFLAGS: %s" % ' '.join(cflags))
3.158       TypeError: sequence item 14: expected str instance, NoneType found
3.158       [end of output]
3.158   
3.158   note: This error originates from a subprocess, and is likely not a problem with pip.
3.159 error: legacy-install-failure
3.159 
3.159 × Encountered error while trying to install package.
3.159 ╰─> uwsgi
3.159 
3.159 note: This is an issue with the package mentioned above, not pip.
3.159 hint: See above for output from the failure.
3.295 
3.295 [notice] A new release of pip is available: 23.0.1 -> 24.0
3.295 [notice] To update, run: pip install --upgrade pip

It looks like it's failing to parse some CFLAGS in the environment. Am I missing some development packages?

I tried upgrading pip to 24.0 and I get a differently formatted, but identical, error. I also tried 3.10-bullseye, and 3.9-bookworm base images. I get the same error.

I also tried installing uwsgi-plugin-python3 from apt but I am not sure how it relates to the uwsgi Python package. It surely doesn't provide that package.

Any hints?

Thanks. gm


Solution

  • Try this:

    FROM python:3.10-slim-bookworm
    
    RUN apt-get update \
      && apt-get install -y \
        build-essential \
        libpcre2-dev \
      && pip install --no-cache-dir uwsgi
    

    Alternatively, you can downgrade to version 2.0.24 by instead writing: pip install uwsgi==2.0.24.

    Answer derived from this currently open GitHub issue here.