Wheel builds, but fails to install complaining about unexpected file in .data

For various reasons, I’m trying to build python-apt 1.8.4.x against CPython 3.9.1 (built from source, no patches). I’m doing this because I’m using Python 3.9.1 on Debian Buster systems, which have apt 1.x and not apt 2.x, so I can’t build the more recent versions of python-apt (they build fine).

When I run ‘pip install .’ using the latest versions of pip/wheel/etc., the wheel gets built, but then during installation the process stops with this message:

(ansible) root@git20:~/python-apt# pip install .
Processing /root/python-apt
Building wheels for collected packages: python-apt
  Building wheel for python-apt (setup.py) ... done
  Created wheel for python-apt: filename=python_apt-1.8.4.9-cp39-cp39-linux_x86_64.whl size=1890745 sha256=fc9fd3e73bf003c10b2d5f76c181e3881a08e441eb6aeb51466dce64a47fe0bc
  Stored in directory: /root/.cache/pip/wheels/1e/bd/d1/2a3e340a78d2cee74643902ccfc6bf3765428bab95bcbb7e93
Successfully built python-apt
Installing collected packages: python-apt
  Attempting uninstall: python-apt
    Found existing installation: python-apt 1.8.4.2
    Uninstalling python-apt-1.8.4.2:
      Successfully uninstalled python-apt-1.8.4.2
  Rolling back uninstall of python-apt
  Moving to /opt/ansible/lib/python3.9/site-packages/apt/
   from /opt/ansible/lib/python3.9/site-packages/~pt
  Moving to /opt/ansible/lib/python3.9/site-packages/apt_inst.cpython-39-x86_64-linux-gnu.so
   from /tmp/pip-uninstall-r37h7b8x/apt_inst.cpython-39-x86_64-linux-gnu.so
  Moving to /opt/ansible/lib/python3.9/site-packages/apt_pkg.cpython-39-x86_64-linux-gnu.so
   from /tmp/pip-uninstall-r37h7b8x/apt_pkg.cpython-39-x86_64-linux-gnu.so
  Moving to /opt/ansible/lib/python3.9/site-packages/aptsources/
   from /opt/ansible/lib/python3.9/site-packages/~ptsources
  Moving to /opt/ansible/lib/python3.9/site-packages/python_apt-1.8.4.2.dist-info/
   from /opt/ansible/lib/python3.9/site-packages/~ython_apt-1.8.4.2.dist-info
ERROR: For req: python-apt==1.8.4.9. Unexpected file in /root/.cache/pip/wheels/1e/bd/d1/2a3e340a78d2cee74643902ccfc6bf3765428bab95bcbb7e93/python_apt-1.8.4.9-cp39-cp39-linux_x86_64.whl: 'python_apt-1.8.4.9.data/purelib'. .data directory contents should be named like: '<scheme key>/<path>'.

I suppose there’s something about this package’s structure (or setup.py contents) which are not compatible with ‘modern’ versions of the packaging tools, and for Debian this doesn’t matter because this branch will only ever be packaged for Debian Buster which has older versions of all of the tools (and Python 3.7).

Any packaging gurus that could give me a hint as to what I could change to make this work?

See point 3. There shouldn’t be files in .data, only folders. Which backend is it using? It is not generating a valid wheel. You should open a bug report against it.

This package is never distributed as a wheel (or even an sdist for that matter), it’s only ever distributed as a Debian/Ubuntu/etc. package, so I’m not surprised it doesn’t produce a valid wheel.

Looks like this section is the cause, and it’s just installing type hints which I don’t need anyway.

class InstallTypeinfo(install):
    def run(self):
        install.run(self)
        for pyi in glob.glob("typehinting/*.pyi"):
            shutil.copy(pyi, self.install_purelib)

Removing the for-loop produces a wheel which installs properly.

1 Like