general.go 343 B

1234567891011121314151617181920212223242526
  1. package python
  2. // See:
  3. // https://docs.python.org/3/c-api/init.html
  4. /*
  5. #define PY_SSIZE_T_CLEAN
  6. #include <Python.h>
  7. */
  8. import "C"
  9. func Initialize() {
  10. C.Py_Initialize()
  11. }
  12. func Finalize() error {
  13. if C.Py_FinalizeEx() == 0 {
  14. return nil
  15. } else {
  16. return GetError()
  17. }
  18. }
  19. func Version() string {
  20. return C.GoString(C.Py_GetVersion())
  21. }