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

Allow providing some python modules as system packages

eudoxos opened this issue · comments

I am packaging a small project which creates several MB worth of .deb because twisted and others are pulled in as dependencies.

I added "big" packages to debian/control as Depends (python3-numpy, python3-pandas, python3-twisted) and removed them from requirements.txt but still, one required module pulls in twisted anyway.

If added --use-system-packages to DH_VENV_ARGS (so that system-installed modules are found on the target machine) and --extra-pip-args --ignore-installed so that modules installed on the builder are included. The --ignore-installed, however, ignores not only pip-installed packaged but also system-installed Debian packages — so they get installed by pip anyway.

As I gathered from numerous discussions, there is no pip option to ignore a dependency (such as --extra-pip-args "--exclude=twisted") but perhaps dh-virtualenv could take an option to pip uninstall a list of modules after they were installed in the virtual environment?

I tried to work it around by adding this to override_dh_virtualenv, after the venv has been installed:

    export VIRTUAL_ENV=debian/ahmt-webdtj/opt/venvs/ahmt-webdtj; \
    export PATH=$$VIRTUAL_ENV/bin:$$PATH; \
    pip install pip-autoremove; \
    pip-autoremove -y twisted

but it does not run in the venv (even though the correct pip executable is invoked) for some reason.

Start by calling the venv interpreter with a full path and -m pip -- direct pip calls in automation are always prone to lookup errors.