spotify / dh-virtualenv

Python virtualenvs in Debian packages

Home Page:http://dh-virtualenv.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot import name `dist` from `distutils`

Spriithy opened this issue · comments

Hi,

I've been trying to package my Python project recently and have stumbled on a particular problem with dh-virtualenv.

Some package (here, joblib) tries to import some distutils module called dist, however, the submodule could not be found within the virtualenv's distutils distribution.

...
File "/opt/venvs/smith/lib/python3.7/site-packages/smith/cli/commands.py", line 11, in <module>
    import joblib
  File "/opt/venvs/smith/lib/python3.7/site-packages/joblib/__init__.py", line 113, in <module>
    from .memory import Memory, MemorizedResult, register_store_backend
  File "/opt/venvs/smith/lib/python3.7/site-packages/joblib/memory.py", line 33, in <module>
    from ._store_backends import StoreBackendBase, FileSystemStoreBackend
  File "/opt/venvs/smith/lib/python3.7/site-packages/joblib/_store_backends.py", line 15, in <module>
    from .backports import concurrency_safe_rename
  File "/opt/venvs/smith/lib/python3.7/site-packages/joblib/backports.py", line 7, in <module>
    from distutils.version import LooseVersion
  File "/opt/venvs/smith/lib/python3.7/distutils/__init__.py", line 25, in <module>
    from distutils import dist, sysconfig
ImportError: cannot import name 'dist' from 'distutils' (/opt/venvs/smith/lib/python3.7/distutils/__init__.py)

This can be fixed by depending on python3-distutils in the Depends: section of the debian/control file.
However, I don't see any reason why this couldn't work by installing the package directly in the virtualenv ? I have tried adding the distutils package dependency to my setup.py with no luck.

I would really like not to depend on any additional packages that might not be available. This is the case here, where python3-distutils is not available in the debian jessie apt repositories (but is in buster's).

Any idea on how to proceed fixing this issue ?

Thanks in advance !

Use --preinstall.