-
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
Changes from all commits
29dbf80
e8cd84e
ee75aac
8c7b86e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,6 +170,8 @@ class Pip( | |
} | ||
|
||
companion object { | ||
private const val SHORT_STRING_MAX_CHARS = 200 | ||
|
||
private val INSTALL_OPTIONS = arrayOf( | ||
"--no-warn-conflicts", | ||
"--prefer-binary" | ||
|
@@ -436,13 +438,15 @@ class Pip( | |
return declaredLicenses | ||
} | ||
|
||
private fun getLicenseFromLicenseField(value: String?): String? = | ||
value?.let { | ||
// Work-around for projects that declare licenses in classifier-style syntax. | ||
getLicenseFromClassifier(it) ?: it | ||
}?.takeUnless { | ||
it.isBlank() || it == "UNKNOWN" | ||
} | ||
private fun getLicenseFromLicenseField(value: String?): String? { | ||
if (value.isNullOrBlank() || value == "UNKNOWN") return null | ||
|
||
val isShortString = value.length <= SHORT_STRING_MAX_CHARS && "\n" !in value | ||
if (!isShortString) return null | ||
|
||
// Apply a work-around for projects that declare licenses in classifier-syntax in the license field. | ||
return getLicenseFromClassifier(value) ?: value | ||
} | ||
|
||
private fun getLicenseFromClassifier(classifier: String): String? = | ||
// Example license classifier: | ||
|
@@ -643,8 +647,10 @@ class Pip( | |
|
||
val rootNode = jsonMapper.readTree(json) as ArrayNode | ||
|
||
return rootNode.elements().asSequence().mapTo(mutableSetOf()) { | ||
Identifier("PyPI", "", it["name"].textValue(), it["version"].textValue()) | ||
return rootNode.elements().asSequence().mapNotNullTo(mutableSetOf()) { | ||
val name = it["name"].textValue() | ||
val version = it["version"].textValue() | ||
Identifier("PyPI", "", name, version).takeUnless { isPhonyDependency(name, version) } | ||
} | ||
} | ||
|
||
|
@@ -677,7 +683,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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Analyzer succeeds, but declared licenses contain it all:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@mmurto, is the Because above you wrote
and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The part with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Wow, subtle! |
||
map["Classifiers"]?.mapNotNullTo(declaredLicenses) { getLicenseFromClassifier(it) } | ||
|
||
val authors = parseAuthorString(map["Author"]?.singleOrNull()) | ||
|
Uh oh!
There was an error while loading. Please reload this page.