Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Go bindings to the CPython-3 API

License

NotificationsYou must be signed in to change notification settings

go-python/cpy3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

relation toDataDog/go-python3

This project is a community maintained successor toDataDog/go-python3, which will get archived in December 2021.

  • If you use the Go packagegithub.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 onDataDog/go-python3, please re-submit them here.

relation tosbinet/go-python

This project was inspired bysbinet/go-python (Go bindings for the CPython-2 C-API).

Install

Deps

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.

Go get

Then simplygo get github.com/go-python/cpy3

API

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.

Contributing

Contributions are welcome! Seedetails.

Community

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

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go90.8%
  • C9.1%
  • Python0.1%

[8]ページ先頭

©2009-2025 Movatter.jp