Golang bindings for the C-API of CPython-3.
This package provides a
go package named "python" under which most of the
PyXYZ functions and macros of the public C-API of CPython have been
exposed. Theoretically, you should be able use https://docs.python.org/3/c-api
and know what to type in your
Currently supports python-3.7+.
This project was inspired by https://github.com/sbinet/go-python. Go and take a look if we need something for python-2.7!
go get github.com/DataDog/go-python3
We will need
pkg-config and a working
python3 environment to build these bindings. By default
pkg-config will look at the
python3 library so if you want to choose a specific version just symlink
python3.pc or use the
PKG_CONFIG_PATH environment variable.
Some functions mix go code and call to Python function. Those functions will
error type. The
int represent the Python result code
error represent any issue from the Go layer.
func PyRun_AnyFile(filename string) open
filename and then call CPython API
int PyRun_AnyFile(FILE *fp, const char *filename).
Therefore its signature is
func PyRun_AnyFile(filename string) (int, error),
int represent the error code from the CPython
and error will be set if we failed to open
If an error is raise before calling th CPython function
int default to
Take a look at some examples