|
1 | | -import os |
2 | | -os.environ.setdefault("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes") |
3 | | -if os.environ.get("PYTHON_JULIACALL_HANDLE_SIGNALS") != "yes": |
4 | | - print("Experimental JuliaCall REPL requires PYTHON_JULIACALL_HANDLE_SIGNALS=yes") |
5 | | - exit(1) |
| 1 | +from juliacall.repl import run_repl |
6 | 2 |
|
7 | | -import argparse |
8 | | -from pathlib import Path |
9 | | -parser = argparse.ArgumentParser("JuliaCall REPL (experimental)") |
10 | | -parser.add_argument('--banner', choices=['yes', 'no', 'short'], default='yes', help='Enable or disable startup banner') |
11 | | -parser.add_argument('--quiet', '-q', action='store_true', help='Quiet startup: no banner, suppress REPL warnings') |
12 | | -parser.add_argument('--history-file', choices=['yes', 'no'], default='yes', help='Load or save history') |
13 | | -parser.add_argument('--preamble', type=Path, help='Code to be included before the REPL starts') |
14 | | -args = parser.parse_args() |
15 | | - |
16 | | -from juliacall import Main, Base |
17 | | - |
18 | | -Base.is_interactive = True |
19 | | - |
20 | | -if not args.quiet: |
21 | | - Main.include(os.path.join(os.path.dirname(__file__), 'banner.jl')) |
22 | | - Main.__PythonCall_banner(Base.Symbol(args.banner)) |
23 | | - |
24 | | -if Main.seval(r'VERSION > v"v1.11.0-alpha1"'): |
25 | | - no_banner_opt = Base.Symbol("no") |
26 | | -else: |
27 | | - no_banner_opt = False |
28 | | - |
29 | | -if args.preamble: |
30 | | - Main.include(str(args.preamble.resolve())) |
31 | | - |
32 | | -Base.run_main_repl( |
33 | | - Base.is_interactive, |
34 | | - args.quiet, |
35 | | - no_banner_opt, |
36 | | - args.history_file == 'yes', |
37 | | - True |
38 | | -) |
| 3 | +if __name__ == '__main__': |
| 4 | + run_repl() |
0 commit comments