multi-lang-build 0.2.5__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,64 @@
1
+ """Multi-Lang Build - Multi-language automated build tool with domestic mirror acceleration."""
2
+
3
+ from multi_lang_build.compiler.base import BuildConfig, BuildResult, CompilerBase
4
+ from multi_lang_build.compiler.pnpm import PnpmCompiler
5
+ from multi_lang_build.compiler.go import GoCompiler
6
+ from multi_lang_build.compiler.python import PythonCompiler
7
+ from multi_lang_build.mirror.config import MirrorConfig, get_mirror_config
8
+ from multi_lang_build.register import register_skill
9
+
10
+ __version__ = "0.2.5"
11
+ __all__ = [
12
+ "BuildConfig",
13
+ "BuildResult",
14
+ "CompilerBase",
15
+ "PnpmCompiler",
16
+ "GoCompiler",
17
+ "PythonCompiler",
18
+ "MirrorConfig",
19
+ "get_mirror_config",
20
+ "register_skill",
21
+ ]
22
+
23
+
24
+ def main() -> None:
25
+ """Main entry point for the multi-lang-build CLI tool."""
26
+ import sys
27
+ from multi_lang_build.cli import run_cli
28
+
29
+ run_cli(sys.argv[1:])
30
+
31
+
32
+ def main_register() -> None:
33
+ """Entry point for the register CLI tool."""
34
+ import sys
35
+ import argparse
36
+ from multi_lang_build.register import register_skill
37
+
38
+ parser = argparse.ArgumentParser(
39
+ description="Register multi-lang-build as an IDE skill",
40
+ prog="multi-lang-register",
41
+ )
42
+ parser.add_argument(
43
+ "ide",
44
+ nargs="?",
45
+ default="claude",
46
+ choices=["claude", "opencode", "trae", "codebuddy", "all"],
47
+ help="IDE to register with (default: claude)",
48
+ )
49
+ parser.add_argument(
50
+ "--version",
51
+ action="version",
52
+ version=f"%(prog)s {__version__}",
53
+ )
54
+
55
+ args = parser.parse_args()
56
+ success = register_skill(args.ide)
57
+ sys.exit(0 if success else 1)
58
+
59
+
60
+ def main_mirror() -> None:
61
+ """Entry point for the mirror CLI tool."""
62
+ from multi_lang_build.mirror.cli import mirror_main
63
+
64
+ mirror_main()
@@ -0,0 +1,320 @@
1
+ """CLI interface for auto-build tool."""
2
+
3
+ from pathlib import Path
4
+ from typing import Sequence, TypedDict
5
+
6
+
7
+ class BuildResult(TypedDict):
8
+ """Result of a build operation."""
9
+ success: bool
10
+ return_code: int
11
+ stdout: str
12
+ stderr: str
13
+ output_path: Path | None
14
+ duration_seconds: float
15
+
16
+
17
+ def run_cli(args: Sequence[str]) -> None:
18
+ """Run the CLI with the given arguments.
19
+
20
+ Args:
21
+ args: Command line arguments (excluding program name)
22
+ """
23
+ import argparse
24
+ import sys
25
+
26
+ parser = argparse.ArgumentParser(
27
+ description="AutoBuild - Multi-language automated build tool",
28
+ formatter_class=argparse.RawDescriptionHelpFormatter,
29
+ epilog="""
30
+ Examples:
31
+ %(prog)s pnpm ./src --output ./dist --mirror
32
+ %(prog)s go ./src --output ./bin/app --mirror
33
+ %(prog)s python ./src --output ./dist --mirror --poetry
34
+
35
+ Supported languages:
36
+ pnpm - Frontend JavaScript/TypeScript projects
37
+ go - Go projects with module support
38
+ python - Python projects with pip/poetry/pdm
39
+ """,
40
+ )
41
+
42
+ parser.add_argument(
43
+ "--version",
44
+ action="version",
45
+ version=f"%(prog)s {__import__('multi_lang_build').__version__}",
46
+ )
47
+
48
+ subparsers = parser.add_subparsers(
49
+ dest="language",
50
+ title="language",
51
+ description="Build tool for specific language",
52
+ )
53
+
54
+ pnpm_parser = subparsers.add_parser(
55
+ "pnpm",
56
+ help="Build pnpm-based frontend projects",
57
+ description="Build pnpm-based frontend projects with mirror acceleration",
58
+ )
59
+ pnpm_parser.add_argument("source_dir", type=Path, help="Source directory")
60
+ pnpm_parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
61
+ pnpm_parser.add_argument("--mirror/--no-mirror", default=True, help="Enable/disable mirror acceleration")
62
+ pnpm_parser.add_argument("--script", type=str, help="Run specific npm script")
63
+ pnpm_parser.add_argument("--install", action="store_true", help="Install dependencies only")
64
+ pnpm_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
65
+
66
+ go_parser = subparsers.add_parser(
67
+ "go",
68
+ help="Build Go projects",
69
+ description="Build Go projects with module support and mirror acceleration",
70
+ )
71
+ go_parser.add_argument("source_dir", type=Path, help="Source directory")
72
+ go_parser.add_argument("-o", "--output", type=Path, required=True, help="Output file or directory")
73
+ go_parser.add_argument("--mirror/--no-mirror", default=True, help="Enable/disable Go proxy mirror")
74
+ go_parser.add_argument("--ldflags", type=str, help="Linker flags")
75
+ go_parser.add_argument("--tags", type=str, help="Build tags (comma-separated)")
76
+ go_parser.add_argument("--test", action="store_true", help="Run tests instead of building")
77
+ go_parser.add_argument("--tidy", action="store_true", help="Run go mod tidy")
78
+ go_parser.add_argument("--all", action="store_true", help="Build all packages")
79
+ go_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
80
+
81
+ python_parser = subparsers.add_parser(
82
+ "python",
83
+ help="Build Python projects",
84
+ description="Build Python projects with pip/poetry/pdm and mirror acceleration",
85
+ )
86
+ python_parser.add_argument("source_dir", type=Path, help="Source directory")
87
+ python_parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
88
+ python_parser.add_argument("--mirror/--no-mirror", default=True, help="Enable/disable PyPI mirror")
89
+ python_parser.add_argument("--install", action="store_true", help="Install dependencies only")
90
+ python_parser.add_argument("--dev", action="store_true", help="Include development dependencies")
91
+ python_parser.add_argument("--poetry", action="store_true", help="Force using poetry")
92
+ python_parser.add_argument("--create-venv", type=Path, help="Create virtual environment at path")
93
+ python_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
94
+
95
+ mirror_parser = subparsers.add_parser(
96
+ "mirror",
97
+ help="Manage mirror configurations",
98
+ description="List or configure domestic mirror acceleration settings",
99
+ epilog="""
100
+ Examples:
101
+ %(prog)s mirror list List all available mirrors
102
+ %(prog)s mirror set pip Configure pip mirror (default)
103
+ %(prog)s mirror set go Configure go proxy mirror
104
+ %(prog)s mirror set pnpm Configure pnpm registry mirror
105
+ %(prog)s mirror show Show current configuration
106
+ %(prog)s mirror reset Reset configuration
107
+ """,
108
+ )
109
+ mirror_subparsers = mirror_parser.add_subparsers(dest="mirror_action")
110
+
111
+ list_parser = mirror_subparsers.add_parser("list", help="List available mirrors")
112
+ list_parser.add_argument("--json", action="store_true", help="Output as JSON")
113
+
114
+ set_parser = mirror_subparsers.add_parser("set", help="Set mirror configuration")
115
+ set_parser.add_argument(
116
+ "type",
117
+ type=str,
118
+ default="pip",
119
+ nargs="?",
120
+ choices=["pip", "go", "npm", "pnpm"],
121
+ help="Package manager type (default: pip)",
122
+ )
123
+ set_parser.add_argument(
124
+ "mirror",
125
+ type=str,
126
+ nargs="?",
127
+ default="pip",
128
+ help="Mirror to use",
129
+ )
130
+
131
+ show_parser = mirror_subparsers.add_parser("show", help="Show current configuration")
132
+ show_parser.add_argument(
133
+ "--global",
134
+ dest="global_level",
135
+ action="store_true",
136
+ help="Show global config instead of project-level",
137
+ )
138
+
139
+ reset_parser = mirror_subparsers.add_parser("reset", help="Reset configuration")
140
+ reset_parser.add_argument(
141
+ "--global",
142
+ dest="global_level",
143
+ action="store_true",
144
+ help="Reset global config instead of project-level",
145
+ )
146
+
147
+ # Register subcommand for IDE integration
148
+ register_parser = subparsers.add_parser(
149
+ "register",
150
+ help="Register as IDE skill (Claude Code, OpenCode, Trae, CodeBuddy)",
151
+ description="Register multi-lang-build as a skill for various AI coding assistants and IDEs",
152
+ epilog="""
153
+ Examples:
154
+ %(prog)s register # Register with Claude Code (default)
155
+ %(prog)s register claude # Register with Claude Code
156
+ %(prog)s register opencode # Register with OpenCode
157
+ %(prog)s register trae # Register with Trae
158
+ %(prog)s register codebuddy # Register with CodeBuddy
159
+ %(prog)s register all # Register with all supported IDEs
160
+ """,
161
+ )
162
+ register_parser.add_argument(
163
+ "ide",
164
+ nargs="?",
165
+ default="claude",
166
+ choices=["claude", "opencode", "trae", "codebuddy", "all"],
167
+ help="IDE to register with (default: claude)",
168
+ )
169
+
170
+ parsed_args = parser.parse_args(args)
171
+
172
+ if parsed_args.language is None:
173
+ parser.print_help()
174
+ sys.exit(1)
175
+
176
+ result: BuildResult | None = None
177
+
178
+ try:
179
+ if parsed_args.language == "pnpm":
180
+ from multi_lang_build.compiler.pnpm import PnpmCompiler
181
+
182
+ compiler = PnpmCompiler()
183
+
184
+ if parsed_args.script:
185
+ result = compiler.run_script(
186
+ parsed_args.source_dir,
187
+ parsed_args.script,
188
+ mirror_enabled=parsed_args.mirror,
189
+ )
190
+ elif parsed_args.install:
191
+ result = compiler.install_dependencies(
192
+ parsed_args.source_dir,
193
+ mirror_enabled=parsed_args.mirror,
194
+ )
195
+ else:
196
+ result = compiler.build(
197
+ parsed_args.source_dir,
198
+ parsed_args.output,
199
+ mirror_enabled=parsed_args.mirror,
200
+ stream_output=parsed_args.stream_output,
201
+ )
202
+
203
+ elif parsed_args.language == "go":
204
+ from multi_lang_build.compiler.go import GoCompiler
205
+
206
+ compiler = GoCompiler()
207
+
208
+ if parsed_args.test:
209
+ result = compiler.run_tests(
210
+ parsed_args.source_dir,
211
+ mirror_enabled=parsed_args.mirror,
212
+ )
213
+ elif parsed_args.tidy:
214
+ result = compiler.tidy_modules(
215
+ parsed_args.source_dir,
216
+ mirror_enabled=parsed_args.mirror,
217
+ )
218
+ elif parsed_args.all:
219
+ result = compiler.build_all(
220
+ parsed_args.source_dir,
221
+ parsed_args.output,
222
+ mirror_enabled=parsed_args.mirror,
223
+ stream_output=parsed_args.stream_output,
224
+ )
225
+ else:
226
+ tags = parsed_args.tags.split(",") if parsed_args.tags else None
227
+ result = compiler.build_binary(
228
+ parsed_args.source_dir,
229
+ parsed_args.output,
230
+ mirror_enabled=parsed_args.mirror,
231
+ ldflags=parsed_args.ldflags,
232
+ tags=tags,
233
+ stream_output=parsed_args.stream_output,
234
+ )
235
+
236
+ elif parsed_args.language == "python":
237
+ from multi_lang_build.compiler.python import PythonCompiler
238
+
239
+ compiler = PythonCompiler()
240
+
241
+ if parsed_args.create_venv:
242
+ result = compiler.create_venv(
243
+ parsed_args.create_venv,
244
+ mirror_enabled=parsed_args.mirror,
245
+ )
246
+ elif parsed_args.install:
247
+ result = compiler.install_dependencies(
248
+ parsed_args.source_dir,
249
+ mirror_enabled=parsed_args.mirror,
250
+ dev=parsed_args.dev,
251
+ poetry=parsed_args.poetry,
252
+ )
253
+ else:
254
+ result = compiler.build(
255
+ parsed_args.source_dir,
256
+ parsed_args.output,
257
+ mirror_enabled=parsed_args.mirror,
258
+ stream_output=parsed_args.stream_output,
259
+ )
260
+
261
+ elif parsed_args.language == "mirror":
262
+ from multi_lang_build.mirror.cli import configure_mirror, print_mirrors, get_current_config
263
+
264
+ if parsed_args.mirror_action == "list":
265
+ if getattr(parsed_args, "json", False):
266
+ from multi_lang_build.mirror.cli import get_all_mirrors
267
+ import json
268
+ print(json.dumps(get_all_mirrors(), indent=2, ensure_ascii=False))
269
+ else:
270
+ print_mirrors()
271
+ elif parsed_args.mirror_action == "set":
272
+ mirror_type = getattr(parsed_args, "type", "pip")
273
+ mirror_key = getattr(parsed_args, "mirror", "pip")
274
+ success = configure_mirror(mirror_type, mirror_key)
275
+ sys.exit(0 if success else 1)
276
+ elif parsed_args.mirror_action == "show":
277
+ config = get_current_config()
278
+ if config:
279
+ print("\n📦 Current Mirror Configuration:")
280
+ print("-" * 40)
281
+ for key, value in config.items():
282
+ print(f" • {key}: {value}")
283
+ print()
284
+ else:
285
+ print("\n📦 No mirror configured")
286
+ print(" Run 'multi-lang-build mirror set <type> <mirror>' to configure")
287
+ print()
288
+ print_mirrors()
289
+ else:
290
+ mirror_parser.print_help()
291
+
292
+ elif parsed_args.language == "register":
293
+ from multi_lang_build.register import register_skill
294
+
295
+ success = register_skill(parsed_args.ide)
296
+ if success:
297
+ print("\n✅ Registration completed successfully!")
298
+ print(f"\nYou can now use 'multi-lang-build' commands in {parsed_args.ide}")
299
+ else:
300
+ print("\n❌ Registration failed for some IDEs.")
301
+ sys.exit(0 if success else 1)
302
+
303
+ else:
304
+ parser.print_help()
305
+ sys.exit(1)
306
+
307
+ if result is not None and result["success"]:
308
+ print(f"Build completed successfully in {result['duration_seconds']:.2f}s")
309
+ if result["output_path"]:
310
+ print(f"Output: {result['output_path']}")
311
+ sys.exit(0)
312
+ elif result is not None:
313
+ print(f"Build failed with code {result['return_code']}")
314
+ if result["stderr"]:
315
+ print(f"Error: {result['stderr']}")
316
+ sys.exit(1)
317
+
318
+ except Exception as e:
319
+ print(f"Error: {e}", file=sys.stderr)
320
+ sys.exit(2)
@@ -0,0 +1,22 @@
1
+ """Compiler module for auto-build tool."""
2
+
3
+ from multi_lang_build.compiler.base import (
4
+ BuildConfig,
5
+ BuildResult,
6
+ CompilerInfo,
7
+ CompilerBase,
8
+ )
9
+
10
+ from multi_lang_build.compiler.pnpm import PnpmCompiler
11
+ from multi_lang_build.compiler.go import GoCompiler
12
+ from multi_lang_build.compiler.python import PythonCompiler
13
+
14
+ __all__ = [
15
+ "BuildConfig",
16
+ "BuildResult",
17
+ "CompilerInfo",
18
+ "CompilerBase",
19
+ "PnpmCompiler",
20
+ "GoCompiler",
21
+ "PythonCompiler",
22
+ ]