From 0d24ae38aabb7f20d5344c537b6a9b1e7d7e1c6d Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Wed, 29 Jan 2025 12:58:15 -0500 Subject: [PATCH] GP-0: Validating Python wheel Module.manifest IP --- build.gradle | 2 +- gradle/hasPythonPackage.gradle | 7 ++++++- gradle/support/ip.gradle | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 65d028f0c4..2d75307a08 100644 --- a/build.gradle +++ b/build.gradle @@ -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() +project.ext.PYTHON_DEPS = new HashMap>() /********************************************************************************* * Define the location of bin repo diff --git a/gradle/hasPythonPackage.gradle b/gradle/hasPythonPackage.gradle index b88c8bb85a..9e09c4818b 100644 --- a/gradle/hasPythonPackage.gradle +++ b/gradle/hasPythonPackage.gradle @@ -80,8 +80,13 @@ rootProject.assembleDistribution { } ext.distributePyDep = { name -> + Set 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") { diff --git a/gradle/support/ip.gradle b/gradle/support/ip.gradle index b7639bf87b..f753473419 100644 --- a/gradle/support/ip.gradle +++ b/gradle/support/ip.gradle @@ -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 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 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