-
Notifications
You must be signed in to change notification settings - Fork 339
Pip filter phony packages #4184
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
Conversation
FYI @mmurto. |
I'll test this asap! |
@@ -679,7 +679,7 @@ class Pip( | |||
} | |||
|
|||
val declaredLicenses = sortedSetOf<String>() | |||
getLicenseFromLicenseField(map["License"]?.single())?.let { declaredLicenses += it } | |||
map["License"]?.mapNotNullTo(declaredLicenses) { getLicenseFromLicenseField(it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit: Do you have a reference to the case (package) where this problem appeared?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. According to @mmurto's report in the chat it should be one of dill Django psycopg2 pymongo python-dateutil pytz PyYAML sqlparse
(unclear in which version), but I cannot spend the time to find out exactly now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering whether the issue could be a bug in lines 660 - 678. Maybe we just wait for @mmurto 's test results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we should not fail hard but only warn if the "License" contains multiple fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analyzer succeeds, but declared licenses contain it all:
declared_licenses:
- "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"
- <redacted>
- "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\
\ THE"
- "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"
- "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
\ FROM,"
- "MIT License"
- "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
\ IN"
- "Permission is hereby granted, free of charge, to any person obtaining a\
\ copy"
- "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\
\ OR"
- "THE SOFTWARE."
- "The MIT License"
- "The above copyright notice and this permission notice shall be included\
\ in"
- "all copies or substantial portions of the Software."
- "copies of the Software, and to permit persons to whom the Software is"
- "furnished to do so, subject to the following conditions:"
- "in the Software without restriction, including without limitation the rights"
- "of this software and associated documentation files (the \"Software\"),\
\ to deal"
- "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"
declared_licenses_processed:
spdx_expression: "MIT"
mapped:
MIT License: "MIT"
The MIT License: "MIT"
unmapped:
- "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"
- <redacted>
- "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\
\ THE"
- "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"
- "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
\ FROM,"
- "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
\ IN"
- "Permission is hereby granted, free of charge, to any person obtaining\
\ a copy"
- "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\
\ OR"
- "THE SOFTWARE."
- "The above copyright notice and this permission notice shall be included\
\ in"
- "all copies or substantial portions of the Software."
- "copies of the Software, and to permit persons to whom the Software is"
- "furnished to do so, subject to the following conditions:"
- "in the Software without restriction, including without limitation the\
\ rights"
- "of this software and associated documentation files (the \"Software\"\
), to deal"
- "to use, copy, modify, merge, publish, distribute, sublicense, and/or\
\ sell"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The analyzer run succeeded with the following result:
- id: "PIP::<redacted>:5743024ffd8a42b806a13060104d861146d4e5ba" definition_file_path: "<redacted>/requirements.txt" authors: - "<redacted>" declared_licenses: - "\nThe MIT License \nCopyright (c) 2021- <redacted>\
@mmurto, is the "<redacted>/requirements.txt"
part in here really correct? Shouldn't it be "<redacted>/setup.py"
?
Because above you wrote
the packages has the whole license text of MIT in setup.py
and requirements.txt
does not actually support declaring a license AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The analyzer run succeeded with the following result:
- id: "PIP::<redacted>:5743024ffd8a42b806a13060104d861146d4e5ba" definition_file_path: "<redacted>/requirements.txt" authors: - "<redacted>" declared_licenses: - "\nThe MIT License \nCopyright (c) 2021- <redacted>\
@mmurto, is the
"<redacted>/requirements.txt"
part in here really correct? Shouldn't it be"<redacted>/setup.py"
?Because above you wrote
the packages has the whole license text of MIT in setup.py
and
requirements.txt
does not actually support declaring a license AFAIK.
The part with requirements.txt
is correct, the project's requirements.txt
contains only .
, which leads to pip getting the dependencies from setup.py
, some info here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The part with
requirements.txt
is correct, the project'srequirements.txt
contains only.
, which leads to pip getting the dependencies fromsetup.py
, some info here.
Wow, subtle!
So far phony packages have only been filtered out from the dependency tree, but they should also be removed from the list of installed packages. Signed-off-by: Sebastian Schuberth <[email protected]>
There was a case reported where the "single()" failed due to multiple licenses. While that might have been an issue with "pip", simply support that case as it is easy to do so, like we already do it for the classifiers one line below. Signed-off-by: Sebastian Schuberth <[email protected]>
There are projects which put the full license text instead of just the license name into a license field. Omit such texts from the list of declared licenses by only accepting licenses that do not contain a newline character. Signed-off-by: Sebastian Schuberth <[email protected]>
996479a
to
ee75aac
Compare
The field is specified to be a "short string" which is "a single line of text, not more than 200 characters" [1]. Respect that limit, which also filters out cases where people add full license texts to the field. [1] https://docs.python.org/3/distutils/setupscript.html#additional-meta-data Signed-off-by: Sebastian Schuberth <[email protected]>
8940a6f
to
8c7b86e
Compare
Superseded by #5319. |
Please have a look at the individual commit messages for the details.