rust-template 0.1.23__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,100 @@
1
+ import os
2
+ import platform
3
+ import subprocess
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def get_platform_info():
9
+ """Determine platform-specific directory and binary name."""
10
+ system = platform.system().lower()
11
+ machine = platform.machine().lower()
12
+
13
+ # Normalize architecture names
14
+ if machine in ("x86_64", "amd64"):
15
+ arch = "x64"
16
+ elif machine in ("aarch64", "arm64"):
17
+ arch = "arm64"
18
+ else:
19
+ print(f"Unsupported architecture: {machine}", file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ # Map to platform-specific directory and binary name
23
+ platform_map = {
24
+ "darwin": {
25
+ "x64": {"dir": "macos-x64", "binary": "rust_template"},
26
+ "arm64": {"dir": "macos-arm64", "binary": "rust_template"},
27
+ },
28
+ "linux": {
29
+ "x64": {"dir": "linux-x64-gnu", "binary": "rust_template"},
30
+ "arm64": {"dir": "linux-arm64-gnu", "binary": "rust_template"},
31
+ },
32
+ "windows": {
33
+ "x64": {"dir": "windows-x64", "binary": "rust_template.exe"},
34
+ "arm64": {"dir": "windows-arm64", "binary": "rust_template.exe"},
35
+ },
36
+ }
37
+
38
+ if system not in platform_map or arch not in platform_map[system]:
39
+ print(f"Unsupported platform: {system}-{arch}", file=sys.stderr)
40
+ sys.exit(1)
41
+
42
+ return platform_map[system][arch]
43
+
44
+
45
+ def find_binary():
46
+ """Find the binary for current platform."""
47
+ platform_info = get_platform_info()
48
+
49
+ # Get package root directory
50
+ package_root = Path(__file__).parent
51
+ binaries_dir = package_root / "binaries"
52
+
53
+ if not binaries_dir.exists():
54
+ print("Error: Binaries directory not found.", file=sys.stderr)
55
+ print("Please reinstall the package.", file=sys.stderr)
56
+ sys.exit(1)
57
+
58
+ # Look for the binary in platform-specific subdirectory
59
+ platform_dir = binaries_dir / platform_info["dir"]
60
+ binary_path = platform_dir / platform_info["binary"]
61
+
62
+ if not binary_path.exists():
63
+ print(
64
+ f"Error: Binary not found for your platform: {platform_info['dir']}/{platform_info['binary']}",
65
+ file=sys.stderr,
66
+ )
67
+ print("Please reinstall the package.", file=sys.stderr)
68
+ sys.exit(1)
69
+
70
+ # Make binary executable on Unix-like systems
71
+ if platform.system() != "Windows":
72
+ try:
73
+ os.chmod(binary_path, 0o755)
74
+ except OSError:
75
+ # Ignore error if already executable
76
+ pass
77
+
78
+ return binary_path
79
+
80
+
81
+ def main():
82
+ """Main entry point that forwards all arguments to the binary."""
83
+ binary_path = find_binary()
84
+
85
+ # Forward all arguments to the binary
86
+ args = sys.argv[1:]
87
+
88
+ try:
89
+ result = subprocess.run(
90
+ [str(binary_path)] + args,
91
+ check=False,
92
+ )
93
+ sys.exit(result.returncode)
94
+ except Exception as err:
95
+ print(f"Failed to start binary: {err}", file=sys.stderr)
96
+ sys.exit(1)
97
+
98
+
99
+ if __name__ == "__main__":
100
+ main()
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.3
2
+ Name: rust-template
3
+ Version: 0.1.23
4
+ Summary: A production-ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.
5
+ Keywords: cli,ai,coding-assistant,telemetry,claude,codex,gemini,usage-tracker,analytics
6
+ Author: Wei Lee
7
+ Author-email: Wei Lee <mai@mai0313.com>
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Project-URL: Bug Tracker, https://github.com/Mai0313/rust_template/issues
23
+ Project-URL: Homepage, https://github.com/Mai0313/rust_template
24
+ Project-URL: Repository, https://github.com/Mai0313/rust_template
25
+ Description-Content-Type: text/markdown
26
+
27
+ <center>
28
+
29
+ # Rust Project Template
30
+
31
+ [![Crates.io](https://img.shields.io/crates/v/rust_template?logo=rust&style=flat-square&color=E05D44)](https://crates.io/crates/rust_template)
32
+ [![Crates.io Downloads](https://img.shields.io/crates/d/rust_template?logo=rust&style=flat-square)](https://crates.io/crates/rust_template)
33
+ [![npm version](https://img.shields.io/npm/v/rust_template?logo=npm&style=flat-square&color=CB3837)](https://www.npmjs.com/package/rust_template)
34
+ [![npm downloads](https://img.shields.io/npm/dt/rust_template?logo=npm&style=flat-square)](https://www.npmjs.com/package/rust_template)
35
+ [![rust](https://img.shields.io/badge/Rust-stable-orange?logo=rust&logoColor=white&style=flat-square)](https://www.rust-lang.org/)
36
+ [![tests](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/test.yml?label=tests&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/test.yml)
37
+ [![code-quality](https://img.shields.io/github/actions/workflow/status/Mai0313/rust_template/code-quality-check.yml?label=code-quality&logo=github&style=flat-square)](https://github.com/Mai0313/rust_template/actions/workflows/code-quality-check.yml)
38
+ [![license](https://img.shields.io/badge/License-MIT-green.svg?labelColor=gray&style=flat-square)](https://github.com/Mai0313/rust_template/tree/master?tab=License-1-ov-file)
39
+ [![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/Mai0313/rust_template/pulls)
40
+
41
+ </center>
42
+
43
+ 🚀 A production‑ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.
44
+
45
+ Click [Use this template](https://github.com/Mai0313/rust_template/generate) to start a new repository from this scaffold.
46
+
47
+ Other Languages: [English](README.md) | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)
48
+
49
+ ## ✨ Highlights
50
+
51
+ - Modern Cargo layout (`src/lib.rs`, `src/main.rs`, `tests/`)
52
+ - Lint & format with clippy and rustfmt
53
+ - GitHub Actions: tests, quality, package build, Docker publish, release drafter, Rust-aware labeler, secret scans, semantic PR, weekly dependency update
54
+ - Multi-stage Dockerfile producing a minimal runtime image
55
+
56
+ ## 🚀 Quick Start
57
+
58
+ Prerequisites: Rust toolchain (`rustup`), Docker (optional)
59
+
60
+ ```bash
61
+ make fmt # rustfmt + clippy
62
+ make test # cargo test (all targets)
63
+ make test-verbose # cargo test (all targets with verbose output)
64
+ make coverage # generate LCOV coverage report
65
+ make build # cargo build (release mode)
66
+ make build-release # cargo build --release
67
+ make run # run the release binary
68
+ make clean # clean build artifacts and caches
69
+ make package # build crate package (allow dirty)
70
+ make help # list targets
71
+ ```
72
+
73
+ ## 🐳 Docker
74
+
75
+ ```bash
76
+ docker build -f docker/Dockerfile --target prod -t ghcr.io/<owner>/<repo>:latest .
77
+ docker run --rm ghcr.io/<owner>/<repo>:latest
78
+ ```
79
+
80
+ Or using the actual binary name:
81
+
82
+ ```bash
83
+ docker build -f docker/Dockerfile --target prod -t rust_template:latest .
84
+ docker run --rm rust_template:latest
85
+ ```
86
+
87
+ ## 📦 Packaging
88
+
89
+ ```bash
90
+ make package # build crate package (allow dirty)
91
+ # or use cargo directly:
92
+ cargo package --locked --allow-dirty
93
+ # CARGO_REGISTRY_TOKEN=... cargo publish
94
+ ```
95
+
96
+ CI builds run automatically on tags matching `v*` and upload the `.crate` file. Uncomment the publish step in `build_package.yml` to automate crates.io releases.
97
+
98
+ ## 🧩 Cross Builds
99
+
100
+ This template does not ship cross-compile tooling by default. If you need cross or zig-based builds locally, install and configure them per your environment.
101
+
102
+ GitHub Actions `build_release.yml` builds multi-platform release binaries on tags matching `v*` and uploads them to the GitHub Release assets.
103
+
104
+ Targets:
105
+
106
+ - x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl
107
+ - aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl
108
+ - x86_64-apple-darwin, aarch64-apple-darwin
109
+ - x86_64-pc-windows-msvc, aarch64-pc-windows-msvc
110
+
111
+ Assets naming:
112
+
113
+ - `<bin>-v<version>-<target>.tar.gz` (all platforms)
114
+ - `<bin>-v<version>-<target>.zip` (Windows additionally)
115
+
116
+ ## 🔁 CI/CD Workflows
117
+
118
+ ### Main Workflows
119
+
120
+ - Tests (`test.yml`): cargo build/test + generate LCOV coverage report and upload artifact
121
+ - Code Quality (`code-quality-check.yml`): rustfmt check + clippy (deny warnings)
122
+ - Build Package (`build_package.yml`): package on tag `v*`, optional crates.io publish
123
+ - Publish Docker Image (`build_image.yml`): push to GHCR on `main/master` and tags `v*`
124
+ - Build Release (`build_release.yml`): Linux release binaries uploaded on tags `v*`
125
+
126
+ ### Additional Automation
127
+
128
+ - Auto Labeler (`auto_labeler.yml`): automatically label PRs based on branch names and file changes
129
+ - Code Scan (`code_scan.yml`): multi-layer security scanning (GitLeaks, Trufflehog secret scanning, CodeQL code analysis, Trivy vulnerability scanning)
130
+ - Release Drafter (`release_drafter.yml`): auto-generate release notes
131
+ - Semantic PR (`semantic-pull-request.yml`): enforce PR title format
132
+ - Dependabot weekly dependency updates
133
+
134
+ ## 🤝 Contributing
135
+
136
+ - Open issues/PRs
137
+
138
+ - Use Conventional Commits for PR titles
139
+
140
+ - Keep code formatted and clippy‑clean
141
+
142
+ - After every edit, run `cargo build` to confirm compilation is successful
143
+
144
+ - Before opening a PR, please run locally:
145
+
146
+ - `cargo fmt --all -- --check`
147
+ - `cargo clippy --all-targets --all-features -- -D warnings`
148
+ - `cargo test`
149
+
150
+ ## 📄 License
151
+
152
+ MIT — see `LICENSE`.
@@ -0,0 +1,11 @@
1
+ rust_template/__init__.py,sha256=Ro3qpI7C0zvr3tlzlV30M3Zyyy9XpC_w4lTs5zhtveQ,2956
2
+ rust_template/binaries/linux-arm64-gnu/rust_template,sha256=qYeUToHGmxqmUoGDkil6a3gnWSVzAb029gerHCD2FjU,332480
3
+ rust_template/binaries/linux-x64-gnu/rust_template,sha256=WmKvL_U-PZDuWad6IOEq5h_ZAx1ikbxJdaro9htPWS4,351592
4
+ rust_template/binaries/macos-arm64/rust_template,sha256=YJSYSJGDpWKe2zsbTAm7_UAHiVTA_kgizsjX4feLwEg,333648
5
+ rust_template/binaries/macos-x64/rust_template,sha256=qt_v0UzDbIIYrfncSOq_3LXxF31nBM5zoXg4XL_t-zk,335024
6
+ rust_template/binaries/windows-arm64/rust_template.exe,sha256=I1UcHmoYjbAi9km8ieZ632Uak3VyxBQvqdkBBqZrF5s,130048
7
+ rust_template/binaries/windows-x64/rust_template.exe,sha256=rnWfxfqHItz2gCWgaTn4QAqSIaEItHhoPdGkkdFzjdk,133632
8
+ rust_template-0.1.23.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
9
+ rust_template-0.1.23.dist-info/entry_points.txt,sha256=lL_pLmtZBPDfLdmysH0lmak13AP0yMCDLgILZFrqafs,79
10
+ rust_template-0.1.23.dist-info/METADATA,sha256=tihg-KZCbXHw0ZLLaqvylrRSqOTumaW7S7yizgnQNso,6728
11
+ rust_template-0.1.23.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.8.24
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ rust_template = rust_template:main
3
+ vct = rust_template:main
4
+