- Notifications
You must be signed in to change notification settings - Fork53
Go bindings to the CPython-3 API
License
go-python/cpy3
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Currently supports python-3.7 only.
This package provides ago
package named "python" under which most of thePyXYZ
functions and macros of the public C-API of CPython have beenexposed. Theoretically, you should be able usehttps://docs.python.org/3/c-apiand know what to type in yourgo
program.
This project is a community maintained successor toDataDog/go-python3
, which will get archived in December 2021.
- If you use the Go package
github.com/DataDog/go-python3
in your code, you can usegithub.com/go-python/cpy3
as a drop-in replacement. We intend to not introduce breaking changes. - If you have unmerged PRs or open issues on
DataDog/go-python3
, please re-submit them here.
This project was inspired bysbinet/go-python
(Go bindings for the CPython-2 C-API).
We will needpkg-config
and a workingpython3.7
environment to build thesebindings. Make sure you have Python libraries and header files installed aswell (python3.7-dev
on Debian orpython3-devel
on Centos for example)..
By defaultpkg-config
will look at thepython3
library so if you want tochoose a specific version just symlinkpython-X.Y.pc
topython3.pc
or usethePKG_CONFIG_PATH
environment variable.
Then simplygo get github.com/go-python/cpy3
Some functions mix go code and call to Python function. Those functions willreturn andint
anderror
type. Theint
represent the Python result codeand theerror
represent any issue from the Go layer.
Example:
func PyRun_AnyFile(filename string)
openfilename
and then call CPython APIfunctionint PyRun_AnyFile(FILE *fp, const char *filename)
.
Therefore its signature isfunc PyRun_AnyFile(filename string) (int, error)
,theint
represent the error code from the CPythonPyRun_AnyFile
functionand error will be set if we failed to openfilename
.
If an error is raise before calling th CPython functionint
default to-1
.
Take a look at someexamples and thistutorial blogpost.
Contributions are welcome! Seedetails.
Find us in#go-python
onGophers Slack. (infos |invite)
This project follows theGo Community Code of Conduct.
About
Go bindings to the CPython-3 API
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- Go90.8%
- C9.1%
- Python0.1%