backfill-cli 0.3.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.
@@ -0,0 +1,88 @@
1
+ import os
2
+ import platform
3
+ import shutil
4
+ import sys
5
+ import tarfile
6
+ import tempfile
7
+ import urllib.error
8
+ import urllib.request
9
+ from pathlib import Path
10
+
11
+
12
+ def _fail(message):
13
+ print(message, file=sys.stderr)
14
+ raise SystemExit(1)
15
+
16
+
17
+ def _target():
18
+ if sys.platform == "darwin":
19
+ os_name = "darwin"
20
+ elif sys.platform.startswith("linux"):
21
+ os_name = "linux"
22
+ else:
23
+ _fail(f"backfill does not support {sys.platform} yet")
24
+
25
+ machine = platform.machine().lower()
26
+ if machine in ("x86_64", "amd64"):
27
+ arch = "amd64"
28
+ elif machine in ("arm64", "aarch64"):
29
+ arch = "arm64"
30
+ else:
31
+ _fail(f"backfill does not support architecture {machine} yet")
32
+
33
+ return os_name, arch
34
+
35
+
36
+ def _download(binary):
37
+ os_name, arch = _target()
38
+ url = f"https://github.com/shyamsivakumar/backfill/releases/latest/download/backfill_{os_name}_{arch}.tar.gz"
39
+ binary.parent.mkdir(parents=True, exist_ok=True)
40
+
41
+ tmp_name = None
42
+ try:
43
+ with urllib.request.urlopen(url) as response:
44
+ with tarfile.open(fileobj=response, mode="r|gz") as tar:
45
+ member = None
46
+ for item in tar:
47
+ if item.name == "bf":
48
+ member = item
49
+ break
50
+
51
+ if member is None or not member.isfile():
52
+ _fail("backfill: release archive did not contain bf")
53
+
54
+ source = tar.extractfile(member)
55
+ if source is None:
56
+ _fail("backfill: could not read bf from release archive")
57
+
58
+ with tempfile.NamedTemporaryFile(dir=str(binary.parent), delete=False) as tmp:
59
+ tmp_name = tmp.name
60
+ shutil.copyfileobj(source, tmp)
61
+
62
+ os.chmod(tmp_name, 0o755)
63
+ os.replace(tmp_name, binary)
64
+ tmp_name = None
65
+ print(f"backfill: downloaded bf {os_name}/{arch}", file=sys.stderr)
66
+ except (urllib.error.URLError, TimeoutError, OSError) as exc:
67
+ _fail(
68
+ "backfill: failed to download bf: "
69
+ f"{exc}\nTry the curl installer instead: curl -fsSL https://backfill.sh/install.sh | sh"
70
+ )
71
+ finally:
72
+ if tmp_name is not None:
73
+ try:
74
+ os.unlink(tmp_name)
75
+ except OSError:
76
+ pass
77
+
78
+
79
+ def main():
80
+ if sys.platform == "win32":
81
+ _fail("backfill does not support Windows yet")
82
+
83
+ binary = Path.home() / ".local" / "share" / "backfill" / "bf"
84
+
85
+ if not (binary.exists() and os.access(str(binary), os.X_OK)):
86
+ _download(binary)
87
+
88
+ os.execv(str(binary), [str(binary)] + sys.argv[1:])
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: backfill-cli
3
+ Version: 0.3.0
4
+ Summary: Get paid while your builds run — terminal ad footer (bf)
5
+ Project-URL: Homepage, https://backfill.sh
6
+ Project-URL: Source, https://github.com/shyamsivakumar/backfill
7
+ License-Expression: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+
11
+ backfill-cli installs the `bf` command for Backfill.
12
+ Install with `pip install backfill-cli`.
13
+ Run your command through it: `bf dbt run`.
14
+ On first run, it downloads the platform binary from GitHub releases.
15
+ After that, it executes the cached binary directly.
16
+ Repo: https://github.com/shyamsivakumar/backfill
@@ -0,0 +1,5 @@
1
+ backfill_cli/__init__.py,sha256=jRZqcla3aYoTzyuSjpmKIvMelrXdwzdX4-lXlCOPCVg,2636
2
+ backfill_cli-0.3.0.dist-info/METADATA,sha256=MMiWKTAmplfY3Pq0JOBViP6QqIpHeR0sXecWy3QXBdo,626
3
+ backfill_cli-0.3.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
4
+ backfill_cli-0.3.0.dist-info/entry_points.txt,sha256=4fSDaXZry7OFRdUAJeXS67YJs8S3AJ-46XLe6QEL6EI,41
5
+ backfill_cli-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bf = backfill_cli:main