pum 1.3.2__py3-none-any.whl → 1.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pum/hook.py +24 -10
- pum/pum_config.py +5 -1
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/METADATA +1 -1
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/RECORD +8 -8
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/WHEEL +0 -0
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/entry_points.txt +0 -0
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/licenses/LICENSE +0 -0
- {pum-1.3.2.dist-info → pum-1.3.3.dist-info}/top_level.txt +0 -0
pum/hook.py
CHANGED
|
@@ -111,20 +111,23 @@ class HookHandler:
|
|
|
111
111
|
parent_dir = str(self.file.parent.resolve())
|
|
112
112
|
|
|
113
113
|
# Store paths that need to be added for hook execution
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
# Always add paths even if already in sys.path - we need them at position 0
|
|
115
|
+
# for priority and we'll track what we added for cleanup
|
|
116
|
+
self.sys_path_additions.append(parent_dir)
|
|
117
117
|
|
|
118
118
|
# Also add base_path if provided, to support imports from sibling directories
|
|
119
119
|
if base_path is not None:
|
|
120
120
|
base_path_str = str(base_path.resolve())
|
|
121
|
-
if base_path_str
|
|
121
|
+
if base_path_str != parent_dir:
|
|
122
122
|
self.sys_path_additions.append(base_path_str)
|
|
123
123
|
|
|
124
|
-
#
|
|
124
|
+
# Add paths for module loading - insert at position 0 for priority
|
|
125
125
|
for path in reversed(self.sys_path_additions):
|
|
126
126
|
sys.path.insert(0, path)
|
|
127
127
|
|
|
128
|
+
# Invalidate caches so Python recognizes the new paths
|
|
129
|
+
importlib.invalidate_caches()
|
|
130
|
+
|
|
128
131
|
try:
|
|
129
132
|
logger.debug(f"Loading hook from: {self.file}")
|
|
130
133
|
logger.debug(f"sys.path additions: {self.sys_path_additions}")
|
|
@@ -178,11 +181,22 @@ class HookHandler:
|
|
|
178
181
|
arg for arg in arg_names if arg not in ("self", "connection")
|
|
179
182
|
]
|
|
180
183
|
|
|
181
|
-
|
|
182
|
-
#
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
except Exception:
|
|
185
|
+
# On error, clean up paths we added
|
|
186
|
+
self.cleanup_sys_path()
|
|
187
|
+
raise
|
|
188
|
+
|
|
189
|
+
def cleanup_sys_path(self) -> None:
|
|
190
|
+
"""Remove paths that were added to sys.path for this hook.
|
|
191
|
+
|
|
192
|
+
This should be called when the hook is no longer needed to prevent
|
|
193
|
+
sys.path pollution.
|
|
194
|
+
"""
|
|
195
|
+
for path in self.sys_path_additions:
|
|
196
|
+
# Remove all occurrences of this path (we may have added it multiple times)
|
|
197
|
+
while path in sys.path:
|
|
198
|
+
sys.path.remove(path)
|
|
199
|
+
self.sys_path_additions.clear()
|
|
186
200
|
|
|
187
201
|
def __repr__(self) -> str:
|
|
188
202
|
"""Return a string representation of the Hook instance."""
|
pum/pum_config.py
CHANGED
|
@@ -184,11 +184,15 @@ class PumConfig:
|
|
|
184
184
|
return self._base_path
|
|
185
185
|
|
|
186
186
|
def cleanup_hook_imports(self) -> None:
|
|
187
|
-
"""Clean up imported modules
|
|
187
|
+
"""Clean up imported modules and sys.path entries from hooks.
|
|
188
188
|
|
|
189
189
|
This should be called when switching to a different module version to ensure
|
|
190
190
|
that cached imports from the previous version don't cause conflicts.
|
|
191
191
|
"""
|
|
192
|
+
# First, clean up sys.path additions from all cached handlers
|
|
193
|
+
for handler in self._cached_handlers:
|
|
194
|
+
handler.cleanup_sys_path()
|
|
195
|
+
|
|
192
196
|
# Clear all modules that were loaded from this base_path
|
|
193
197
|
base_path_str = str(self._base_path.resolve())
|
|
194
198
|
modules_to_remove = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.3
|
|
4
4
|
Summary: Pum stands for "Postgres Upgrades Manager". It is a Database migration management tool very similar to flyway-db or Liquibase, based on metadata tables.
|
|
5
5
|
Author-email: Denis Rouzaud <denis@opengis.ch>
|
|
6
6
|
License-Expression: GPL-2.0-or-later
|
|
@@ -8,18 +8,18 @@ pum/dependency_handler.py,sha256=1A6720Tv0rBME-gJVLn9PYK46YPXLMD-r9hpNNX8ApY,696
|
|
|
8
8
|
pum/dumper.py,sha256=FFRidaOg3ENePNZ61TGbnAdp0TItvWbA4j292Xlf9bA,3878
|
|
9
9
|
pum/exceptions.py,sha256=h1TEPHI_hSbLLQc6zYfTpFexczv1iKIN7OuTsLTN590,1439
|
|
10
10
|
pum/feedback.py,sha256=pbZYdhsocjmJbjcdUpvYhI8XLio15htyVg-Cay6HHdE,3810
|
|
11
|
-
pum/hook.py,sha256=
|
|
11
|
+
pum/hook.py,sha256=twhlQtklBHUY2W9PAseTKTMhpsnkl8hNG36I-9oz8iU,12841
|
|
12
12
|
pum/info.py,sha256=75Fr4Bn-ARe36aK8KV31MSCNWDkAdiMgJ-4IvMF73zU,1346
|
|
13
13
|
pum/parameter.py,sha256=e7Lm5fp2Xg4SEkIDmbxSyNTsYvELCkeyPUeS6CCs6EA,2646
|
|
14
|
-
pum/pum_config.py,sha256=
|
|
14
|
+
pum/pum_config.py,sha256=l9PybZURB4ZUbvVC-QeXyLrtawByWt3OiN2CS5BKiwM,15565
|
|
15
15
|
pum/report_generator.py,sha256=upv6gpVZ_kk7O6IhcO7LWMlPHg_u_V0wx_LxQebMp-c,38908
|
|
16
16
|
pum/role_manager.py,sha256=_LG5LR8osc5bVQVb-AKGU3wvXBrIe9J3IV1ECzhiwnA,15991
|
|
17
17
|
pum/schema_migrations.py,sha256=-yR84KkG1mLY5yeEWzidNPam1hrE_1mMC5KJaHOUxiA,16304
|
|
18
18
|
pum/sql_content.py,sha256=BY5XMS713sIOUT4xLHByOzQhxYItucvkCFEyzmwSTR4,12969
|
|
19
19
|
pum/upgrader.py,sha256=skGfwfuAb0TLMqCPjRbcJNf1VKmekaaQLm_C-abs61E,18353
|
|
20
|
-
pum-1.3.
|
|
21
|
-
pum-1.3.
|
|
22
|
-
pum-1.3.
|
|
23
|
-
pum-1.3.
|
|
24
|
-
pum-1.3.
|
|
25
|
-
pum-1.3.
|
|
20
|
+
pum-1.3.3.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
|
|
21
|
+
pum-1.3.3.dist-info/METADATA,sha256=CKhXiAoGzcAz_bHXF-4g1tyd3XHYNyJ0yU7ug5p31CM,3236
|
|
22
|
+
pum-1.3.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
23
|
+
pum-1.3.3.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
|
|
24
|
+
pum-1.3.3.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
|
|
25
|
+
pum-1.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|