migrable 0.2.0__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.
migrable/__init__.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tarfile
|
|
7
|
+
import urllib.request
|
|
8
|
+
import zipfile
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
VERSION = "0.2.0"
|
|
12
|
+
_BIN_DIR = os.path.join(os.path.dirname(__file__), "_bin")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
bin_path = _ensure_binary()
|
|
17
|
+
result = subprocess.run([bin_path] + sys.argv[1:])
|
|
18
|
+
sys.exit(result.returncode)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _ensure_binary():
|
|
22
|
+
"""Download the binary on first run if not present."""
|
|
23
|
+
name = "migrable.exe" if platform.system() == "Windows" else "migrable"
|
|
24
|
+
bin_path = os.path.join(_BIN_DIR, name)
|
|
25
|
+
if os.path.exists(bin_path):
|
|
26
|
+
return bin_path
|
|
27
|
+
|
|
28
|
+
os.makedirs(_BIN_DIR, exist_ok=True)
|
|
29
|
+
|
|
30
|
+
os_name = _detect_os()
|
|
31
|
+
arch = _detect_arch()
|
|
32
|
+
ext = "zip" if os_name == "windows" else "tar.gz"
|
|
33
|
+
|
|
34
|
+
url = (
|
|
35
|
+
f"https://github.com/smm-h/migrable/releases/download/v{VERSION}/"
|
|
36
|
+
f"migrable_{VERSION}_{os_name}_{arch}.{ext}"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
print(f"Downloading migrable v{VERSION} for {os_name}/{arch}...", file=sys.stderr)
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
response = urllib.request.urlopen(url)
|
|
43
|
+
data = response.read()
|
|
44
|
+
except Exception as e:
|
|
45
|
+
print(f"Failed to download migrable: {e}", file=sys.stderr)
|
|
46
|
+
sys.exit(1)
|
|
47
|
+
|
|
48
|
+
if ext == "tar.gz":
|
|
49
|
+
with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as tar:
|
|
50
|
+
for member in tar.getmembers():
|
|
51
|
+
if member.name == "migrable" or member.name.endswith("/migrable"):
|
|
52
|
+
member.name = name
|
|
53
|
+
tar.extract(member, _BIN_DIR)
|
|
54
|
+
break
|
|
55
|
+
else:
|
|
56
|
+
with zipfile.ZipFile(io.BytesIO(data)) as zf:
|
|
57
|
+
for zi in zf.infolist():
|
|
58
|
+
if zi.filename == "migrable.exe" or zi.filename.endswith(
|
|
59
|
+
"/migrable.exe"
|
|
60
|
+
):
|
|
61
|
+
zi_data = zf.read(zi)
|
|
62
|
+
with open(bin_path, "wb") as f:
|
|
63
|
+
f.write(zi_data)
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
if platform.system() != "Windows":
|
|
67
|
+
os.chmod(bin_path, 0o755)
|
|
68
|
+
|
|
69
|
+
return bin_path
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _detect_os():
|
|
73
|
+
s = platform.system().lower()
|
|
74
|
+
if s == "linux":
|
|
75
|
+
return "linux"
|
|
76
|
+
if s == "darwin":
|
|
77
|
+
return "darwin"
|
|
78
|
+
if s == "windows":
|
|
79
|
+
return "windows"
|
|
80
|
+
raise RuntimeError(f"Unsupported OS: {s}")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _detect_arch():
|
|
84
|
+
m = platform.machine().lower()
|
|
85
|
+
if m in ("x86_64", "amd64"):
|
|
86
|
+
return "amd64"
|
|
87
|
+
if m in ("arm64", "aarch64"):
|
|
88
|
+
return "arm64"
|
|
89
|
+
raise RuntimeError(f"Unsupported architecture: {m}")
|
migrable/__main__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: migrable
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Declarative config file migrations for TOML
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/smm-h/migrable
|
|
7
|
+
Project-URL: Repository, https://github.com/smm-h/migrable
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# migrable
|
|
12
|
+
|
|
13
|
+
Declarative config file migrations for TOML.
|
|
14
|
+
|
|
15
|
+
This is a thin wrapper that downloads the migrable binary for your platform.
|
|
16
|
+
|
|
17
|
+
See https://github.com/smm-h/migrable for full documentation.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
migrable/__init__.py,sha256=6a2gE2a7cjWzk8dJLMT4QOTMFlkn7CXYrKaN0LBpIA8,2469
|
|
2
|
+
migrable/__main__.py,sha256=-XwMWTEY8mpRv6Fg9LZAGj0bVxbeF5TsYW7oDvZNy1U,34
|
|
3
|
+
migrable-0.2.0.dist-info/METADATA,sha256=X7fHQna-2xykgY-IEg2rgV4WHMnoR-vUeiXwpfbfTC8,507
|
|
4
|
+
migrable-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
migrable-0.2.0.dist-info/entry_points.txt,sha256=Cwy2Oxc3PhikYk1x4ySaqODleqFlLSE4yAR4uIroIw8,43
|
|
6
|
+
migrable-0.2.0.dist-info/top_level.txt,sha256=_6VY2DAAeoxArhpUIek6-tp95ggK8L83vRSITtC4BaE,9
|
|
7
|
+
migrable-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
migrable
|