From 9c83d3f7c361df652e3c335f08dbde5593387836 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Sun, 19 Jun 2022 01:58:22 -0700 Subject: [PATCH] update support matrix, add setup.py example in README, gofmt files. --- README.md | 8 ++++++++ SUPPORT_MATRIX.md | 1 + _examples/cpkg/run.go | 1 + _examples/variadic/variadic.go | 20 ++++++++++++-------- bind/gen_func.go | 4 ++-- main_darwin.go | 1 + main_unix.go | 1 + main_unix_test.go | 1 + main_windows_test.go | 1 + 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cd695f6..ca00c93 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,14 @@ $ docker run -it --rm go-python/gopy To know what features are supported on what backends, please refer to the [Support matrix ](https://github.com/go-python/gopy/blob/master/SUPPORT_MATRIX.md). +## setup.py + +Here's an example for how to use `setup.py` with gopy to make an installable package: +https://github.com/natun-ai/labsdk/blob/master/setup.py + +Also, see this for cross-platform build: +https://github.com/natun-ai/labsdk/blob/master/.github/workflows/wheels.yaml + ## Troubleshooting ### python version mismatches diff --git a/SUPPORT_MATRIX.md b/SUPPORT_MATRIX.md index 5e473e0..f23c8f6 100644 --- a/SUPPORT_MATRIX.md +++ b/SUPPORT_MATRIX.md @@ -29,4 +29,5 @@ _examples/sliceptr | yes | yes _examples/slices | yes | yes _examples/structs | yes | yes _examples/unicode | no | yes +_examples/variadic | no | yes _examples/vars | yes | yes diff --git a/_examples/cpkg/run.go b/_examples/cpkg/run.go index 85bd647..f95d10c 100644 --- a/_examples/cpkg/run.go +++ b/_examples/cpkg/run.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ignore // +build ignore package main diff --git a/_examples/variadic/variadic.go b/_examples/variadic/variadic.go index dce6447..113ddf4 100644 --- a/_examples/variadic/variadic.go +++ b/_examples/variadic/variadic.go @@ -1,7 +1,11 @@ +// Copyright 2022 The go-python Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package variadic /////////////// Non Variadic ////////////// -func NonVariFunc(arg1 int, arg2 []int, arg3 int) int{ +func NonVariFunc(arg1 int, arg2 []int, arg3 int) int { total := arg1 for _, num := range arg2 { total += num @@ -12,7 +16,7 @@ func NonVariFunc(arg1 int, arg2 []int, arg3 int) int{ } /////////////// Variadic Over Int ////////////// -func VariFunc(vargs ...int) int{ +func VariFunc(vargs ...int) int { total := 0 for _, num := range vargs { total += num @@ -26,15 +30,15 @@ type IntStrUct struct { } func NewIntStrUct(n int) IntStrUct { - return IntStrUct { - p:n, + return IntStrUct{ + p: n, } -} +} -func VariStructFunc(vargs ...IntStrUct) int{ +func VariStructFunc(vargs ...IntStrUct) int { total := 0 for _, inst := range vargs { - total += inst.p + total += inst.p } return total } @@ -48,7 +52,7 @@ func (is *IntStrUct) Number() int { return is.p } -func VariInterFaceFunc(vargs ...IntInterFace) int{ +func VariInterFaceFunc(vargs ...IntInterFace) int { total := 0 for _, inst := range vargs { total += inst.Number() diff --git a/bind/gen_func.go b/bind/gen_func.go index 991165f..adcffe1 100644 --- a/bind/gen_func.go +++ b/bind/gen_func.go @@ -100,7 +100,7 @@ func (g *pyGen) genFuncSig(sym *symbol, fsym *Func) bool { } } - if i!=nargs-1 || !fsym.isVariadic { + if i != nargs-1 || !fsym.isVariadic { wpArgs = append(wpArgs, anm) } } @@ -303,7 +303,7 @@ if __err != nil { default: na = anm } - if i == len(args) - 1 && fsym.isVariadic { + if i == len(args)-1 && fsym.isVariadic { na = na + "..." } callArgs = append(callArgs, na) diff --git a/main_darwin.go b/main_darwin.go index 8697476..5edc920 100644 --- a/main_darwin.go +++ b/main_darwin.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package main diff --git a/main_unix.go b/main_unix.go index fcd1871..1acf66f 100644 --- a/main_unix.go +++ b/main_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (linux && !android) || dragonfly || openbsd // +build linux,!android dragonfly openbsd package main diff --git a/main_unix_test.go b/main_unix_test.go index 8d0733a..0d709f7 100644 --- a/main_unix_test.go +++ b/main_unix_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package main diff --git a/main_windows_test.go b/main_windows_test.go index 07aac46..037b33a 100644 --- a/main_windows_test.go +++ b/main_windows_test.go @@ -1,6 +1,7 @@ // Copyright 2015 The go-python Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. + //go:build windows // +build windows