0

I've got a small Dockerfile where I'm trying to get to a point where I can RUN pip3 bdist_wheel successfully. That is, without getting this error:

unknown command "bdist_wheel" - maybe you meant "wheel"

I've tried installing everything mentioned in this answer, but no luck.

Minimal repro Dockerfile and docker build output:

FROM ubuntu:18.04

RUN apt-get update \
    && apt-get install -qyy -o APT::Install-Recommends=false -o APT::Install-Suggests=false \
    file \
    gcc \
    python3 \
    python3-dev \
    python3-pip \
    python3-setuptools \
    python3-venv \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN pip3 install --cache-dir=/tmp/pipcache --upgrade pip && rm -rf /tmp/pipcache
RUN pip install --cache-dir=/tmp/pipcache poetry && rm -rf /tmp/pipcache

WORKDIR /src/app
RUN poetry new .
RUN poetry add gevent

The most relevant part of the output is of course

error: invalid command 'bdist_wheel'

l0b0
  • 55,365
  • 30
  • 138
  • 223
  • @phd Nope, I've tried `apt-get install python3-wheel`, `pip install wheel`, `pip install --upgrade wheel` and probably some other variations. – l0b0 Jun 09 '20 at 21:44
  • I tried that too. For now I'm capitulating and upgrading to Ubuntu 20.04 to get away from this horrible situation. – l0b0 Jun 09 '20 at 22:28
  • 1
    There's no `pip bdist_wheel` command. Either `pip wheel`, or `python setup.py bdist_wheel` from inside the repo. – hoefling Jun 09 '20 at 23:57
  • @hoefling Tell that to the gevent maintainers. I'm just trying to install the latest gevent package. – l0b0 Jun 09 '20 at 23:58
  • 1
    Can you point to exact spot featuring this "command"? Is it a Dockerfile in gevent repo? – hoefling Jun 09 '20 at 23:59
  • 1
    I see, it's a Dockerfile you've got - it's clearly wrong, there's nothing wrong with `gevent`. Post the minimal Dockerfile reproducing the error. – hoefling Jun 10 '20 at 00:06
  • @hoefling Here you go, minimal Dockerfile + output. – l0b0 Jun 10 '20 at 00:53

1 Answers1

3

First, some notes to the error: invalid command 'bdist_wheel' output. When running pip install <pkgname>, pip will try to find a prebuilt wheel that matches your target platform. If it doesn't find one, it tries to build a wheel itself -- the source dist is downloaded and pip wheel is run to produce the wheel. On success, the built wheel is installed. On any failure (the wheel package not installed, python setup.py bdist_wheel failed or whatever), pip will fallback to the second option, which is the distutils installation method: running python setup.py install over the unpacked source dist. This is what you can observe in the log you posted:

Failed building wheel for gevent
...
Running setup.py install for gevent: started

Only when the setup.py install also fails, the installation is failed unconditionally. So while pip can't indeed build the wheel b/c the wheel package is not installed, it is not an issue for the failing installation. You can fix this by adding wheel to development packages:

RUN poetry add --dev wheel
RUN poetry add gevent

but this is an optional thing and won't affect the build result.

Now, to the real error:

Running '(cd  "/tmp/pip-build-ek9pxyw2/gevent/deps/libev"  && sh ./configure -C > configure-output.txt )' in /tmp/pip-build-ek9pxyw2/gevent
    config.status: error: in `/tmp/pip-build-ek9pxyw2/gevent/deps/libev':
    config.status: error: Something went wrong bootstrapping makefile fragments
        for automatic dependency tracking.  Try re-running configure with the
        '--disable-dependency-tracking' option to at least be able to build
        the package (albeit without support for automatic dependency tracking).
    See `config.log' for more details

Something went wrong bootstrapping makefile fragments usually means that you're missing make. Install it in addition to the rest:

RUN apt install -y make

After doing that and rerunning the build, I've got the last error

error: src/gevent/libev/corecext.c: No such file or directory

This is because gevent needs Cython for generating the C extension sources. Install it before installing gevent:

RUN poetry add --dev cython
RUN poetry add gevent

The complete Dockerfile for reference, changes in bold:

FROM ubuntu:18.04

RUN apt-get update \
    && apt-get install -qyy -o APT::Install-Recommends=false -o APT::Install-Suggests=false \
    file \
    gcc \
    python3 \
    python3-dev \
    python3-pip \
    python3-setuptools \
    python3-venv \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN pip3 install --cache-dir=/tmp/pipcache --upgrade pip && rm -rf /tmp/pipcache
RUN pip install --cache-dir=/tmp/pipcache poetry && rm -rf /tmp/pipcache

WORKDIR /src/app
RUN poetry new .


RUN apt update
RUN apt install -y make
RUN poetry add --dev wheel cython


RUN poetry add gevent

Neither wheel nor cython are required to actually run gevent, so they can be safely uninstalled afterwards to reduce the image size.

hoefling
  • 59,418
  • 12
  • 147
  • 194