Skip to content

Commit 2a31e2f

Browse files
author
Randall C. O'Reilly
committed
make new args avail for all modes
1 parent 3b6fc61 commit 2a31e2f

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ An article was also posted on the [GopherAcademy Advent-2015](https://blog.gophe
7070
Documentation is available on [godoc](https://godoc.org):
7171
https://godoc.org/github.com/go-python/gopy
7272

73-
The `pkg` and `exe` commands are for end-users and create a full standalone python package that can be installed locally using `make install` based on the auto-generated `Makefile`. Theoretically these packages could be uploaded to https://pypi.org/ for wider distribution, but that would require a lot more work to handle all the different possible python versions and coordination with the Go source version, so it is much better to just do the local make install on your system. The `gen` and `build` commands are used for testing and just generate / build the raw binding files only.
73+
The `pkg` and `exe` commands are for end-users and create a full standalone python package that can be installed locally using `make install` based on the auto-generated `Makefile`. Theoretically these packages could be uploaded to https://pypi.org/ for wider distribution, but that would require a lot more work to handle all the different possible python versions and coordination with the Go source version, so it is easier to just do the local make install on your system. The `gen` and `build` commands are used for testing and just generate / build the raw binding files only.
7474

7575
IMPORTANT: many errors will be avoided by specifying the `-vm` option to gopy, with a full path if needed, or typically just `-vm=python3` to use python3 instead of version 2, which is often the default for the plain `python` command.
7676

@@ -116,6 +116,7 @@ Options:
116116
-version="0.1.0": semantic version number -- can use e.g., git to get this from tag and pass as argument
117117
-vm="python": path to python interpreter
118118
-dynamic-link=false: whether to link output shared library dynamically to Python
119+
-build-tags="": build tags to be passed to `go build`
119120

120121

121122
$ gopy help exe
@@ -142,6 +143,8 @@ Options:
142143
-user="": username on https://www.pypa.io/en/latest/ for package name suffix
143144
-version="0.1.0": semantic version number -- can use e.g., git to get this from tag and pass as argument
144145
-vm="python": path to python interpreter
146+
-dynamic-link=false: whether to link output shared library dynamically to Python
147+
-build-tags="": build tags to be passed to `go build`
145148

146149
$ gopy help gen
147150
Usage: gopy gen <go-package-name> [other-go-package...]
@@ -153,9 +156,15 @@ ex:
153156
$ gopy gen github.com/go-python/gopy/_examples/hi
154157

155158
Options:
156-
-main="": code string to run in the Go main() function in the cgo library
159+
-build-tags="": build tags to be passed to `go build`
160+
-dynamic-link=false: whether to link output shared library dynamically to Python
161+
-main="": code string to run in the go main() function in the cgo library
157162
-name="": name of output package (otherwise name of first package is used)
163+
-no-make=false: do not generate a Makefile, e.g., when called from Makefile
164+
-no-warn=false: suppress warning messages, which may be expected
158165
-output="": output directory for bindings
166+
-package-prefix=".": custom package prefix used when generating import statements for generated package
167+
-rename=false: rename Go symbols to python PEP snake_case
159168
-vm="python": path to python interpreter
160169

161170
$ gopy help build
@@ -168,9 +177,15 @@ ex:
168177
$ gopy build github.com/go-python/gopy/_examples/hi
169178

170179
Options:
171-
-main="": code string to run in the Go main() function in the cgo library
180+
-build-tags="": build tags to be passed to `go build`
181+
-dynamic-link=false: whether to link output shared library dynamically to Python
182+
-main="": code string to run in the go main() function in the cgo library
172183
-name="": name of output package (otherwise name of first package is used)
184+
-no-make=false: do not generate a Makefile, e.g., when called from Makefile
185+
-no-warn=false: suppress warning messages, which may be expected
173186
-output="": output directory for bindings
187+
-package-prefix=".": custom package prefix used when generating import statements for generated package
188+
-rename=false: rename Go symbols to python PEP snake_case
174189
-symbols=true: include symbols in output
175190
-vm="python": path to python interpreter
176191

cmd_exe.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ ex:
5858
cmd.Flag.String("url", "https://github.com/go-python/gopy", "home page for project")
5959
cmd.Flag.Bool("no-warn", false, "suppress warning messages, which may be expected")
6060
cmd.Flag.Bool("no-make", false, "do not generate a Makefile, e.g., when called from Makefile")
61+
cmd.Flag.Bool("dynamic-link", false, "whether to link output shared library dynamically to Python")
62+
cmd.Flag.String("build-tags", "", "build tags to be passed to `go build`")
6163

6264
return cmd
6365
}
@@ -80,6 +82,8 @@ func gopyRunCmdExe(cmdr *commander.Command, args []string) error {
8082
cfg.Symbols = cmdr.Flag.Lookup("symbols").Value.Get().(bool)
8183
cfg.NoWarn = cmdr.Flag.Lookup("no-warn").Value.Get().(bool)
8284
cfg.NoMake = cmdr.Flag.Lookup("no-make").Value.Get().(bool)
85+
cfg.DynamicLinking = cmdr.Flag.Lookup("dynamic-link").Value.Get().(bool)
86+
cfg.BuildTags = cmdr.Flag.Lookup("build-tags").Value.Get().(string)
8387

8488
var (
8589
exclude = cmdr.Flag.Lookup("exclude").Value.Get().(string)

cmd_gen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ ex:
3737
cmd.Flag.Bool("rename", false, "rename Go symbols to python PEP snake_case")
3838
cmd.Flag.Bool("no-warn", false, "suppress warning messages, which may be expected")
3939
cmd.Flag.Bool("no-make", false, "do not generate a Makefile, e.g., when called from Makefile")
40+
cmd.Flag.Bool("dynamic-link", false, "whether to link output shared library dynamically to Python")
41+
cmd.Flag.String("build-tags", "", "build tags to be passed to `go build`")
4042
return cmd
4143
}
4244

@@ -58,6 +60,8 @@ func gopyRunCmdGen(cmdr *commander.Command, args []string) error {
5860
cfg.RenameCase = cmdr.Flag.Lookup("rename").Value.Get().(bool)
5961
cfg.NoWarn = cmdr.Flag.Lookup("no-warn").Value.Get().(bool)
6062
cfg.NoMake = cmdr.Flag.Lookup("no-make").Value.Get().(bool)
63+
cfg.DynamicLinking = cmdr.Flag.Lookup("dynamic-link").Value.Get().(bool)
64+
cfg.BuildTags = cmdr.Flag.Lookup("build-tags").Value.Get().(string)
6165

6266
if cfg.VM == "" {
6367
cfg.VM = "python"

cmd_pkg.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ex:
5555
cmd.Flag.String("url", "https://github.com/go-python/gopy", "home page for project")
5656
cmd.Flag.Bool("no-warn", false, "suppress warning messages, which may be expected")
5757
cmd.Flag.Bool("no-make", false, "do not generate a Makefile, e.g., when called from Makefile")
58+
cmd.Flag.Bool("dynamic-link", false, "whether to link output shared library dynamically to Python")
59+
cmd.Flag.String("build-tags", "", "build tags to be passed to `go build`")
5860

5961
return cmd
6062
}
@@ -76,6 +78,8 @@ func gopyRunCmdPkg(cmdr *commander.Command, args []string) error {
7678
cfg.Symbols = cmdr.Flag.Lookup("symbols").Value.Get().(bool)
7779
cfg.NoWarn = cmdr.Flag.Lookup("no-warn").Value.Get().(bool)
7880
cfg.NoMake = cmdr.Flag.Lookup("no-make").Value.Get().(bool)
81+
cfg.DynamicLinking = cmdr.Flag.Lookup("dynamic-link").Value.Get().(bool)
82+
cfg.BuildTags = cmdr.Flag.Lookup("build-tags").Value.Get().(string)
7983

8084
var (
8185
exclude = cmdr.Flag.Lookup("exclude").Value.Get().(string)

0 commit comments

Comments
 (0)