Skip to content

Aligning spk-convert-pip with current SPI changes #1168

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions packages/spk-convert-pip/spk-convert-pip
Original file line number Diff line number Diff line change
Expand Up @@ -291,23 +291,11 @@ class PipImporter:
assert not info.requires_external, "No support for external requirements"
assert not info.supported_platforms, "No support for supported platforms field"

# The spk default is "Unlicensed", which seems odd
package_license = "Unknown"
if hasattr(info, "license"):
if info.license is not None:
package_license = str(info.license)
if len(package_license) > LICENSE_FIELD_TRUNCATION_POINT:
package_license = (
package_license[:LICENSE_FIELD_TRUNCATION_POINT]
+ TRUNCATED_VALUE_INDICATOR
)

spec = {
"pkg": f"{_to_spk_name(info.name)}/{_to_spk_version(info.version)}",
"api": "v0/package",
"sources": [],
"meta": {
"license": package_license,
Copy link
Collaborator

@rydrman rydrman Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still put this in the metadata, but you should be able to disable the license check - maybe this needs to be split out first to make this possible.

Aka split SpdxLicense rule into two (has license vs is spdx) and then make the semantics such that both can be disabled in these cases so that the actual included license is never checked.

build:
  validation:
    - rules: 
        - allow: SpdxLicense
        - allow: HasLicense

"labels": {
SPK_GENERATED_BY_LABEL: SPK_GENERATED_BY_VALUE,
"spk-convert-pip:cli": self._cli_args,
Expand All @@ -327,6 +315,16 @@ class PipImporter:
},
}

# TODO: if info.license exists, add it into meta.license but
# need a way to disable the SpdxLicense validation.
if hasattr(info, "license"):
package_license = str(info.license)
if len(package_license) > LICENSE_FIELD_TRUNCATION_POINT:
package_license = (
package_license[:LICENSE_FIELD_TRUNCATION_POINT]
+ TRUNCATED_VALUE_INDICATOR
)

if info.name == "pip":
spec["build"]["validation"] = {"rules": [{"allow": "RecursiveBuild"}]}

Expand Down
2 changes: 1 addition & 1 deletion packages/spk-convert-pip/spk-convert-pip.spk.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pkg: spk-convert-pip/1.4.2
pkg: spk-convert-pip/1.4.4
api: v0/package
build:
script:
Expand Down
Loading