Skip to content

Commit c74638c

Browse files
James LechtnerJames Lechtner
authored andcommitted
Making sure python dependencies of dependency modules are also exported
1 parent 0febf76 commit c74638c

File tree

8 files changed

+50
-13
lines changed

8 files changed

+50
-13
lines changed

src/cls/IPM/Lifecycle/Base.cls

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,11 +1203,12 @@ Method %Export(
12031203
kill tSingleModuleArray
12041204
merge tSingleModuleArray = tResourceArray(tModuleName)
12051205
do ..ExportSingleModule(.tSingleModuleArray, pTargetDirectory, .pDependencyGraph, .tParams, tVerbose)
1206-
}
12071206

1208-
set exportPythonDependencies = $get(pParams("ExportPythonDependencies"), 0)
1209-
if exportPythonDependencies {
1210-
do ..ExportPythonDependencies(.pParams)
1207+
set exportPythonDependencies = $get(pParams("ExportPythonDependencies"), 0)
1208+
if exportPythonDependencies {
1209+
set pyDepMod = ##class(%IPM.Storage.Module).NameOpen(tModuleName)
1210+
do ..ExportPythonDependencies(pyDepMod, .pParams)
1211+
}
12111212
}
12121213

12131214
// Export the deployed project to the target directory, if it's non-empty
@@ -1244,13 +1245,16 @@ Method %Export(
12441245
}
12451246

12461247
/// Downloads Python wheels for Python dependencies into the /root/wheels directory of the module. Also updates module.xml with the Python Wheel resources.
1247-
Method ExportPythonDependencies(ByRef pParams)
1248+
Method ExportPythonDependencies(
1249+
module As %IPM.Storage.Module,
1250+
ByRef pParams)
12481251
{
1249-
set root = ##class(%File).NormalizeDirectory("", ..Module.Root)
1252+
set root = ##class(%File).NormalizeDirectory("", module.Root)
12501253
$$$ThrowOnError(..InstallOrDownloadPythonRequirements(root, .pParams, 1))
1251-
set wheelsDir = ##class(%File).NormalizeDirectory("wheels", ..Module.Root)
1254+
set wheelsDir = ##class(%File).NormalizeDirectory("wheels", module.Root)
12521255
if '##class(%File).DirectoryExists(wheelsDir) {
1253-
$$$ThrowStatus($$$ERROR($$$GeneralError, "Wheels directory: "_wheelsDir_" not found."))
1256+
write !, "WARNING: No wheels directory for this module: "_wheelsDir_" not found"
1257+
quit
12541258
}
12551259
set stmt = ##class(%SQL.Statement).%New()
12561260
$$$ThrowOnError(stmt.%PrepareClassQuery("%File", "FileSet"))
@@ -1262,7 +1266,7 @@ Method ExportPythonDependencies(ByRef pParams)
12621266
if (type '= "F") || (file = "") {
12631267
continue
12641268
}
1265-
do ##class(%IPM.StudioDocument.Module).AddPythonWheels(..Module.Name, file)
1269+
do ##class(%IPM.StudioDocument.Module).AddPythonWheels(module.Name, file)
12661270
}
12671271
$$$ThrowOnError(sc)
12681272
}

tests/integration_tests/Test/PM/Integration/ProcessPythonWheel.cls

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,16 @@ Method TestPackageWithPythonDeps() As %Status
204204
/// Test publishing with the -export-python-deps flag
205205
Method TestPublishWithPythonDeps() As %Status
206206
{
207-
set moduleName = "publish-with-python-deps"
207+
// First test the case where the module itself has python dependencies
208+
do ..PublishTestHandler("publish-with-python-deps-dep")
208209

210+
// Next test the case where the base module has no ptyhon dependencies but dependency module does
211+
do ..PublishTestHandler("publish-with-python-deps-base")
212+
}
213+
214+
/// Handler method for publish test suite
215+
Method PublishTestHandler(moduleName As %String)
216+
{
209217
// Create a filesystem repository
210218
set dir = ..GetModuleDir("python-deps-tests", ..#PublishWithPythonDepsLocation)
211219
set sc = ##class(%IPM.Main).Shell("repo -fs -name localrepo -path "_dir)
@@ -220,7 +228,7 @@ Method TestPublishWithPythonDeps() As %Status
220228
do $$$AssertStatusOK(sc, "Configured remote repo")
221229

222230
// Publish module to remote repository
223-
set sc = ##class(%IPM.Main).Shell("publish -v "_moduleName_" -r remote -export-python-deps")
231+
set sc = ##class(%IPM.Main).Shell("publish -v "_moduleName_" -r remote -export-python-deps -export-deps 1")
224232
do $$$AssertStatusOK(sc, "Published module "_moduleName_" to remote repository")
225233

226234
// Uninstall module that came from filesystem repository
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Class Base.Class
2+
{
3+
4+
ClassMethod MethodA()
5+
{
6+
write !, "This is ##class(Base.Class).MethodA()"
7+
}
8+
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Export generator="Cache" version="25">
3+
<Document name="publish-with-python-deps-base.ZPM">
4+
<Module>
5+
<Name>publish-with-python-deps-base</Name>
6+
<Version>1.0.0</Version>
7+
<Resource Name="Base.PKG" />
8+
<Dependencies>
9+
<ModuleReference>
10+
<Name>publish-with-python-deps-dep</Name>
11+
<Version>^1.0.0</Version>
12+
</ModuleReference>
13+
</Dependencies>
14+
</Module>
15+
</Document>
16+
</Export>

tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/lune-1.6.2-py3-none-any.whl renamed to tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/dep-module/lune-1.6.2-py3-none-any.whl

File renamed without changes.

tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/module.xml renamed to tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/dep-module/module.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Export generator="IRIS" version="26">
3-
<Document name="publish-with-python-deps.ZPM">
3+
<Document name="publish-with-python-deps-dep.ZPM">
44
<Module>
5-
<Name>publish-with-python-deps</Name>
5+
<Name>publish-with-python-deps-dep</Name>
66
<Version>1.6.2</Version>
77
<Packaging>module</Packaging>
88
<PythonWheel Name="lune-1.6.2-py3-none-any.whl" Directory="." />

tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/requirements.txt renamed to tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/dep-module/requirements.txt

File renamed without changes.

tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/wheels/lune-1.6.4-py3-none-any.whl renamed to tests/integration_tests/Test/PM/Integration/_data/python-deps-tests/publish-with-python-deps/dep-module/wheels/lune-1.6.4-py3-none-any.whl

File renamed without changes.

0 commit comments

Comments
 (0)