pum 1.1.2__py3-none-any.whl → 1.1.4__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/config_model.py +6 -0
- pum/pum_config.py +27 -14
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/METADATA +1 -1
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/RECORD +8 -8
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/WHEEL +0 -0
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/entry_points.txt +0 -0
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/licenses/LICENSE +0 -0
- {pum-1.1.2.dist-info → pum-1.1.4.dist-info}/top_level.txt +0 -0
pum/config_model.py
CHANGED
|
@@ -26,6 +26,12 @@ class ParameterDefinitionModel(PumCustomBaseModel):
|
|
|
26
26
|
default: Optional[Any] = None
|
|
27
27
|
description: Optional[str] = None
|
|
28
28
|
|
|
29
|
+
@model_validator(mode="before")
|
|
30
|
+
def validate_default(cls, values):
|
|
31
|
+
if values.get("type") == ParameterType.BOOLEAN:
|
|
32
|
+
values["default"] = values.get("default", False) in (1, "1", "true", "TRUE", True)
|
|
33
|
+
return values
|
|
34
|
+
|
|
29
35
|
|
|
30
36
|
class HookModel(PumCustomBaseModel):
|
|
31
37
|
"""
|
pum/pum_config.py
CHANGED
|
@@ -18,7 +18,6 @@ from .config_model import ConfigModel
|
|
|
18
18
|
from .hook import HookHandler
|
|
19
19
|
import tempfile
|
|
20
20
|
import sys
|
|
21
|
-
import atexit
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
try:
|
|
@@ -26,7 +25,7 @@ try:
|
|
|
26
25
|
except importlib.metadata.PackageNotFoundError:
|
|
27
26
|
# Fallback: try to read from pum-*.dist-info/METADATA
|
|
28
27
|
dist_info_dirs = glob.glob(os.path.join(os.path.dirname(__file__), "..", "pum-*.dist-info"))
|
|
29
|
-
|
|
28
|
+
versions = []
|
|
30
29
|
for dist_info in dist_info_dirs:
|
|
31
30
|
metadata_path = os.path.join(dist_info, "METADATA")
|
|
32
31
|
if os.path.isfile(metadata_path):
|
|
@@ -34,11 +33,11 @@ except importlib.metadata.PackageNotFoundError:
|
|
|
34
33
|
for line in f:
|
|
35
34
|
if line.startswith("Version:"):
|
|
36
35
|
version = line.split(":", 1)[1].strip()
|
|
36
|
+
versions.append(version)
|
|
37
37
|
break
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
PUM_VERSION = packaging.version.Version(version)
|
|
38
|
+
if versions:
|
|
39
|
+
# Pick the highest version
|
|
40
|
+
PUM_VERSION = max((packaging.version.Version(v) for v in versions))
|
|
42
41
|
else:
|
|
43
42
|
PUM_VERSION = packaging.version.Version("0.0.0")
|
|
44
43
|
|
|
@@ -138,6 +137,17 @@ class PumConfig:
|
|
|
138
137
|
"""Return the base path used for configuration and changelogs."""
|
|
139
138
|
return self._base_path
|
|
140
139
|
|
|
140
|
+
def parameters(self) -> list[ParameterDefinition]:
|
|
141
|
+
"""Return a list of migration parameters.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
list[ParameterDefinition]: A list of migration parameter definitions.
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
return [
|
|
148
|
+
ParameterDefinition(**parameter.model_dump()) for parameter in self.config.parameters
|
|
149
|
+
]
|
|
150
|
+
|
|
141
151
|
def parameter(self, name: str) -> ParameterDefinition:
|
|
142
152
|
"""Get a specific migration parameter by name.
|
|
143
153
|
|
|
@@ -250,6 +260,15 @@ class PumConfig:
|
|
|
250
260
|
"""Return a dictionary of demo data files defined in the configuration."""
|
|
251
261
|
return {dm.name: dm.file for dm in self.config.demo_data}
|
|
252
262
|
|
|
263
|
+
def __del__(self):
|
|
264
|
+
# Cleanup temporary directories and sys.path modifications
|
|
265
|
+
if self.dependency_path:
|
|
266
|
+
# Remove from sys.path if present
|
|
267
|
+
sys.path = [p for p in sys.path if p != str(self.dependency_path)]
|
|
268
|
+
# Remove the directory if it exists and is a TemporaryDirectory
|
|
269
|
+
if hasattr(self, "_temp_dir") and self._temp_dir:
|
|
270
|
+
self.dependency_tmp.cleanup()
|
|
271
|
+
|
|
253
272
|
def validate(self, install_dependencies: bool = False) -> None:
|
|
254
273
|
"""Validate the changelogs and hooks.
|
|
255
274
|
|
|
@@ -258,16 +277,10 @@ class PumConfig:
|
|
|
258
277
|
"""
|
|
259
278
|
|
|
260
279
|
if install_dependencies and self.config.dependencies:
|
|
261
|
-
|
|
262
|
-
self.dependency_path = Path(
|
|
280
|
+
self.dependency_tmp = tempfile.TemporaryDirectory()
|
|
281
|
+
self.dependency_path = Path(self.dependency_tmp.name)
|
|
263
282
|
sys.path.insert(0, str(self.dependency_path))
|
|
264
283
|
|
|
265
|
-
def cleanup():
|
|
266
|
-
sys.path = [p for p in sys.path if p != str(self.dependency_path)]
|
|
267
|
-
temp_dir.cleanup()
|
|
268
|
-
|
|
269
|
-
atexit.register(cleanup)
|
|
270
|
-
|
|
271
284
|
parameter_defaults = {}
|
|
272
285
|
for parameter in self.config.parameters:
|
|
273
286
|
parameter_defaults[parameter.name] = psycopg.sql.Literal(parameter.default)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
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
|
|
@@ -2,22 +2,22 @@ pum/__init__.py,sha256=P-NHd6_SYpk9aypefLI62QCZ3f5APOMCwSzrFFCKAew,759
|
|
|
2
2
|
pum/changelog.py,sha256=yDc5swmMd5gb2vCEAlenoq5gs-ZEGc4uXicBtiGxkOk,3692
|
|
3
3
|
pum/checker.py,sha256=GT2v7793HP1g94dv0mL6CHtQfblQwAyeFHEWCy44lkc,14379
|
|
4
4
|
pum/cli.py,sha256=nnuApRDXgWaiBZXw2F3iwUxI5nzfIqyMdwhTXS-Jde8,14045
|
|
5
|
-
pum/config_model.py,sha256=
|
|
5
|
+
pum/config_model.py,sha256=piSQBYp29gnzqmtN50_OUw5o9d7Q5dEzj4q6G7cIFik,6396
|
|
6
6
|
pum/dependency_handler.py,sha256=34wvDGWlI-vsMFm1z0XcSDN2cnL_VFAh61GWmeYEzk4,3841
|
|
7
7
|
pum/dumper.py,sha256=EJZ8T44JM0GKgdqw1ENOfhZ-RI89OQ4DNdoTZKtLdEw,3404
|
|
8
8
|
pum/exceptions.py,sha256=xyzzY4ht1nKfrVt59Giulflpmu83nJhxoTygrqiqPlw,1137
|
|
9
9
|
pum/hook.py,sha256=L4Cnr34zrgPzxso9CdsUYWmtuOXRmFccQZ9Lp4IYCBM,9326
|
|
10
10
|
pum/info.py,sha256=VSCUZJJ_ae-khKaudwbgqszZXBMKB_yskuQo5Mc1PgY,1024
|
|
11
11
|
pum/parameter.py,sha256=e9f80kMZpART9laeImW_YECeTvwDyDSmZlTeJGvpS_8,2449
|
|
12
|
-
pum/pum_config.py,sha256=
|
|
12
|
+
pum/pum_config.py,sha256=xTEdYh-628pnkoqH56NoPIuhIQauc1d6hksM8hcCCU4,11232
|
|
13
13
|
pum/role_manager.py,sha256=yr-fmytflGqANY3IZIpgJBoMOK98ynTWfemIBhAy79A,10131
|
|
14
14
|
pum/schema_migrations.py,sha256=FiaqAbhFX7vd3Rk_R43kd7-QWfil-Q5587EU8xSLBkA,10504
|
|
15
15
|
pum/sql_content.py,sha256=gwgvcdXOXxNz3RvLtL8Bqr5WO3KKq3sluhbj4OAEnQs,9756
|
|
16
16
|
pum/upgrader.py,sha256=jvl6vmpgxGyYiw8rrWC_bDC7Zd4wHJqGLXCK8EMt9wY,7109
|
|
17
17
|
pum/conf/pum_config_example.yaml,sha256=_nwV_7z6S_Se-mejh_My0JFLY-A0Q4nigeLGPZAfcqg,424
|
|
18
|
-
pum-1.1.
|
|
19
|
-
pum-1.1.
|
|
20
|
-
pum-1.1.
|
|
21
|
-
pum-1.1.
|
|
22
|
-
pum-1.1.
|
|
23
|
-
pum-1.1.
|
|
18
|
+
pum-1.1.4.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
|
|
19
|
+
pum-1.1.4.dist-info/METADATA,sha256=eZOs5rKpdCVJJR1BSQKeTjMdhneE57kZMrNaTnv-US8,3138
|
|
20
|
+
pum-1.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
pum-1.1.4.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
|
|
22
|
+
pum-1.1.4.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
|
|
23
|
+
pum-1.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|