raimon49 / pip-licenses

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

Output does not always end in newline #172

Closed dries007 closed 10 months ago

dries007 commented 11 months ago

I've noticed that the output of this tool doesn't always end in a newline.

This has various annoying side effects, such as leaving the shell prompt behind the error message, causing extra diff lines in case the output files are added to git, but also the last line not showing up in some tools that parse newline delimited lines.

Examples:

user@host:/project$ hatch run pip-licenses --allow-only "GPL"
license Apache Software License not in allow-only licenses was found for package trove-classifiers:2023.8.7user@host:/project$ 
user@host:/project$ hatch run pip-licenses --format=markdown --output-file=licenses.md
created path: licenses.md
user@host:/project$ cat licenses.md 
| Name               | Version   | License                              |
|--------------------|-----------|--------------------------------------|
...
| zipp               | 3.16.2    | MIT License                          |user@host:/project$ 

This is generally considered bad behaviour and while it's not as big of an issue as it once was, I'd still like to see it fixed :).

raimon49 commented 10 months ago

@dries007 Thanks for the very detailed report. Your suggestion is reasonable.

Both cases appear to require ad-hoc solutions. I think we can provide a message modification when not found by --allow-only prior to the output file.

raimon49 commented 10 months ago

pip-licenses 4.3.3 has been released. https://pypi.org/project/pip-licenses/4.3.3/

It would be great if you could check the behavior in your environment and report back to us.

$ pip install -U "pip-licenses==4.3.3" 
dries007 commented 10 months ago

Looks good, thanks :smile: