File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 11# runpythonvirtual
22It’s a basic Nim wrapper to run Python scripts with a hardcoded interpreter in the same shell while forwarding arguments transparently.
3+
4+ # 📜 Description of the Current Program
5+
6+ This Nim program is a simple Python launcher:
7+
8+ ### Hardcoded Executable Path
9+
10+ The path to the Python interpreter inside the virtual environment is written directly into the code.
11+
12+ ```
13+ Example (Windows):
14+
15+ const exePath = r"C:\Programs\PythonVirtualEnv\tuivirtual\Scripts\python.exe"
16+ ```
17+
18+ ### Command-Line Argument Forwarding
19+
20+ When you run the Nim program with arguments, it forwards them to the Python executable.
21+
22+ ```
23+ Example:
24+
25+ runpython.exe myscript.py arg1 arg2
26+ ```
27+
28+ internally runs:
29+ ```
30+ C:\Programs\PythonVirtualEnv\tuivirtual\Scripts\python.exe myscript.py arg1 arg2
31+ ```
32+
33+ ### Process Execution in Current Shell
34+
35+ - It uses ``` startProcess(exePath, args=args, options={poParentStreams}) ``` .
36+
37+ - This runs the Python script inside the same shell session as the Nim program, sharing stdin/stdout/stderr.
38+
39+ - That means no new window/terminal is opened; it just executes inline.
40+
41+ ### Output Handling
42+
43+ - Because {poParentStreams} is used, all Python output is visible in the same console window.
44+
45+ - The program waits for Python to finish, then prints "Process finished.".
46+
47+ ### ⚡ Example Run
48+ ```
49+ nim c -r runpython.nim myscript.py
50+ ```
You can’t perform that action at this time.
0 commit comments