Skip to content

Commit

Permalink
fix(python): Support ZIP archives for source artifacts
Browse files Browse the repository at this point in the history
See e.g. [1] which has `wget-3.2.zip`.

[1]: https://pypi.org/project/wget/#files

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed May 3, 2024
1 parent 1f689aa commit a23237b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ internal fun List<PythonInspector.Package>.toOrtPackages(): Set<Package> =
@Suppress("UseOrEmpty")
fun PythonInspector.Package.getHash(): Hash = Hash.create(sha512 ?: sha256 ?: sha1 ?: md5 ?: "")

fun getArtifact(fileExtension: String) =
packages.find { it.downloadUrl.endsWith(fileExtension) }?.let {
fun getArtifact(vararg fileExtensions: String) =
packages.find { pkg -> fileExtensions.any { pkg.downloadUrl.endsWith(it) } }?.let {
RemoteArtifact(
url = it.downloadUrl,
hash = it.getHash()
Expand All @@ -151,7 +151,7 @@ internal fun List<PythonInspector.Package>.toOrtPackages(): Set<Package> =
description = pkg.description.lineSequence().firstOrNull { it.isNotBlank() }.orEmpty(),
homepageUrl = pkg.homepageUrl.orEmpty(),
binaryArtifact = getArtifact(".whl"),
sourceArtifact = getArtifact(".tar.gz"),
sourceArtifact = getArtifact(".tar.gz", ".zip"),

Check warning on line 154 in plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt

View check run for this annotation

Codecov / codecov/patch

plugins/package-managers/python/src/main/kotlin/utils/PythonInspectorExtensions.kt#L154

Added line #L154 was not covered by tests
vcs = VcsInfo.EMPTY.copy(url = pkg.vcsUrl.orEmpty()),
vcsProcessed = PackageManager.processPackageVcs(
VcsInfo(VcsType.UNKNOWN, pkg.vcsUrl.orEmpty(), revision = ""),
Expand Down

0 comments on commit a23237b

Please sign in to comment.