26
26
"""
27
27
28
28
import difflib
29
+ import json
29
30
import logging
30
31
import os
32
+ import platform
33
+ import subprocess
31
34
import sys
32
35
33
36
from pathlib import Path
@@ -237,6 +240,34 @@ def prompt_yesno() -> bool:
237
240
print ("Please respond with 'y' or 'n'" )
238
241
239
242
243
+ def get_system_info ():
244
+ system_info = {
245
+ "os" : platform .system (),
246
+ "os_version" : platform .version (),
247
+ "architecture" : platform .machine (),
248
+ "python_version" : sys .version ,
249
+ "packages" : format_installed_packages (get_installed_packages ()),
250
+ }
251
+ return system_info
252
+
253
+
254
+ def get_installed_packages ():
255
+ try :
256
+ result = subprocess .run (
257
+ [sys .executable , "-m" , "pip" , "list" , "--format=json" ],
258
+ capture_output = True ,
259
+ text = True ,
260
+ )
261
+ packages = json .loads (result .stdout )
262
+ return {pkg ["name" ]: pkg ["version" ] for pkg in packages }
263
+ except Exception as e :
264
+ return str (e )
265
+
266
+
267
+ def format_installed_packages (packages ):
268
+ return "\n " .join ([f"{ name } : { version } " for name , version in packages .items ()])
269
+
270
+
240
271
@app .command (
241
272
help = """
242
273
GPT-engineer lets you:
@@ -331,6 +362,11 @@ def main(
331
362
"--no_execution" ,
332
363
help = "Run setup but to not call LLM or write any code. For testing purposes." ,
333
364
),
365
+ sysinfo : bool = typer .Option (
366
+ False ,
367
+ "--sysinfo" ,
368
+ help = "Output system information for debugging" ,
369
+ ),
334
370
):
335
371
"""
336
372
The main entry point for the CLI tool that generates or improves a project.
@@ -371,6 +407,8 @@ def main(
371
407
Flag indicating whether to enable verbose logging.
372
408
no_execution: bool
373
409
Run setup but to not call LLM or write any code. For testing purposes.
410
+ sysinfo: bool
411
+ Flag indicating whether to output system information for debugging.
374
412
375
413
Returns
376
414
-------
@@ -382,6 +420,12 @@ def main(
382
420
383
421
sys .excepthook = lambda * _ : pdb .pm ()
384
422
423
+ if sysinfo :
424
+ sys_info = get_system_info ()
425
+ for key , value in sys_info .items ():
426
+ print (f"{ key } : { value } " )
427
+ raise typer .Exit ()
428
+
385
429
# Validate arguments
386
430
if improve_mode and (clarify_mode or lite_mode ):
387
431
typer .echo ("Error: Clarify and lite mode are not compatible with improve mode." )
0 commit comments