diff --git a/README.md b/README.md index 11e7ac3..f99ac02 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ go-python [![Build Status](https://drone.io/github.com/sbinet/go-python/status.png)](https://drone.io/github.com/sbinet/go-python/latest) -Naive `go` bindings towards the C-API of CPython-2. +Naive `go` bindings towards the C-API of CPython-3. this 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. @@ -31,13 +31,13 @@ not standardised across distributions and OSes, so you may have to edit the ``cgoflags.go`` file accordingly. ```sh - $ go get github.com/sbinet/go-python + $ go get github.com/willATgithub/go-python3 ``` If ``go get`` + ``pkg-config`` failed: ```sh - $ cd go-python + $ cd go-python3 $ edit cgoflags.go $ make VERBOSE=1 ``` @@ -59,17 +59,17 @@ Example: package main import "fmt" -import "github.com/sbinet/go-python" +import "github.com/willATgithub/go-python3" func init() { err := python.Initialize() if err != nil { panic(err.Error()) - } + } } func main() { - gostr := "foo" + gostr := "foo" pystr := python.PyString_FromString(gostr) str := python.PyString_AsString(pystr) fmt.Println("hello [", str, "]") @@ -88,9 +88,9 @@ TODO: - add CPython unit-tests - - do not expose ``C.FILE`` pointer and replace it with ``os.File`` in "go-python" API + - do not expose ``C.FILE`` pointer and replace it with ``os.File`` in "go-python3" API - - provide an easy way to extend go-python with ``go`` based extensions + - provide an easy way to extend go-python3 with ``go`` based extensions - think about the need (or not) to translate CPython exceptions into go panic/recover mechanism diff --git a/capi.go b/capi.go index 2d8d777..a4765ea 100644 --- a/capi.go +++ b/capi.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" // PyObject* Py_BuildValue(const char *format, ...) diff --git a/cgoflags.go b/cgoflags.go index 5f1f0fa..5d67795 100644 --- a/cgoflags.go +++ b/cgoflags.go @@ -1,7 +1,7 @@ package python -// #cgo pkg-config: python-2.7 -// #include "go-python.h" +// #cgo pkg-config: python-3.7 +// #include "go-python3.h" import "C" // EOF diff --git a/cmd/go-python/main.go b/cmd/go-python3/main.go similarity index 100% rename from cmd/go-python/main.go rename to cmd/go-python3/main.go diff --git a/dict.go b/dict.go index 8a27457..240151d 100644 --- a/dict.go +++ b/dict.go @@ -1,6 +1,6 @@ package python -//#include "go-python.h" +//#include "go-python3.h" import "C" import ( diff --git a/exceptions.go b/exceptions.go index 58dca1c..3e06fbd 100644 --- a/exceptions.go +++ b/exceptions.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" import ( diff --git a/exceptions_posix.go b/exceptions_posix.go index d98ab31..50a3775 100644 --- a/exceptions_posix.go +++ b/exceptions_posix.go @@ -2,7 +2,7 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" // int PySignal_SetWakeupFd(int fd) diff --git a/file.go b/file.go index 983ebe8..0b0897e 100644 --- a/file.go +++ b/file.go @@ -2,7 +2,7 @@ package python /* #include -#include "go-python.h" +#include "go-python3.h" PyObject* _gopy_PyFile_FromFile(int fd, char *name, char *mode) { diff --git a/go-python.c b/go-python3.c similarity index 100% rename from go-python.c rename to go-python3.c diff --git a/go-python.go b/go-python3.go similarity index 100% rename from go-python.go rename to go-python3.go diff --git a/go-python.h b/go-python3.h similarity index 100% rename from go-python.h rename to go-python3.h diff --git a/heap.go b/heap.go index d3a00a1..91cc331 100644 --- a/heap.go +++ b/heap.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" import ( diff --git a/init.go b/init.go index 7f1b485..9faf2a3 100644 --- a/init.go +++ b/init.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" // char *gopy_ProgName = NULL; // char *gopy_PythonHome = NULL; import "C" diff --git a/init_test.go b/init_test.go index f1e73ac..3fc30e0 100644 --- a/init_test.go +++ b/init_test.go @@ -3,7 +3,7 @@ package python_test import ( "testing" - python "github.com/sbinet/go-python" + python "github.com/willATgithub/go-python3" ) func TestProgramName(t *testing.T) { @@ -16,7 +16,7 @@ func TestProgramName(t *testing.T) { } func TestPythonHome(t *testing.T) { - const want = "/usr/lib/go-python" + const want = "/usr/lib/go-python3" python.Py_SetPythonHome(want) got := python.Py_GetPythonHome() if got != want { diff --git a/none.go b/none.go index 914899e..c76a41b 100644 --- a/none.go +++ b/none.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" // The Python None object, denoting lack of value. This object has no methods. diff --git a/numeric.go b/numeric.go index 31a2c2a..d3d9032 100644 --- a/numeric.go +++ b/numeric.go @@ -1,6 +1,6 @@ package python -//#include "go-python.h" +//#include "go-python3.h" import "C" import ( diff --git a/object.go b/object.go index 274fcfd..c6335ca 100644 --- a/object.go +++ b/object.go @@ -1,6 +1,6 @@ package python -//#include "go-python.h" +//#include "go-python3.h" import "C" import ( diff --git a/otherobjects.go b/otherobjects.go index 08ae445..b2419fa 100644 --- a/otherobjects.go +++ b/otherobjects.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" import ( diff --git a/python.go b/python.go index 1776e02..296fb95 100644 --- a/python.go +++ b/python.go @@ -1,7 +1,7 @@ // simplistic wrapper around the python C-API package python -//#include "go-python.h" +//#include "go-python3.h" import "C" import ( diff --git a/python_test.go b/python_test.go index 0adeb4e..217e3d9 100644 --- a/python_test.go +++ b/python_test.go @@ -11,10 +11,10 @@ import ( ) func TestGoPython(t *testing.T) { - cmd := exec.Command("go-python", "-c", "print 1+1") + cmd := exec.Command("go-python3", "-c", "print 1+1") err := cmd.Run() if err != nil { - t.Fatalf("go-python failed: %v", err) + t.Fatalf("go-python3 failed: %v", err) } } @@ -24,7 +24,7 @@ type pkg struct { } func testPkg(t *testing.T, table pkg) { - workdir, err := ioutil.TempDir("", "go-python-") + workdir, err := ioutil.TempDir("", "go-python3-") if err != nil { t.Fatalf("[%s]: could not create workdir: %v\n", table.path, err) } @@ -46,7 +46,7 @@ func testPkg(t *testing.T, table pkg) { err = cmd.Run() if err != nil { t.Fatalf( - "[%s]: error running go-python test: %v\n%v\n", + "[%s]: error running go-python3 test: %v\n%v\n", table.path, err, string(buf.Bytes()), @@ -77,7 +77,7 @@ func testPkg(t *testing.T, table pkg) { } } - t.Fatalf("[%s]: error running go-python test:\nwant:\n%s\n\ngot:\n%s\n%s", + t.Fatalf("[%s]: error running go-python3 test:\nwant:\n%s\n\ngot:\n%s\n%s", table.path, string(table.want), string(buf.Bytes()), diffTxt, diff --git a/sequence.go b/sequence.go index 54b6a91..3072caf 100644 --- a/sequence.go +++ b/sequence.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" import ( diff --git a/type.go b/type.go index 7d1989b..11817a3 100644 --- a/type.go +++ b/type.go @@ -1,6 +1,6 @@ package python -//#include "go-python.h" +//#include "go-python3.h" import "C" type PyTypeObject struct { diff --git a/utilities.go b/utilities.go index 8bdaed2..d1c009c 100644 --- a/utilities.go +++ b/utilities.go @@ -1,6 +1,6 @@ package python -// #include "go-python.h" +// #include "go-python3.h" import "C" import ( diff --git a/veryhigh.go b/veryhigh.go index b943e4a..47c08bd 100644 --- a/veryhigh.go +++ b/veryhigh.go @@ -1,6 +1,6 @@ package python -//#include "go-python.h" +//#include "go-python3.h" import "C" import (