Skip to content

Commit

Permalink
license: comment out licenses field if we were unable to determine th…
Browse files Browse the repository at this point in the history
…e correct license
  • Loading branch information
makefu committed Apr 14, 2020
1 parent 4518c71 commit 70c7b9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nixpkgs_pytools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ def format_license(license):
name.lower(): nix_attr
for name, nix_attr in case_sensitive_license_nix_map.items()
}
return license_nix_map.get(license.lower(), license)
return license_nix_map.get(license.lower())
9 changes: 7 additions & 2 deletions nixpkgs_pytools/python_package_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def package_json_to_metadata(package_json, package_name, package_version):
"no source distribution (sdist) found for {package_name}:{package_version}".format(package_name=package_name, package_version=package_version)
)

try:
lic = format_license(package_json["info"]["license"])
except:
lic = None
metadata = {
"pname": format_normalized_package_name(package_json["info"]["name"]),
"downloadname": package_json["info"]["name"],
Expand All @@ -116,7 +120,8 @@ def package_json_to_metadata(package_json, package_name, package_version):
"description": format_description(package_json["info"]["summary"]),
"homepage": format_homepage(package_json["info"]["home_page"]),
"maintainer": getuser(),
"license": format_license(package_json["info"]["license"]),
"resolved_license": lic,
"license": package_json["info"]["license"],
}

metadata.update(determine_package_dependencies(package_json, metadata["url"]))
Expand Down Expand Up @@ -192,7 +197,7 @@ def metadata_to_nix(metadata):
meta = with lib; {
description = "{{ metadata.description }}";
homepage = "{{ metadata.homepage }}";
license = licenses.{{ metadata.license }};
{% if metadata.resolved_license %} license = licenses.{{ metadata.resolved_license }};{% else %} # license = licenses."{{ metadata.license }}"; # unable to map license to nix license format{% endif %}
# maintainers = [ maintainers.{{ metadata.maintainer }} ];
};
}
Expand Down

0 comments on commit 70c7b9d

Please sign in to comment.