raimon49 / pip-licenses

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

Non-deterministic order of multiple licenses using pip-licenses 3.5.0 #104

Closed jklaise closed 3 years ago

jklaise commented 3 years ago

E.g. in a project only having tqdm after running pip-licenses --from=mixed --format=csv multiple times I get either of the two outputs:

"tqdm","4.61.1","Mozilla Public License 2.0 (MPL 2.0); MIT License"
"tqdm","4.61.1","MIT License; Mozilla Public License 2.0 (MPL 2.0)"

I believe this could be due to the change in #102 using set operations which are not guaranteed to have deterministic outputs.

This impacts the way we use pip-licenses on CI where we check if there are any differences between the current set of licenses and the latest licenses, the check will fail now due to the random order multi-licenses are returned.

raimon49 commented 3 years ago

@jklaise Thanks for the report. I had overlooked that behavior.

It looks like you can use sorted() to fix the order of multiple licenses when concatenating them. I will work on shipping version 3.5.1 which resolves this issue.

raimon49 commented 3 years ago

@jklaise This issue was fixed in 3.5.1. https://pypi.org/project/pip-licenses/3.5.1/

Thanks to you, I also noticed another option issue in 3.5.0.