GP-0: Validating Python wheel Module.manifest IP

This commit is contained in:
Ryan Kurtz 2025-01-29 12:58:15 -05:00
parent 3c68902436
commit 0d24ae38aa
3 changed files with 22 additions and 2 deletions

View file

@ -50,7 +50,7 @@ if ("32".equals(System.getProperty("sun.arch.data.model"))) {
* Identify supported Python command
***************************************************************************************/
project.ext.PYTHON3 = findPython3(true)
project.ext.PYTHON_DEPS = new HashSet<String>()
project.ext.PYTHON_DEPS = new HashMap<Project, Set<File>>()
/*********************************************************************************
* Define the location of bin repo

View file

@ -80,8 +80,13 @@ rootProject.assembleDistribution {
}
ext.distributePyDep = { name ->
Set<File> wheelFiles = PYTHON_DEPS.get(project)
if (wheelFiles == null) {
wheelFiles = new HashSet<>()
PYTHON_DEPS.put(project, wheelFiles)
}
File dep = findPyDep(name)
PYTHON_DEPS.add(dep)
wheelFiles.add(dep)
def zipPath = getZipPath(project)
rootProject.assembleDistribution {
into ("${zipPath}/pypkg/dist") {

View file

@ -43,6 +43,9 @@ task ip {
// gets the external libs from gradle and verifies they are accounted for in the Module.manifest file
checkExternalLibsInMap(moduleManifestIpMap, project)
// gets the declared external python wheels and verifies they are accounted for in the Module.manifest file
checkExternalPythonWheelsInMap(moduleManifestIpMap, p)
// adds the ip info from the Module.manifest file to the map generated from scanning the module files.
addModuleManifestIp(ipToFileMap, moduleManifestIpMap)
@ -105,6 +108,18 @@ def checkExternalLibsInMap(Map<String, String> map, Project project) {
}
}
/**********************************************************************************
* Gets the python dependences and makes sure each external wheel is accounted for in
* the map from the Module.manifest file
*********************************************************************************/
def checkExternalPythonWheelsInMap(Map<String, String> map, Project project) {
PYTHON_DEPS.getOrDefault(project, List.of()).each { dep ->
String name = dep.getName() // get just the filename without the path
String relativePath = "pypkg/dist/"+name;
assert map.containsKey(relativePath) : "No License specified for external python wheel: "+relativePath+ " in module "+project.projectDir
}
}
/*********************************************************************************
* Examines all the files in the module, reads their ip from the header, verifies
* that the ip is allowed, and adds an entry to a mapping of the ip to a list of