uv-sbom-bin 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.
@@ -0,0 +1,7 @@
1
+ """Python wrapper for uv-sbom CLI tool."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from .install import ensure_binary, get_binary_path
6
+
7
+ __all__ = ["ensure_binary", "get_binary_path", "__version__"]
@@ -0,0 +1,30 @@
1
+ """CLI entry point for uv-sbom."""
2
+
3
+ import subprocess
4
+ import sys
5
+
6
+ from .install import ensure_binary
7
+
8
+
9
+ def main():
10
+ """Main entry point that ensures binary is installed and runs it."""
11
+ try:
12
+ binary_path = ensure_binary()
13
+ except RuntimeError as e:
14
+ print(f"Error: {e}", file=sys.stderr)
15
+ return 1
16
+
17
+ # Run the binary with all arguments passed through
18
+ try:
19
+ result = subprocess.run(
20
+ [str(binary_path)] + sys.argv[1:],
21
+ check=False
22
+ )
23
+ return result.returncode
24
+ except Exception as e:
25
+ print(f"Error running uv-sbom: {e}", file=sys.stderr)
26
+ return 1
27
+
28
+
29
+ if __name__ == "__main__":
30
+ sys.exit(main())
uv_sbom_bin/install.py ADDED
@@ -0,0 +1,196 @@
1
+ """Binary installation logic for uv-sbom."""
2
+
3
+ import os
4
+ import platform
5
+ import sys
6
+ import tarfile
7
+ import zipfile
8
+ from pathlib import Path
9
+ from urllib.request import urlretrieve
10
+
11
+ # Version of uv-sbom to install
12
+ UV_SBOM_VERSION = "0.1.0"
13
+
14
+ # GitHub release URL template
15
+ RELEASE_URL_TEMPLATE = (
16
+ "https://github.com/Taketo-Yoda/uv-sbom/releases/download/"
17
+ "v{version}/uv-sbom-{platform}.{ext}"
18
+ )
19
+
20
+
21
+ def get_platform_info():
22
+ """Detect the current platform and return the appropriate binary info.
23
+
24
+ Returns:
25
+ tuple: (platform_string, file_extension)
26
+
27
+ Raises:
28
+ RuntimeError: If the platform is not supported
29
+ """
30
+ system = platform.system().lower()
31
+ machine = platform.machine().lower()
32
+
33
+ if system == "darwin":
34
+ if machine == "arm64":
35
+ return "aarch64-apple-darwin", "tar.gz"
36
+ elif machine == "x86_64":
37
+ return "x86_64-apple-darwin", "tar.gz"
38
+ else:
39
+ raise RuntimeError(f"Unsupported macOS architecture: {machine}")
40
+
41
+ elif system == "linux":
42
+ if machine == "x86_64":
43
+ return "x86_64-unknown-linux-gnu", "tar.gz"
44
+ else:
45
+ raise RuntimeError(
46
+ f"Unsupported Linux architecture: {machine}. "
47
+ "Only x86_64 is currently supported."
48
+ )
49
+
50
+ elif system == "windows":
51
+ if machine in ("amd64", "x86_64"):
52
+ return "x86_64-pc-windows-msvc", "zip"
53
+ else:
54
+ raise RuntimeError(f"Unsupported Windows architecture: {machine}")
55
+
56
+ else:
57
+ raise RuntimeError(f"Unsupported operating system: {system}")
58
+
59
+
60
+ def get_binary_path():
61
+ """Get the path where the uv-sbom binary should be installed.
62
+
63
+ Returns:
64
+ Path: Path to the binary executable
65
+ """
66
+ package_dir = Path(__file__).parent
67
+ binary_dir = package_dir / "bin"
68
+
69
+ if platform.system().lower() == "windows":
70
+ return binary_dir / "uv-sbom.exe"
71
+ else:
72
+ return binary_dir / "uv-sbom"
73
+
74
+
75
+ def download_binary(platform_str, extension, dest_dir):
76
+ """Download the binary archive for the current platform.
77
+
78
+ Args:
79
+ platform_str: Platform identifier (e.g., "x86_64-apple-darwin")
80
+ extension: File extension ("tar.gz" or "zip")
81
+ dest_dir: Destination directory for the download
82
+
83
+ Returns:
84
+ Path: Path to the downloaded archive
85
+ """
86
+ url = RELEASE_URL_TEMPLATE.format(
87
+ version=UV_SBOM_VERSION,
88
+ platform=platform_str,
89
+ ext=extension
90
+ )
91
+
92
+ archive_name = f"uv-sbom-{platform_str}.{extension}"
93
+ archive_path = dest_dir / archive_name
94
+
95
+ print(f"Downloading uv-sbom v{UV_SBOM_VERSION} for {platform_str}...")
96
+ print(f"URL: {url}")
97
+
98
+ try:
99
+ urlretrieve(url, archive_path)
100
+ print(f"Downloaded to {archive_path}")
101
+ return archive_path
102
+ except Exception as e:
103
+ raise RuntimeError(
104
+ f"Failed to download uv-sbom binary: {e}\n"
105
+ f"URL: {url}"
106
+ )
107
+
108
+
109
+ def extract_binary(archive_path, dest_dir):
110
+ """Extract the binary from the downloaded archive.
111
+
112
+ Args:
113
+ archive_path: Path to the archive file
114
+ dest_dir: Destination directory for extraction
115
+ """
116
+ print(f"Extracting {archive_path}...")
117
+
118
+ if archive_path.suffix == ".zip" or archive_path.name.endswith(".zip"):
119
+ with zipfile.ZipFile(archive_path, 'r') as zip_ref:
120
+ zip_ref.extractall(dest_dir)
121
+ else: # tar.gz
122
+ with tarfile.open(archive_path, 'r:gz') as tar_ref:
123
+ tar_ref.extractall(dest_dir)
124
+
125
+ print(f"Extracted to {dest_dir}")
126
+
127
+
128
+ def make_executable(binary_path):
129
+ """Make the binary executable on Unix-like systems.
130
+
131
+ Args:
132
+ binary_path: Path to the binary file
133
+ """
134
+ if platform.system().lower() != "windows":
135
+ os.chmod(binary_path, 0o755)
136
+ print(f"Made {binary_path} executable")
137
+
138
+
139
+ def ensure_binary():
140
+ """Ensure the uv-sbom binary is installed.
141
+
142
+ Downloads and installs the binary if not already present.
143
+
144
+ Returns:
145
+ Path: Path to the installed binary
146
+
147
+ Raises:
148
+ RuntimeError: If installation fails
149
+ """
150
+ binary_path = get_binary_path()
151
+
152
+ # Check if already installed
153
+ if binary_path.exists():
154
+ print(f"uv-sbom binary already installed at {binary_path}")
155
+ return binary_path
156
+
157
+ # Get platform info
158
+ try:
159
+ platform_str, extension = get_platform_info()
160
+ except RuntimeError as e:
161
+ print(f"Error: {e}", file=sys.stderr)
162
+ raise
163
+
164
+ # Create binary directory
165
+ binary_dir = binary_path.parent
166
+ binary_dir.mkdir(parents=True, exist_ok=True)
167
+
168
+ # Download and extract
169
+ try:
170
+ archive_path = download_binary(platform_str, extension, binary_dir)
171
+ extract_binary(archive_path, binary_dir)
172
+
173
+ # Verify the binary exists
174
+ if not binary_path.exists():
175
+ raise RuntimeError(
176
+ f"Binary not found after extraction: {binary_path}"
177
+ )
178
+
179
+ # Make executable
180
+ make_executable(binary_path)
181
+
182
+ # Clean up archive
183
+ archive_path.unlink()
184
+ print(f"Cleaned up {archive_path}")
185
+
186
+ print(f"✅ uv-sbom v{UV_SBOM_VERSION} installed successfully!")
187
+ return binary_path
188
+
189
+ except Exception as e:
190
+ print(f"❌ Installation failed: {e}", file=sys.stderr)
191
+ raise
192
+
193
+
194
+ if __name__ == "__main__":
195
+ # Allow running as: python -m uv_sbom_bin.install
196
+ ensure_binary()
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: uv-sbom-bin
3
+ Version: 0.1.0
4
+ Summary: Python wrapper for uv-sbom - SBOM generation tool for uv projects
5
+ Project-URL: Homepage, https://github.com/Taketo-Yoda/uv-sbom
6
+ Project-URL: Repository, https://github.com/Taketo-Yoda/uv-sbom
7
+ Project-URL: Bug Tracker, https://github.com/Taketo-Yoda/uv-sbom/issues
8
+ Author-email: Taketo Yoda <exhaust7.drs@gmail.com>
9
+ License: MIT
10
+ Keywords: cyclonedx,python-wrapper,sbom,security,supply-chain,uv
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Security
22
+ Classifier: Topic :: Software Development :: Build Tools
23
+ Classifier: Topic :: System :: Software Distribution
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+
27
+ # uv-sbom-bin
28
+
29
+ Python wrapper for the `uv-sbom` CLI tool written in Rust.
30
+
31
+ This package allows Python users to install `uv-sbom` via PyPI and use it with `uv tool install`.
32
+
33
+ ## Installation
34
+
35
+ ### Via pip
36
+
37
+ ```bash
38
+ pip install uv-sbom-bin
39
+ ```
40
+
41
+ ### Via uv
42
+
43
+ ```bash
44
+ uv tool install uv-sbom-bin
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ After installation, the `uv-sbom` command will be available in your PATH:
50
+
51
+ ```bash
52
+ uv-sbom --version
53
+ uv-sbom --format json
54
+ uv-sbom --format markdown --output SBOM.md
55
+ ```
56
+
57
+ ## How It Works
58
+
59
+ This package downloads the prebuilt Rust binary for your platform from the [GitHub releases](https://github.com/Taketo-Yoda/uv-sbom/releases) and installs it.
60
+
61
+ Supported platforms:
62
+ - macOS (Apple Silicon and Intel)
63
+ - Linux (x86_64)
64
+ - Windows (x86_64)
65
+
66
+ ## Development
67
+
68
+ This is a wrapper package. The actual tool is developed at:
69
+ https://github.com/Taketo-Yoda/uv-sbom
70
+
71
+ ## License
72
+
73
+ MIT License - see [LICENSE](https://github.com/Taketo-Yoda/uv-sbom/blob/main/LICENSE)
@@ -0,0 +1,7 @@
1
+ uv_sbom_bin/__init__.py,sha256=ADA4IPJMVYgQ1cc-yuWF-fB_Ehrp3ukr9zYxo4FJliU,182
2
+ uv_sbom_bin/__main__.py,sha256=WhZJUeivXr7JnKsRwPKbEY_RQz2p9YrO5lOtcFRWtOU,696
3
+ uv_sbom_bin/install.py,sha256=5PMo9wWQEMlFIF-OY17y1ZFV98rv8FsV3orL3jglxVQ,5417
4
+ uv_sbom_bin-0.1.0.dist-info/METADATA,sha256=_Iy2cfv4oLTr1zk98hFn-bHhA9qubgR_d6ZmPGVBmCg,2105
5
+ uv_sbom_bin-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ uv_sbom_bin-0.1.0.dist-info/entry_points.txt,sha256=h3xm_-qaiw_VpHnAUjf95X_Lpbf2Tm5g04U9ivqKLhA,54
7
+ uv_sbom_bin-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ uv-sbom = uv_sbom_bin.__main__:main