{"id":13366354,"url":"https://github.com/sbinet/Go-python","last_synced_at":"2025-03-12T18:30:56.577Z","repository":{"id":52910039,"uuid":"4960374","full_name":"sbinet/go-python","owner":"sbinet","description":"naive go bindings to the CPython2 C-API","archived":true,"fork":false,"pushed_at":"2023-07-24T07:11:30.000Z","size":193,"stargazers_count":1528,"open_issues_count":27,"forks_count":139,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-02-09T10:30:41.398Z","etag":null,"topics":["cgo","go","golang","python2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbinet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2012-07-09T15:43:31.000Z","updated_at":"2025-01-22T08:24:57.000Z","dependencies_parsed_at":"2024-01-30T04:55:46.284Z","dependency_job_id":null,"html_url":"https://github.com/sbinet/go-python","commit_stats":{"total_commits":158,"total_committers":18,"mean_commits":8.777777777777779,"dds":0.5759493670886076,"last_synced_commit":"d6ca9f284dab685f42c80cd635ef9169aa5f2afc"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbinet%2Fgo-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbinet%2Fgo-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbinet%2Fgo-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbinet%2Fgo-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbinet","download_url":"https://codeload.github.com/sbinet/go-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243271158,"owners_count":20264402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","go","golang","python2"],"created_at":"2024-07-30T00:01:23.608Z","updated_at":"2025-03-12T18:30:56.286Z","avatar_url":"https://github.com/sbinet.png","language":"Go","funding_links":[],"categories":["嵌入式脚本语言","嵌入式腳本語言"],"sub_categories":["高级控制台界面","高級控制台界面"],"readme":"go-python\n=========\n\n**`sbinet/go-python` only supports CPython2. CPython2 isn't supported anymore by [python.org](https://python.org). Thus, `sbinet/go-python` is now archived.**\n**A possible alternative may be to use and contribute to [go-python/cpy3](https://github.com/go-python/cpy3) instead.**\n\n[![Build Status](https://travis-ci.org/sbinet/go-python.svg?branch=master)](https://travis-ci.org/sbinet/go-python)\n[![Build status](https://ci.appveyor.com/api/projects/status/n0ujg8no487a89vo/branch/master?svg=true)](https://ci.appveyor.com/project/sbinet/go-python/branch/master)\n[![GoDocs](https://godocs.io/github.com/sbinet/go-python?status.svg)](https://godocs.io/github.com/sbinet/go-python)\n\nNaive `go` bindings towards the C-API of CPython-2.\n\nthis 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.\n\ntheoretically, you should be able to just look at:\n\n  http://docs.python.org/c-api/index.html\n\nand know what to type in your ``go`` program.\n\n\nthis package also provides an executable \"go-python\" which just loads \"python\" and then call ``python.Py_Main(os.Args)``.\nthe rational being that under such an executable, ``go`` based extensions for C-Python would be easier to implement (as this usually means calling into ``go`` from ``C`` through some rather convoluted functions hops)\n\n\n## Install\n\nWith `Go 1` and the ``go`` tool, ``cgo`` packages can't pass anymore\nadditional ``CGO_CFLAGS`` from external programs (except `pkg-config`)\nto the \"fake\" ``#cgo`` preprocessor directive.\n\n``go-python`` now uses ``pkg-config`` to get the correct location of\nheaders and libraries.\nUnfortunately, the naming convention for the ``pkg-config`` package is\nnot standardised across distributions and OSes, so you may have to\nedit the ``cgoflags.go`` file accordingly.\n\n```sh\n $ go get github.com/sbinet/go-python\n```\n\nIf ``go get`` + ``pkg-config`` failed:\n\n```sh\n $ cd go-python\n $ edit cgoflags.go\n $ make VERBOSE=1\n```\n\n*Note*: you'll need the proper header and `python` development environment. On Debian, you'll need to install the ``python-all-dev`` package\n\nDocumentation\n-------------\n\nIs available on ``godocs``:\n\n https://godocs.io/github.com/sbinet/go-python\n\n\nExample:\n--------\n\n```go\npackage main\n\nimport \"fmt\"\nimport \"github.com/sbinet/go-python\"\n\nfunc init() {\n   err := python.Initialize()\n   if err != nil {\n          panic(err.Error())\n   } \n}\n\nfunc main() {\n \t gostr := \"foo\" \n\t pystr := python.PyString_FromString(gostr)\n\t str := python.PyString_AsString(pystr)\n\t fmt.Println(\"hello [\", str, \"]\")\n}\n```\n\n```sh\n$ go run ./main.go\nhello [ foo ]\n```\n\nTODO:\n-----\n\n - fix handling of integers (I did a poor job at making sure everything was ok)\n\n - add CPython unit-tests\n\n - do not expose ``C.FILE`` pointer and replace it with ``os.File`` in \"go-python\" API\n\n - provide an easy way to extend go-python with ``go`` based extensions\n\n - think about the need (or not) to translate CPython exceptions into go panic/recover mechanism\n\n - use SWIG to automatically wrap the whole CPython api ?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbinet%2FGo-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbinet%2FGo-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbinet%2FGo-python/lists"}