Skip to content

Commit 269fdc3

Browse files
committed
Remove the changes to python dependency management
1 parent 52650da commit 269fdc3

3 files changed

Lines changed: 22 additions & 89 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- #1057: Fix IPM not cleaning up after itself on self-uninstall
2121
- #1122: Packaging should recognize resources in dependency modules set to deploy
2222
- #1119: The update command should check version requirements using post-update values instead of what's currently installed
23-
- #1097: The Test resource processor now supports nested tests and installing Python dependencies from requirements.txt will correctly override wheels
23+
- #1097: The Test resource processor now supports nested tests
2424

2525
## [0.10.6] - 2026-02-24
2626

src/cls/IPM/Lifecycle/Base.cls

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,6 @@ Method InstallOrDownloadPythonRequirements(
778778
set processType = "requirements.txt"
779779
do ..Log(processType _ " START")
780780
write:tVerbose !
781-
782-
// Clean up existing package installations before pip install
783-
// This is necessary because pip with --python-version doesn't check/uninstall existing packages
784-
do ..CleanupPythonInstallation(pythonRequirements, target, tVerbose)
785-
786781
set command = ..ResolvePipCaller(.pParams) _ $listbuild("install", "-r", "requirements.txt", "-t", target, "--python-version", tPyVersion, "--only-binary=:all:") _ $listfromstring(tExtraPipFlags, " ")
787782
if tVerbose {
788783
write !, "Running "
@@ -925,69 +920,6 @@ ClassMethod DetectPipCaller(
925920
throw ##class(%Exception.General).%New("Could not find a suitable pip caller. Consider setting UseStandalonePip and PipCaller")
926921
}
927922

928-
/// Cleans up the existing Python package installation in the specified target directory based on the given requirements.txt file
929-
ClassMethod CleanupPythonInstallation(
930-
filename As %String,
931-
targetDirectory As %String,
932-
verbose As %Boolean)
933-
{
934-
set file = ##class(%Stream.FileCharacter).%New()
935-
set file.Filename = filename
936-
while 'file.AtEnd {
937-
set line = $zstrip(file.ReadLine(), "<>W")
938-
// Skip comments and empty lines
939-
continue:line=""
940-
continue:$extract(line,1)="#"
941-
942-
// Extract package name (before any version operator)
943-
set packageName = line
944-
for operator = "==", ">=", "<=", "!=", "~=", ">", "<" {
945-
set packageName = $piece(packageName, operator, 1)
946-
}
947-
set packageName = $zstrip(packageName, "<>W")
948-
949-
if packageName '= "" {
950-
// Remove package directory: <target>/<package>/
951-
set packageDir = ##class(%File).NormalizeDirectory(packageName, targetDirectory)
952-
if ##class(%File).DirectoryExists(packageDir) {
953-
set removed = ##class(%File).RemoveDirectoryTree(packageDir)
954-
if verbose && removed {
955-
write !, "Removed old package directory: ", packageDir
956-
}
957-
}
958-
959-
// Remove dist-info directories: <target>/<package>-*.dist-info/
960-
set pattern = targetDirectory _ packageName _ "-*.dist-info"
961-
set distInfo = $zsearch(pattern)
962-
while distInfo '= "" {
963-
if ##class(%File).DirectoryExists(distInfo) {
964-
set removed = ##class(%File).RemoveDirectoryTree(distInfo)
965-
if verbose && removed {
966-
write !, "Removed old dist-info: ", distInfo
967-
}
968-
}
969-
set distInfo = $zsearch("")
970-
}
971-
972-
// Also handle underscore variant: <package>_<name>-*.dist-info/
973-
set packageUnderscore = $replace(packageName, "-", "_")
974-
if packageUnderscore '= packageName {
975-
set pattern = targetDirectory _ packageUnderscore _ "-*.dist-info"
976-
set distInfo = $zsearch(pattern)
977-
while distInfo '= "" {
978-
if ##class(%File).DirectoryExists(distInfo) {
979-
set removed = ##class(%File).RemoveDirectoryTree(distInfo)
980-
if verbose && removed {
981-
write !, "Removed old dist-info: ", distInfo
982-
}
983-
}
984-
set distInfo = $zsearch("")
985-
}
986-
}
987-
}
988-
}
989-
}
990-
991923
Method %Validate(ByRef pParams) As %Status
992924
{
993925
// NOTE: Resource processor classes and their attributes are validated in OnBeforePhase,

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,24 @@ Method TestWheelPresent()
132132
/// requirements.txt takes precedence.
133133
Method TestWheelAndReqsPresentOnline()
134134
{
135-
do ..PurgePythonPackage("lune")
136-
set dir = ..GetModuleDir("python-deps-tests", ..#LuneReqsOnlineLocation)
137-
set sc = ##class(%IPM.Main).Shell("load -v " _ dir)
138-
do $$$AssertStatusOK(sc, "Successfully installed lune-wheel resource")
139-
try {
140-
set httprequest = ##class(%Net.HttpRequest).%New()
141-
set httprequest.Server="www.example.com"
142-
do httprequest.Get("/")
143-
if httprequest.HttpResponse '= "" {
144-
set lunePackage = ##class(%SYS.Python).Import("lune")
145-
do $$$AssertSuccess("Successfully imported lune-wheel resource using requirements.txt")
146-
set reqVer = ..GetPythonVersion("lune")
147-
do $$$AssertEquals(reqVer, "1.6.4")
148-
}
149-
} catch ex {
150-
do $$$AssertFailure("Failed to import lune-wheel resource: "_ex.AsStatus())
151-
}
135+
do $$$AssertSkipped("Skipping until python wheels fix is merged")
136+
#; do ..PurgePythonPackage("lune")
137+
#; set dir = ..GetModuleDir("python-deps-tests", ..#LuneReqsOnlineLocation)
138+
#; set sc = ##class(%IPM.Main).Shell("load -v " _ dir)
139+
#; do $$$AssertStatusOK(sc, "Successfully installed lune-wheel resource")
140+
#; try {
141+
#; set httprequest = ##class(%Net.HttpRequest).%New()
142+
#; set httprequest.Server="www.example.com"
143+
#; do httprequest.Get("/")
144+
#; if httprequest.HttpResponse '= "" {
145+
#; set lunePackage = ##class(%SYS.Python).Import("lune")
146+
#; do $$$AssertSuccess("Successfully imported lune-wheel resource using requirements.txt")
147+
#; set reqVer = ..GetPythonVersion("lune")
148+
#; do $$$AssertEquals(reqVer, "1.6.4")
149+
#; }
150+
#; } catch ex {
151+
#; do $$$AssertFailure("Failed to import lune-wheel resource: "_ex.AsStatus())
152+
#; }
152153
}
153154

154155
/// Testing case where Python wheel and requirements.txt is present. System not connected to Internet.
@@ -341,7 +342,7 @@ Method GetRandomExportPath()
341342
/// Instead of using full file name, checks for a substring. This is because the specific version of dependencies
342343
/// installed along with requirements.txt can change and we don't want the check to fail if it does so.
343344
/// This way can just use the package names and not have to worry about extensions on the file names changing causing failures.
344-
///
345+
///
345346
/// Arguments:
346347
/// - exportTarball: path to the packaged tarball
347348
/// - wheels: Object of <relative path>-<wheel string> pairs array of file names to check for in the unpackaged module
@@ -389,11 +390,11 @@ Method AssertWheelFilesExistInPackagedModule(
389390

390391
/// Given an object of <module name>-<wheel list> pairs,
391392
/// compiles a list of resources for the module and iterates over the wheel list to check if that wheel is a resource of the module
392-
///
393+
///
393394
/// Instead of using resource, checks for a substring. This is because the specific version of dependencies
394395
/// installed along with requirements.txt can change and we don't want the check to fail if it does so.
395396
/// This way can just use the package names and not have to worry about extensions changing causing failures.
396-
///
397+
///
397398
/// Ex: wheels = { "module1": ["ansible","pycparser"], "module2":["jinja2", "lune"] }
398399
Method AssertWheelResourcesExistForModule(wheels As %DynamicObject)
399400
{

0 commit comments

Comments
 (0)