pyg

package
v0.0.0-...-42b9eaa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CFree

func CFree[T comparable](obj *T)

func CInt2Bool

func CInt2Bool(obj Cint) bool

CInt2Bool

Translate a C type integer into a boolean.

func WString2String

func WString2String(value CPyWideString) string

WString2String

Translate a wide char string into a Go string.

Types

type CFILE

type CFILE = C.FILE

type CPyCompilerFlags

type CPyCompilerFlags = C.PyCompilerFlags

type CPyConfig

type CPyConfig = C.CGO_PyConfig

type CPyObject

type CPyObject = C.PyObject

type CPyPreConfig

type CPyPreConfig = C.CGO_PyPreConfig

type CPySSizeT

type CPySSizeT = C.Py_ssize_t

type CPyStatus

type CPyStatus = C.PyStatus

type CPyWideString

type CPyWideString = *C.wchar_t

func String2WideString

func String2WideString(value string) CPyWideString

String2WideString

Translate a Go string into a wide char string.

type CPyWideStringList

type CPyWideStringList = C.PyWideStringList

type Cchar

type Cchar = C.char

type Cint

type Cint = C.int

func Bool2CInt

func Bool2CInt(obj bool) Cint

Translate a boolean to a C type integer.

type Clong

type Clong = C.long

type Cvoid

type Cvoid = C.void

type Cwchar

type Cwchar = C.wchar_t

type PyArtifact

type PyArtifact[T comparable] struct {
	// Internal C object that this artifact points
	// to/represents.
	CInstance T
	// contains filtered or unexported fields
}

Representative object of some object from the Python CAPI. Allows for related CPython methods to grouped under an object in Go per the object (or objects) they modify.

type PyConfig

type PyConfig struct {
	PyArtifact[CPyConfig]
	CInstance       CPyConfig
	CInstanceMapped bool
	CPyConfig
}

func ConfigNew

func ConfigNew() *PyConfig

Initialize a new Go PyConfig object.

func (*PyConfig) Clear

func (config *PyConfig) Clear()

Release configuration memory. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_Clear

func (*PyConfig) InitIsolatedConfig

func (config *PyConfig) InitIsolatedConfig()

Initialize configuration with the isolated configuration. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_InitIsolatedConfig

func (*PyConfig) InitPythonConfig

func (config *PyConfig) InitPythonConfig()

Initialize configuration with the Python configuration. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_InitPythonConfig

func (*PyConfig) Read

func (config *PyConfig) Read() PyStatus

Read all Python configuration. Fields which are already initialized are left unchanged. Fields for path configuration are no longer calculated or modified when calling this function, as of Python 3.11.

The PyConfig_Read function only parses `PyConfig.argv` arguments once: `PyConfig.parse_argv` is set to 2 after arguments are parsed. Since Python arguments are stripped from `PyConfig.argv`, parsing arguments twice would parse the application options as Python options. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_Read

func (*PyConfig) SetArgv

func (config *PyConfig) SetArgv(argv []CPyWideString) PyStatus

Set command line arguments. (argv member of config) from the argv list of wide character strings https://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetArgv

func (*PyConfig) SetBoolean

func (config *PyConfig) SetBoolean(prop *Cint, val bool) PyStatus

Set property as boolean.

func (*PyConfig) SetBytesArgv

func (config *PyConfig) SetBytesArgv(argv []string) PyStatus

Set command line arguments (argv member of config) from the argv list of bytes strings. Decode bytes using Py_DecodeLocale(). https://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetBytesArgv

func (*PyConfig) SetBytesString

func (config *PyConfig) SetBytesString(
	configStr *CPyWideString, str string) PyStatus

Decode str using Py_DecodeLocale() and set the result into configStr. Preinitialize Python if needed. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetBytesString

func (*PyConfig) SetInteger

func (config *PyConfig) SetInteger(prop *Cint, val int) PyStatus

Set property as integer.

func (*PyConfig) SetString

func (config *PyConfig) SetString(
	prop *CPyWideString, val CPyWideString) PyStatus

Copy wide character string into configStr. Preinitialize Python if needed. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetString

func (*PyConfig) SetWideStringList

func (config *PyConfig) SetWideStringList(
	list *CPyWideStringList,
	items []CPyWideString) PyStatus

Set the list of wide strings list to length and items. Preinitialize Python if needed. https://docs.python.org/3/c-api/init_config.html#c.PyConfig_SetWideStringList

type PyPreConfig

type PyPreConfig struct {
	PyArtifact[CPyPreConfig]
	CInstance       CPyPreConfig
	CInstanceMapped bool
	CPyPreConfig
}

func PreConfigNew

func PreConfigNew() *PyPreConfig

Initialize a new Go PyPreConfig object.

func (*PyPreConfig) Clear

func (config *PyPreConfig) Clear()

Free any memory associated with preconfig.

func (*PyPreConfig) InitIsolatedConfig

func (config *PyPreConfig) InitIsolatedConfig()

Initialize the preconfiguration with Isolated Configuration. https://docs.python.org/3/c-api/init_config.html#c.PyPreConfig_InitIsolatedConfig

func (*PyPreConfig) InitPythonConfig

func (config *PyPreConfig) InitPythonConfig()

Initialize the preconfiguration with Python Configuration. https://docs.python.org/3/c-api/init_config.html#c.PyPreConfig_InitPythonConfig

func (*PyPreConfig) SetBoolean

func (config *PyPreConfig) SetBoolean(prop *Cint, val bool) PyStatus

Set property as boolean.

func (*PyPreConfig) SetInteger

func (config *PyPreConfig) SetInteger(prop *Cint, val int) PyStatus

Set property as integer.

type PyStatus

type PyStatus PyArtifact[CPyStatus]

func StatusError

func StatusError(err string) PyStatus

Initialize an error PyStatus. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_Error

func StatusExit

func StatusExit(code int) PyStatus

Initialize a PyStatus with an exit code. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_Exit

func StatusNew

func StatusNew(cStatus CPyStatus) PyStatus

Initialize a new instance of `PyStatus`.

func StatusNoMemory

func StatusNoMemory() PyStatus

Initialize an allocation failure PyStatus. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_NoMemory

func StatusOk

func StatusOk() PyStatus

Initialize a success PyStatus. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_Ok

func (*PyStatus) ErrMessage

func (status *PyStatus) ErrMessage() string

The error message. https://docs.python.org/3/c-api/init_config.html#c.PyStatus.err_msg

func (*PyStatus) ExitCode

func (status *PyStatus) ExitCode() int

The exit code. https://docs.python.org/3/c-api/init_config.html#c.PyStatus.exitcode

func (*PyStatus) ExitStatusException

func (status *PyStatus) ExitStatusException()

Display exception message and exit the process.

func (*PyStatus) FuncName

func (status *PyStatus) FuncName() string

The name of the function which created an error. https://docs.python.org/3/c-api/init_config.html#c.PyStatus.func

func (*PyStatus) IsError

func (status *PyStatus) IsError() bool

Check if status is an error. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_IsError

func (*PyStatus) IsException

func (status *PyStatus) IsException() bool

Check if a status is an exception or exit status. Must be handled if the result is true. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_Exception

func (*PyStatus) IsExit

func (status *PyStatus) IsExit() bool

Check if status has an exit code. https://docs.python.org/3/c-api/init_config.html#c.PyStatus_IsExit

type Pyg

type Pyg struct {
	PreConfig *PyPreConfig
	Config    *PyConfig
}

func PygNew

func PygNew(config *PyConfig, preconfig *PyPreConfig) *Pyg

PygNew

Get a new instance of Python interpreter with preset config and preconfig objects.

func PygNewIsolated

func PygNewIsolated() *Pyg

PygNewIsolated

Get a new isolated instance of Python interpreter.

func PygNewPython

func PygNewPython() *Pyg

PygNewPython

Get a new instance of Python interpreter.

func (*Pyg) FinalizeEx

func (pygi *Pyg) FinalizeEx() int

FinalizeEx

Undo all initializations made by Py_Initialize() and subsequent use of Python/C API functions, and destroy all sub-interpreters (see Py_NewInterpreter() below) that were created and not yet destroyed since the last call to Py_Initialize(). https://docs.python.org/3/c-api/init.html#c.Py_FinalizeEx

func (*Pyg) GetBuildInfo

func (pygi *Pyg) GetBuildInfo() string

GetBuildInfo

Return information about the sequence number and build date and time of the current Python interpreter. https://docs.python.org/3/c-api/init.html#c.Py_GetBuildInfo

func (*Pyg) GetCompiler

func (pygi *Pyg) GetCompiler() string

GetCompiler

Return an indication of the compiler used to build the current Python version. https://docs.python.org/3/c-api/init.html#c.Py_GetCompiler

func (*Pyg) GetCopyright

func (pygi *Pyg) GetCopyright() string

GetCopyright

Return the official copyright for the current Python version. https://docs.python.org/3/c-api/init.html#c.Py_GetCopyright

func (*Pyg) GetExecPrefix

func (pygi *Pyg) GetExecPrefix() (string, error)

GetExecPrefix

Return the exec-prefix for installed platform-dependent files. https://docs.python.org/3/c-api/init.html#c.Py_GetExecPrefix

func (*Pyg) GetPath

func (pygi *Pyg) GetPath() (string, error)

GetPath

Return the default module search path. https://docs.python.org/3/c-api/init.html#c.Py_GetPath

func (*Pyg) GetPlatform

func (pygi *Pyg) GetPlatform() string

GetPlatform

Return the platform identifier for the current platform. https://docs.python.org/3/c-api/init.html#c.Py_GetPlatform

func (*Pyg) GetPrefix

func (pygi *Pyg) GetPrefix() (string, error)

GetPrefix

Return the prefix for installed platform-independent files. https://docs.python.org/3/c-api/init.html#c.Py_GetPrefix

func (*Pyg) GetProgramFullPath

func (pygi *Pyg) GetProgramFullPath() (string, error)

GetProgramFullPath

Return the full program name of the Python executable. https://docs.python.org/3/c-api/init.html#c.Py_GetProgramFullPath

func (*Pyg) GetProgramName

func (pygi *Pyg) GetProgramName() (string, error)

GetProgramName

Return the program name set by Python configuration. https://docs.python.org/3/c-api/init.html#c.Py_GetProgramName

func (*Pyg) GetPythonHome

func (pygi *Pyg) GetPythonHome() (string, error)

GetPythonHome

Return the default "home", that is, the value set by configuration. https://docs.python.org/3/c-api/init.html#c.Py_GetPythonHome

func (*Pyg) GetVersion

func (pygi *Pyg) GetVersion() string

GetVersion

Return the version of this Python interpreter. https://docs.python.org/3/c-api/init.html#c.Py_GetVersion

func (*Pyg) InitializeFromConfig

func (pygi *Pyg) InitializeFromConfig() PyStatus

InitializeFromConfig

Initialize Python from config configuration. https://docs.python.org/3/c-api/init_config.html#c.Py_InitializeFromConfig

func (*Pyg) IsInitialized

func (pygi *Pyg) IsInitialized() bool

IsInitialized

Whether the Python interpreter has been initialized or not. https://docs.python.org/3/c-api/init.html#c.Py_IsInitialized

func (*Pyg) PreInitialize

func (pygi *Pyg) PreInitialize() PyStatus

PreInitialize

Preinitialize Python from preconfig preconfiguration. https://docs.python.org/3/c-api/init_config.html#c.Py_PreInitialize

func (*Pyg) PreInitializeFromArgs

func (pygi *Pyg) PreInitializeFromArgs(argv []CPyWideString) PyStatus

PreInitializeFromArgs

Preinitialize Python from preconfig preconfiguration. Parse argv command line arguments (wide strings) if parse_argv of PyPreConfig is non-zero. https://docs.python.org/3/c-api/init_config.html#c.Py_PreInitializeFromArgs

func (*Pyg) PreInitializeFromBytesArgs

func (pygi *Pyg) PreInitializeFromBytesArgs(argv []string) PyStatus

PreInitializeFromBytesArgs

Preinitialize Python from preconfig preconfiguration. Parse argv command line arguments (bytes strings) if parse_argv of PyPreConfig is non-zero. https://docs.python.org/3/c-api/init_config.html#c.Py_PreInitializeFromBytesArgs

func (*Pyg) RunFile

func (pygi *Pyg) RunFile(fileName string) (int, error)

RunFile

This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving closeit set to 0 and flags set to NULL. https://docs.python.org/3/c-api/veryhigh.html?highlight=pyrun_#c.PyRun_SimpleFile

func (*Pyg) RunMain

func (pygi *Pyg) RunMain() (int, error)

RunMain

Execute the command (PyConfig.run_command), the script (PyConfig.run_filename) or the module (PyConfig.run_module) specified on the command line or in the configuration. https://docs.python.org/3/c-api/init_config.html#c.Py_RunMain

func (*Pyg) RunString

func (pygi *Pyg) RunString(str string) (int, error)

RunString

This is a simplified interface to PyRun_SimpleStringFlags() below, leaving the PyCompilerFlags* argument set to NULL. https://docs.python.org/3/c-api/veryhigh.html?highlight=pyrun_#c.PyRun_SimpleString

func (*Pyg) SetConfigArgv

func (pygi *Pyg) SetConfigArgv(argv []string) PyStatus

SetConfigArgv

Set arguments list of this internal config.

func (*Pyg) SetConfigBoolean

func (pygi *Pyg) SetConfigBoolean(prop *Cint, value bool) PyStatus

SetConfigBoolean

Set an integer config property as a boolean.

func (*Pyg) SetConfigInteger

func (pygi *Pyg) SetConfigInteger(prop *Cint, value int) PyStatus

SetConfigInteger

Set an integer config property.

func (*Pyg) SetConfigString

func (pygi *Pyg) SetConfigString(prop *CPyWideString, value string) PyStatus

SetConfigString

Set a string config property.

func (*Pyg) SetPreConfigBoolean

func (pygi *Pyg) SetPreConfigBoolean(prop *Cint, value bool) PyStatus

SetPreConfigBoolean

Set an integer preconfig property as a boolean.

func (*Pyg) SetPreConfigInteger

func (pygi *Pyg) SetPreConfigInteger(prop *Cint, value int) PyStatus

SetPreConfigInteger

Set an integer preconfig property.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL