raimon49 / pip-licenses

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

Can I exclude dev dependencies? #124

Closed JohnHardy closed 1 year ago

JohnHardy commented 1 year ago

Hello!

Love this tool!

Is there an easy way to exclude packages in the dev dependencies?

Thanks!

raimon49 commented 1 year ago

@JohnHardy I think that is a very good question. Unfortunately, there is no easy way to exclude dev dependencies with this tool by itself.

Classically, many developers separate requirements.txt and dev-requirements.txt for environment management.

Some developers use the --without dev option in modern package management tools like poetry to build their environments.

JohnHardy commented 1 year ago

We are using PDM (that uses a pyproject.toml file). There is a command I can use to export (excluding the dev deps) pdm export --production --pyproject to the console etc.

Can pip-licenses work by taking input from the pipe or similar? :) Or can I say only include these packages / their direct deps?

raimon49 commented 1 year ago

Can pip-licenses work by taking input from the pipe or similar? :) Or can I say only include these packages / their direct deps?

No, pip-licenses retrieves package information via pip in environments such as venv. So currently it does not work with input from stdin.

JohnHardy commented 1 year ago

Ah ok!

Could you explain to me how it works at the moment? Does it open the requirements.txt file or look through the site packages or something?

raimon49 commented 1 year ago

Currently we are getting the working set of pkg_resources from pip's internal API.

There have been proposals to acquire this in other ways. See also #116

JohnHardy commented 1 year ago

Thanks, appreciate the info and your great project :)

I am using pdm at the moment, and since that seems to store things a bit differently, and because I don't know enough about how pip-licenses or really anything about the python packaging system works, I implemented it here: https://github.com/pdm-project/pdm/pull/1433

Perhaps there is something that you can use? If I get chance, I'll take a look at #116

raimon49 commented 1 year ago

It's great that you as a user of PDM implement subcommands in PDM.

Supporting colorized text seems like quite a challenge.

raimon49 commented 1 year ago

The scope of this issue moved to adding functionality to the pdm-project.

JohnHardy commented 1 year ago

Thanks! I'll still try to get these features into pip-licenses too, since we have projects outside the pdm world.