raimon49 / pip-licenses

Dump the license list of packages installed with pip.
MIT License
314 stars 45 forks source link

WIP: Support pip --path option of pip #79

Closed ksauzz closed 4 years ago

ksauzz commented 4 years ago

Motivation

pip-licenses collects distributions including site.USER_SITE in python 3.6. I would like to exculde the packages in USER_SITE.

Hmm, I can use PYTHONNOUSERSITE, or python -s as workaround... :thinking:

python 3.7

% pyenv shell 3.7.5 && python --version && python -m site
Python 3.7.5
sys.path = [
    '/home/kazuhiro',
    '/home/kazuhiro/.pyenv/versions/3.7.5/lib/python37.zip',
    '/home/kazuhiro/.pyenv/versions/3.7.5/lib/python3.7',
    '/home/kazuhiro/.pyenv/versions/3.7.5/lib/python3.7/lib-dynload',
    '/home/kazuhiro/.pyenv/versions/3.7.5/lib/python3.7/site-packages',
]
USER_BASE: '/home/kazuhiro/.local' (exists)
USER_SITE: '/home/kazuhiro/.local/lib/python3.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

python 3.6

% pyenv shell 3.6.10 && python --version && python -m site
Python 3.6.10
sys.path = [
    '/home/kazuhiro',
    '/home/kazuhiro/.pyenv/versions/3.6.10/lib/python36.zip',
    '/home/kazuhiro/.pyenv/versions/3.6.10/lib/python3.6',
    '/home/kazuhiro/.pyenv/versions/3.6.10/lib/python3.6/lib-dynload',
    '/home/kazuhiro/.local/lib/python3.6/site-packages',             <------- USER_SITE
    '/home/kazuhiro/.pyenv/versions/3.6.10/lib/python3.6/site-packages',
]
USER_BASE: '/home/kazuhiro/.local' (exists)
USER_SITE: '/home/kazuhiro/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True
ksauzz commented 4 years ago

It looks using --path is not good solution for my issue. It might be better to add --with[out]-userbase.