invl/pip-autoremove

Not remove all unused deps

jonatasrs opened this issue · 1 comments

Not remove all unused dependencies:

$ pip install weasyprint
Collecting weasyprint
  Downloading weasyprint-53.3-py3-none-any.whl (242 kB)
     |████████████████████████████████| 242 kB 3.3 MB/s            
Collecting pydyf>=0.0.3
  Downloading pydyf-0.1.1-py3-none-any.whl (6.3 kB)
Collecting cffi>=0.6
  Downloading cffi-1.15.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (427 kB)
     |████████████████████████████████| 427 kB 45.0 MB/s            
Collecting tinycss2>=1.0.0
  Downloading tinycss2-1.1.0-py3-none-any.whl (21 kB)
Requirement already satisfied: Pillow>=4.0.0 in ./env/lib/python3.7/site-packages (from weasyprint) (8.3.2)
Collecting fonttools[woff]>=4.0.0
  Downloading fonttools-4.27.1-py3-none-any.whl (869 kB)
     |████████████████████████████████| 869 kB 88.7 MB/s            
Collecting cssselect2>=0.1
  Downloading cssselect2-0.4.1-py3-none-any.whl (13 kB)
Collecting html5lib>=1.0.1
  Downloading html5lib-1.1-py2.py3-none-any.whl (112 kB)
     |████████████████████████████████| 112 kB 49.1 MB/s            
Collecting Pyphen>=0.9.1
  Downloading pyphen-0.11.0-py3-none-any.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 46.4 MB/s            
Collecting pycparser
  Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
     |████████████████████████████████| 112 kB 79.7 MB/s            
Collecting webencodings
  Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting zopfli>=0.1.4
  Downloading zopfli-0.1.9-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (113 kB)
     |████████████████████████████████| 113 kB 87.7 MB/s            
Collecting brotli>=1.0.1
  Downloading Brotli-1.0.9-cp37-cp37m-manylinux1_x86_64.whl (357 kB)
     |████████████████████████████████| 357 kB 73.2 MB/s            
Requirement already satisfied: six>=1.9 in ./env/lib/python3.7/site-packages (from html5lib>=1.0.1->weasyprint) (1.15.0)
Installing collected packages: webencodings, zopfli, tinycss2, pycparser, fonttools, brotli, Pyphen, pydyf, html5lib, cssselect2, cffi, weasyprint
Successfully installed Pyphen-0.11.0 brotli-1.0.9 cffi-1.15.0 cssselect2-0.4.1 fonttools-4.27.1 html5lib-1.1 pycparser-2.20 pydyf-0.1.1 tinycss2-1.1.0 weasyprint-53.3 webencodings-0.5.1 zopfli-0.1.9

Using pip-autoremove:

pip-autoremove weasyprint -y
weasyprint 53.3 (env/lib/python3.7/site-packages)
    tinycss2 1.1.0 (env/lib/python3.7/site-packages)
        webencodings 0.5.1 (env/lib/python3.7/site-packages)
    cssselect2 0.4.1 (env/lib/python3.7/site-packages)
    cffi 1.15.0 (env/lib/python3.7/site-packages)
        pycparser 2.20 (env/lib/python3.7/site-packages)
    html5lib 1.1 (env/lib/python3.7/site-packages)
    pyphen 0.11.0 (env/lib/python3.7/site-packages)
    fonttools 4.27.1 (env/lib/python3.7/site-packages)
    pydyf 0.1.1 (env/lib/python3.7/site-packages)
Found existing installation: html5lib 1.1
Uninstalling html5lib-1.1:
  Successfully uninstalled html5lib-1.1
Found existing installation: pycparser 2.20
Uninstalling pycparser-2.20:
  Successfully uninstalled pycparser-2.20
Found existing installation: pydyf 0.1.1
Uninstalling pydyf-0.1.1:
  Successfully uninstalled pydyf-0.1.1
Found existing installation: fonttools 4.27.1
Uninstalling fonttools-4.27.1:
  Successfully uninstalled fonttools-4.27.1
Found existing installation: tinycss2 1.1.0
Uninstalling tinycss2-1.1.0:
  Successfully uninstalled tinycss2-1.1.0
Found existing installation: weasyprint 53.3
Uninstalling weasyprint-53.3:
  Successfully uninstalled weasyprint-53.3
Found existing installation: pyphen 0.11.0
Uninstalling pyphen-0.11.0:
  Successfully uninstalled pyphen-0.11.0
Found existing installation: webencodings 0.5.1
Uninstalling webencodings-0.5.1:
  Successfully uninstalled webencodings-0.5.1
Found existing installation: cffi 1.15.0
Uninstalling cffi-1.15.0:
  Successfully uninstalled cffi-1.15.0
Found existing installation: cssselect2 0.4.1
Uninstalling cssselect2-0.4.1:
  Successfully uninstalled cssselect2-0.4.1

These 2 libs (brotli and zopfli) deps from fonttools not auto uninstalled:

brotli>=1.0.1 in ./env/lib/python3.7/site-packages (from fonttools[woff]>=4.0.0->weasyprint) (1.0.9)
zopfli>=0.1.4 in ./env/lib/python3.7/site-packages (from fonttools[woff]>=4.0.0->weasyprint) (0.1.9)

Versão:

$ pip-autoremove --version
pip-autoremove 0.10.0

I looked into this a while back after seeing a similar issue. Internally, pip-autoremove can't see when something is installed with extras (in this case woff is the extra), it can only see that the base package was installed. This appears to be a limitation of pkg_resources.get_distribution which is what is used to build up the dependency graph.