#include "nrnpython.h"
#include "nrnpy_utils.h"
#include "oc_ansi.h"
#include <stdio.h>
#include <InterViews/resource.h>
#include <nrnoc2iv.h>
#include "hoccontext.h"
#include <ocfile.h>
#include <hocstr.h>
#include "nrnpy.h"
#include <filesystem>
#include <string>
#include <sstream>
#include <fstream>
#include <nanobind/nanobind.h>
Go to the source code of this file.
◆ neuronhome_forward()
char* neuronhome_forward |
( |
| ) |
|
◆ nrnmingw_pyrun_interactiveloop()
static int nrnmingw_pyrun_interactiveloop |
( |
| ) |
|
|
static |
Like a PyRun_InteractiveLoop that does not need a FILE* Use InteractiveConsole to work around the issue of mingw FILE* not being compatible with Python via the CAPI on windows11.
- Returns
- 0 on success, nonzero on failure.
Definition at line 166 of file nrnpython.cpp.
◆ nrnpy_hoc()
◆ nrnpy_nrn()
◆ nrnpy_pyrun()
int nrnpy_pyrun |
( |
const char * |
fname | ) |
|
Execute a Python script.
- Returns
- 0 on failure, 1 on success.
Definition at line 125 of file nrnpython.cpp.
◆ nrnpython_getline()
static char * nrnpython_getline |
( |
FILE * |
, |
|
|
FILE * |
, |
|
|
const char * |
prompt |
|
) |
| |
|
static |
◆ nrnpython_real()
static void nrnpython_real |
( |
| ) |
|
|
static |
Backend to nrnpython(...) in HOC/Python code.
This can be called both with nrniv and python as the top-level executable, with different code responsible for initialising Python in the two cases. We trust that Python was initialised correctly somewhere higher up the call stack.
Definition at line 383 of file nrnpython.cpp.
◆ nrnpython_reg_real_nrnpython_cpp()
◆ nrnpython_set_path()
static void nrnpython_set_path |
( |
std::string_view |
fname | ) |
|
|
static |
Reset sys.path to its value at initialisation and prepend fname.
Calling this with fname empty is appropriate ahead of executing code similar to python -c "..."
, if fname is non-empty then resolve symlinks in it and get the directory name – this is appropriate for python script.py
compatibility.
Definition at line 108 of file nrnpython.cpp.
◆ nrnpython_start()
static int nrnpython_start |
( |
int |
b | ) |
|
|
static |
Start the Python interpreter.
- b Mode of operation, can be 0 (finalize), 1 (initialize), or 2 (execute commands/scripts)
- Returns
- 0 on success, non-zero on error
There is an internal state variable that stores whether or not Python has been initialized. Mode 1 only has an effect if Python is not initialized, while the other modes only take effect if Python is already initialized.
Definition at line 192 of file nrnpython.cpp.
◆ python_sys_path_to_append()
static std::string python_sys_path_to_append |
( |
| ) |
|
|
static |
◆ hoc_cbufstr
◆ hoc_ctp
◆ hoc_fin
◆ hoc_promptstr
const char* hoc_promptstr |
|
extern |
◆ nrn_global_argc
◆ nrn_global_argv
◆ nrnpy_nositeflag
◆ nrnpy_pyexe
◆ p_nrnpy_pyrun
int(* p_nrnpy_pyrun) (const char *) |
( |
const char * |
fname | ) |
|
|
extern |