enzyme-python-package 0.4.4__tar.gz

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,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: enzyme-python-package
3
+ Version: 0.4.4
4
+ Summary: Vault intelligence — concept graph and semantic search for markdown notes
5
+ Author: Joshua Pham
6
+ License: MIT
7
+ Project-URL: Homepage, https://enzyme.garden
8
+ Project-URL: Repository, https://github.com/jshph/enzyme
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: MacOS
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
@@ -0,0 +1,157 @@
1
+ """enzyme-cli — pip-installable wrapper for the enzyme binary.
2
+
3
+ On first run (or `enzyme-cli install`), downloads the correct platform binary
4
+ and embedding model from GitHub releases. Subsequent calls proxy directly to
5
+ the binary.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import os
12
+ import platform
13
+ import stat
14
+ import subprocess
15
+ import sys
16
+ import tarfile
17
+ import tempfile
18
+ import urllib.request
19
+
20
+ REPO = "jshph/enzyme"
21
+ VERSION = "0.4.4"
22
+
23
+ # Where we store the binary and model
24
+ _DATA_DIR = os.path.join(os.path.expanduser("~"), ".enzyme-cli")
25
+ _BIN_PATH = os.path.join(_DATA_DIR, "enzyme")
26
+
27
+
28
+ def _detect_target() -> str:
29
+ """Detect platform target string matching GitHub release asset names."""
30
+ system = platform.system()
31
+ machine = platform.machine()
32
+
33
+ if system == "Darwin" and machine == "arm64":
34
+ return "macos-arm64"
35
+ elif system == "Linux" and machine == "x86_64":
36
+ return "linux-x86_64"
37
+ elif system == "Linux" and machine in ("aarch64", "arm64"):
38
+ return "linux-arm64"
39
+ else:
40
+ raise RuntimeError(
41
+ f"Unsupported platform: {system}-{machine}. "
42
+ "Enzyme supports macOS arm64, Linux x86_64, and Linux arm64."
43
+ )
44
+
45
+
46
+ def _download_url(url: str, dest: str) -> None:
47
+ """Download a URL to a file path."""
48
+ print(f" Downloading {url.split('/')[-1]}...")
49
+ urllib.request.urlretrieve(url, dest)
50
+
51
+
52
+ def _verify_sha256(filepath: str, sha256_url: str) -> None:
53
+ """Verify file against a .sha256 checksum URL."""
54
+ try:
55
+ with urllib.request.urlopen(sha256_url) as resp:
56
+ expected = resp.read().decode().strip().split()[0]
57
+ h = hashlib.sha256()
58
+ with open(filepath, "rb") as f:
59
+ for chunk in iter(lambda: f.read(8192), b""):
60
+ h.update(chunk)
61
+ actual = h.hexdigest()
62
+ if actual != expected:
63
+ raise RuntimeError(
64
+ f"SHA256 mismatch: expected {expected}, got {actual}"
65
+ )
66
+ except urllib.error.URLError:
67
+ # If checksum file unavailable, skip verification
68
+ pass
69
+
70
+
71
+ def _is_installed() -> bool:
72
+ """Check if the enzyme binary is installed and current."""
73
+ if not os.path.isfile(_BIN_PATH):
74
+ return False
75
+ # Check version
76
+ try:
77
+ result = subprocess.run(
78
+ [_BIN_PATH, "--version"],
79
+ capture_output=True, text=True, timeout=5,
80
+ )
81
+ return VERSION in result.stdout
82
+ except Exception:
83
+ return False
84
+
85
+
86
+ def install() -> None:
87
+ """Download and install the enzyme binary and embedding model."""
88
+ target = _detect_target()
89
+ base_url = f"https://github.com/{REPO}/releases/download/v{VERSION}"
90
+ asset = f"enzyme-{target}.tar.gz"
91
+ asset_url = f"{base_url}/{asset}"
92
+ sha256_url = f"{asset_url}.sha256"
93
+
94
+ os.makedirs(_DATA_DIR, exist_ok=True)
95
+
96
+ print(f"Installing enzyme {VERSION} ({target})...")
97
+
98
+ with tempfile.TemporaryDirectory() as tmpdir:
99
+ tarball = os.path.join(tmpdir, asset)
100
+ _download_url(asset_url, tarball)
101
+ _verify_sha256(tarball, sha256_url)
102
+
103
+ with tarfile.open(tarball, "r:gz") as tar:
104
+ tar.extractall(tmpdir)
105
+
106
+ # Move binary
107
+ src = os.path.join(tmpdir, "enzyme")
108
+ if not os.path.isfile(src):
109
+ raise RuntimeError(f"Binary not found in archive at {src}")
110
+
111
+ # Replace atomically
112
+ tmp_bin = _BIN_PATH + ".tmp"
113
+ with open(src, "rb") as sf, open(tmp_bin, "wb") as df:
114
+ df.write(sf.read())
115
+ os.chmod(tmp_bin, os.stat(tmp_bin).st_mode | stat.S_IEXEC)
116
+ os.replace(tmp_bin, _BIN_PATH)
117
+
118
+ # Copy bundled libs if present (Linux builds)
119
+ lib_dir = os.path.join(tmpdir, "lib")
120
+ if os.path.isdir(lib_dir):
121
+ dest_lib = os.path.join(_DATA_DIR, "lib")
122
+ os.makedirs(dest_lib, exist_ok=True)
123
+ for f in os.listdir(lib_dir):
124
+ src_f = os.path.join(lib_dir, f)
125
+ dst_f = os.path.join(dest_lib, f)
126
+ with open(src_f, "rb") as sf, open(dst_f, "wb") as df:
127
+ df.write(sf.read())
128
+
129
+ print(f" Binary installed to {_BIN_PATH}")
130
+
131
+ # Download embedding model
132
+ print(" Downloading embedding model (~52 MB)...")
133
+ subprocess.run(
134
+ [_BIN_PATH, "setup"],
135
+ timeout=120,
136
+ check=True,
137
+ )
138
+ print(" Done.")
139
+
140
+
141
+ def main() -> None:
142
+ """Entry point — install if needed, then proxy to the binary."""
143
+ # Handle explicit install command
144
+ if len(sys.argv) > 1 and sys.argv[1] == "install":
145
+ install()
146
+ return
147
+
148
+ # Auto-install on first run
149
+ if not _is_installed():
150
+ install()
151
+
152
+ # Proxy all args to the real binary
153
+ try:
154
+ result = subprocess.run([_BIN_PATH] + sys.argv[1:])
155
+ sys.exit(result.returncode)
156
+ except KeyboardInterrupt:
157
+ sys.exit(130)
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: enzyme-python-package
3
+ Version: 0.4.4
4
+ Summary: Vault intelligence — concept graph and semantic search for markdown notes
5
+ Author: Joshua Pham
6
+ License: MIT
7
+ Project-URL: Homepage, https://enzyme.garden
8
+ Project-URL: Repository, https://github.com/jshph/enzyme
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: MacOS
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ pyproject.toml
2
+ enzyme_python_package/__init__.py
3
+ enzyme_python_package.egg-info/PKG-INFO
4
+ enzyme_python_package.egg-info/SOURCES.txt
5
+ enzyme_python_package.egg-info/dependency_links.txt
6
+ enzyme_python_package.egg-info/entry_points.txt
7
+ enzyme_python_package.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ enzyme = enzyme_python_package:main
@@ -0,0 +1 @@
1
+ enzyme_python_package
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "enzyme-python-package"
7
+ version = "0.4.4"
8
+ description = "Vault intelligence — concept graph and semantic search for markdown notes"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {text = "MIT"}
12
+ authors = [{name = "Joshua Pham"}]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: MacOS",
17
+ "Operating System :: POSIX :: Linux",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://enzyme.garden"
22
+ Repository = "https://github.com/jshph/enzyme"
23
+
24
+ [project.scripts]
25
+ enzyme = "enzyme_python_package:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+