n1scan 0.1.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.
n1scan/__init__.py ADDED
@@ -0,0 +1,80 @@
1
+ """Thin launcher for the official n1scan binary (https://github.com/alex00010/n1scan)."""
2
+ import hashlib
3
+ import os
4
+ import platform
5
+ import subprocess
6
+ import sys
7
+ import tarfile
8
+ import tempfile
9
+ import urllib.request
10
+ import zipfile
11
+
12
+ __version__ = "0.1.0"
13
+ N1SCAN_VERSION = "0.1.0"
14
+ REPO = "alex00010/n1scan"
15
+
16
+
17
+ def _fail(msg):
18
+ sys.stderr.write("n1scan: %s\n" % msg)
19
+ sys.exit(1)
20
+
21
+
22
+ def _fetch(url):
23
+ req = urllib.request.Request(url, headers={"User-Agent": "n1scan-pypi-wrapper"})
24
+ with urllib.request.urlopen(req, timeout=60) as r:
25
+ return r.read()
26
+
27
+
28
+ def _binary():
29
+ goos = {"Windows": "windows", "Darwin": "darwin", "Linux": "linux"}.get(platform.system())
30
+ m = platform.machine().lower()
31
+ goarch = {"x86_64": "amd64", "amd64": "amd64", "arm64": "arm64", "aarch64": "arm64"}.get(m)
32
+ if not goos or not goarch:
33
+ _fail("unsupported platform %s/%s" % (platform.system(), platform.machine()))
34
+ exe = "n1scan.exe" if goos == "windows" else "n1scan"
35
+ home = os.environ.get("N1SCAN_HOME") or os.path.join(os.path.expanduser("~"), ".n1scan", "pypi")
36
+ d = os.path.join(home, "%s-%s-%s" % (N1SCAN_VERSION, goos, goarch))
37
+ binp = os.path.join(d, exe)
38
+ if os.path.exists(binp):
39
+ return binp
40
+
41
+ ext = "zip" if goos == "windows" else "tar.gz"
42
+ asset = "n1scan_%s_%s_%s.%s" % (N1SCAN_VERSION, goos, goarch, ext)
43
+ base = "https://github.com/%s/releases/download/v%s/" % (REPO, N1SCAN_VERSION)
44
+ sys.stderr.write("n1scan: downloading %s ...\n" % asset)
45
+ archive = _fetch(base + asset)
46
+ sums = _fetch(base + "checksums.txt").decode("utf-8")
47
+ want = None
48
+ for line in sums.splitlines():
49
+ p = line.split()
50
+ if len(p) == 2 and p[1] == asset:
51
+ want = p[0]
52
+ if not want:
53
+ _fail("no checksum listed for " + asset)
54
+ got = hashlib.sha256(archive).hexdigest()
55
+ if got != want:
56
+ _fail("checksum mismatch for %s (expected %s, got %s)" % (asset, want, got))
57
+
58
+ os.makedirs(d, exist_ok=True)
59
+ with tempfile.NamedTemporaryFile(delete=False, suffix="." + ext) as t:
60
+ t.write(archive)
61
+ tmp = t.name
62
+ try:
63
+ if ext == "zip":
64
+ with zipfile.ZipFile(tmp) as z:
65
+ z.extract(exe, d)
66
+ else:
67
+ with tarfile.open(tmp) as tf:
68
+ member = tf.getmember(exe)
69
+ member.name = exe
70
+ tf.extract(member, d)
71
+ finally:
72
+ os.unlink(tmp)
73
+ if goos != "windows":
74
+ os.chmod(binp, 0o755)
75
+ return binp
76
+
77
+
78
+ def main():
79
+ binp = _binary()
80
+ sys.exit(subprocess.call([binp] + sys.argv[1:]))
n1scan/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from . import main
2
+
3
+ main()
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: n1scan
3
+ Version: 0.1.0
4
+ Summary: Find N+1 queries by watching your app's PostgreSQL traffic. Launcher for the official n1scan binary.
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/alex00010/n1scan
7
+ Project-URL: Issues, https://github.com/alex00010/n1scan/issues
8
+ Keywords: postgres,postgresql,n+1,performance,orm,cli,proxy
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Database
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # n1scan
18
+
19
+ Find N+1 queries by watching your app's PostgreSQL traffic. One binary, no code changes, any language or ORM.
20
+
21
+ This package is a thin launcher: on first run it downloads the official binary from the
22
+ [GitHub release](https://github.com/alex00010/n1scan/releases), checks its SHA-256 against the release's
23
+ `checksums.txt`, and runs it.
24
+
25
+ ```sh
26
+ uvx n1scan run -- pytest
27
+ ```
28
+
29
+ Docs, source and issues: https://github.com/alex00010/n1scan
@@ -0,0 +1,8 @@
1
+ n1scan/__init__.py,sha256=UVdRBhvlJbFNHMU86p0Cw15TRNnsakP0iBkg_H9eOMQ,2588
2
+ n1scan/__main__.py,sha256=ubt6XyZvcHwdjCQ90B_U4MeP-3YJduz5GWUC9yOgkrg,27
3
+ n1scan-0.1.0.dist-info/licenses/LICENSE,sha256=W0or7v4WcWgU-O8RJT_VaQyzeAd55dwVRVHlZ3uiJSw,1076
4
+ n1scan-0.1.0.dist-info/METADATA,sha256=8PYaVyzIOA1Ih8pTzIlSPhT9nbVrjHc7nj7gdWv9Qck,1064
5
+ n1scan-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
6
+ n1scan-0.1.0.dist-info/entry_points.txt,sha256=fPqkk4SK_kDOhBF8TdpDkmV_MVICA9HIXl3dDhT8VvI,39
7
+ n1scan-0.1.0.dist-info/top_level.txt,sha256=WWRS4tt4WsLRtC45iRpz0fN3tjLu4tohiYmT4ppPl2E,7
8
+ n1scan-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ n1scan = n1scan:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 n1scan contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ n1scan