-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling from within Python #81
Comments
Yes, pip-licenses is developed as a CLI tool. Does your opinion mean that you want to import pip-licenses as a module and use some of the features in your Python code? |
Yes, that would be great. Currently I get around it by calling it with subprocess and then parsing the json output, but this seems a bit unnecessary, given that pip-licenses is Python code itself. |
I didn't imagine anyone would want to use the scan results in their Python code. I would consider APIs and documentation that users can handle with structured objects. Thank you for your valuable opinion, @fladd . |
This is what I am doing to achieve this: import piplicenses
parser = piplicenses.create_parser()
args = parser.parse_args()
packages = piplicenses.get_packages(args)
for p in packages:
print(p) If you need options, you could provide them in the call to |
This would also be useful to work around the lack of "proper" support for multiply-licensed packages - that is, the fact that multiple licenses are shown in a single string separated by delimiters, rather than as some structured representation (like a JSON list, for the JSON output format). If there were a Python API, perhaps it could expose multiple licenses as a Python list. I don't know how practical this actually is, but it would make a significant difference to my use case. |
I'd like to express my support for this feature request. I'm currently using pip-licenses in a unit test to ensure all dependencies' licenses are compatible. A pip-licenses Python API would allow this code to be rewritten a lot shorter and cleaner. |
I stumbled upon this recently as well when trying to re-use some functionality which is only available as a nested method like |
A pip-licenses Python API would be a great fit for applications bundled with e.g. PyInstaller. Using |
I previously used Due to additional requirements from my side (matching all license files, only querying metadata without files etc.) and the upstream repository receiving corresponding PRs which would never end up in a release, I decided to create my own fork of this tool which has a strict focus on library usage: https://github.com/stefan6419846/pip-licenses-lib |
|
The documentation currently does not explain how to call pip-licenses from within Python, only how to call it from a command line.
The text was updated successfully, but these errors were encountered: