Skip to content

Commit f601dca

Browse files
authored
Merge pull request #189 from gopherdata/go1.11module
Go 1.11 module support
2 parents 8a9de0d + 3a09b20 commit f601dca

File tree

965 files changed

+146
-332961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

965 files changed

+146
-332961
lines changed

Dockerfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ RUN set -x \
3434
### pin down the tornado and ipykernel to compatible versions
3535
&& pip3 install jupyter notebook pyzmq==16.0.2 tornado==4.5.3 ipykernel==4.8.1 \
3636
## install gophernotes
37-
&& GOPATH=/go go install github.com/gopherdata/gophernotes \
37+
&& cd /go/src/github.com/gopherdata/gophernotes \
38+
&& GOPATH=/go GO111MODULE=on go install . \
3839
&& cp /go/bin/gophernotes /usr/local/bin/ \
3940
&& mkdir -p ~/.local/share/jupyter/kernels/gophernotes \
40-
&& cp -r /go/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes \
41+
&& cp -r ./kernel/* ~/.local/share/jupyter/kernels/gophernotes \
42+
&& cd - \
4143
## clean
4244
&& find /usr/lib/python3.6 -name __pycache__ | xargs rm -r \
4345
&& rm -rf \
@@ -49,4 +51,4 @@ RUN set -x \
4951
ENV GOPATH /go
5052

5153
EXPOSE 8888
52-
CMD [ "jupyter", "notebook", "--no-browser", "--allow-root", "--ip=0.0.0.0" ]
54+
CMD [ "jupyter", "notebook", "--no-browser", "--allow-root", "--ip=0.0.0.0" ]

Dockerfile.DS

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN set -x \
1818
g++ \
1919
git \
2020
py3-zmq \
21-
pkgconfig \
21+
pkgconfig \
2222
zeromq-dev \
2323
musl-dev \
2424
mercurial \
@@ -29,17 +29,20 @@ RUN set -x \
2929
--repository http://dl-4.alpinelinux.org/alpine/edge/community \
3030
--arch=x86_64 add \
3131
go \
32-
## jupyter notebook
32+
## jupyter notebook
3333
&& ln -s /usr/include/locale.h /usr/include/xlocale.h \
3434
### fix pyzmq to v16.0.2 as that is what is distributed with py3-zmq
3535
### pin down the tornado and ipykernel to compatible versions
3636
&& pip3 install jupyter notebook pyzmq==16.0.2 tornado==4.5.3 ipykernel==4.8.1 \
3737
## install gophernotes
38+
&& cd /go/src/github.com/gopherdata/gophernotes \
3839
&& export GOPATH=/go \
39-
&& go install github.com/gopherdata/gophernotes \
40+
&& export GO111MODULE=on \
41+
&& go install . \
4042
&& cp /go/bin/gophernotes /usr/local/bin/ \
4143
&& mkdir -p ~/.local/share/jupyter/kernels/gophernotes \
42-
&& cp -r /go/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes \
44+
&& cp -r ./kernel/* ~/.local/share/jupyter/kernels/gophernotes \
45+
&& cd - \
4346
## get the relevant Go packages
4447
&& go get -insecure gonum.org/v1/plot/... \
4548
&& go get -insecure gonum.org/v1/gonum/... \

README.md

+45-11
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,41 @@
4040

4141
### Prerequisites
4242

43-
- [Go 1.9+](https://golang.org/doc/install) - including GOPATH/bin added to your PATH (i.e., you can run Go binaries that you `go install`).
43+
- [Go 1.11+](https://golang.org/doc/install) - including GOPATH/bin added to your PATH (i.e., you can run Go binaries that you `go install`).
4444
- [Jupyter Notebook](http://jupyter.readthedocs.io/en/latest/install.html) or [nteract](https://nteract.io/desktop)
4545
- [ZeroMQ 4.X.X](http://zeromq.org/intro:get-the-software) - for convenience, pre-built Windows binaries (v4.2.1) are included in the zmq-win directory.
4646
- [pkg-config](https://en.wikipedia.org/wiki/Pkg-config)
47+
- [git](https://git-scm.com/download) - usually already present on Linux and Mac OS X. If not present, follow the instructions at [https://git-scm.com/download](https://git-scm.com/download)
48+
On Windows, it can also be installed as part of MinGW as described below.
4749

4850
### Linux
4951

52+
Quick installation as module, requires Go 1.12+
5053
```sh
51-
$ go get -u github.com/gopherdata/gophernotes
54+
$ env GO111MODULE=on go get github.com/gopherdata/gophernotes
5255
$ mkdir -p ~/.local/share/jupyter/kernels/gophernotes
53-
$ cp $GOPATH/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes
56+
$ cd ~/.local/share/jupyter/kernels/gophernotes
57+
$ cp "$(go env GOPATH)"/pkg/mod/github.com/gopherdata/[email protected]/kernel/* "."
58+
$ sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
5459
```
5560

56-
To confirm that the `gophernotes` binary is installed and in your PATH, you should see the following when running `gophernotes` directly:
61+
Manual installation from GOPATH, also works with Go 1.11
62+
```sh
63+
$ env GO111MODULE=off go get -d -u github.com/gopherdata/gophernotes
64+
$ cd "$(go env GOPATH)"/src/github.com/gopherdata/gophernotes
65+
$ env GO111MODULE=on go install
66+
$ mkdir -p ~/.local/share/jupyter/kernels/gophernotes
67+
$ cp kernel/* ~/.local/share/jupyter/kernels/gophernotes
68+
$ cd ~/.local/share/jupyter/kernels/gophernotes
69+
$ sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
70+
```
5771

72+
To confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:
73+
```sh
74+
$ "$(go env GOPATH)"/bin/gophernotes
75+
```
76+
and you shoud see the following:
5877
```sh
59-
$ gophernotes
6078
2017/09/20 10:33:12 Need a command line argument specifying the connection file.
6179
```
6280

@@ -68,19 +86,34 @@ $ jupyter --data-dir
6886

6987
### Mac
7088

71-
**Important Note** - gomacro relies on the `plugin` package when importing third party libraries. This package works reliably on Mac OS X only with Go 1.10.2+ as long as you **never** execute the command `strip gophernotes`.
72-
If you can only compile gophernotes with Go <= 1.10.1 on Mac, consider using the [Docker](#docker) install and run gophernotes/Jupyter in Docker.
89+
**Important Note** - gomacro relies on the `plugin` package when importing third party libraries. This package works reliably on Mac OS X with Go 1.10.2+ as long as you **never** execute the command `strip gophernotes`.
7390

91+
Quick installation as module, requires Go 1.12+
7492
```sh
75-
$ go get -u github.com/gopherdata/gophernotes
93+
$ env GO111MODULE=on go get github.com/gopherdata/gophernotes
7694
$ mkdir -p ~/Library/Jupyter/kernels/gophernotes
77-
$ cp $GOPATH/src/github.com/gopherdata/gophernotes/kernel/* ~/Library/Jupyter/kernels/gophernotes
95+
$ cd ~/Library/Jupyter/kernels/gophernotes
96+
$ cp "$(go env GOPATH)"/pkg/mod/github.com/gopherdata/[email protected]/kernel/* "."
97+
$ sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
7898
```
7999

80-
To confirm that the `gophernotes` binary is installed and in your PATH, you should see the following when running `gophernotes` directly:
100+
Manual installation from GOPATH, also works with Go 1.11
101+
```sh
102+
$ env GO111MODULE=off go get -d -u github.com/gopherdata/gophernotes
103+
$ cd "$(go env GOPATH)"/src/github.com/gopherdata/gophernotes
104+
$ env GO111MODULE=on go install
105+
$ mkdir -p ~/Library/Jupyter/kernels/gophernotes
106+
$ cp kernel/* ~/Library/Jupyter/kernels/gophernotes
107+
$ cd ~/Library/Jupyter/kernels/gophernotes
108+
$ sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
109+
```
81110

111+
To confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:
112+
```sh
113+
$ "$(go env GOPATH)"/bin/gophernotes
114+
```
115+
and you shoud see the following:
82116
```sh
83-
$ gophernotes
84117
2017/09/20 10:33:12 Need a command line argument specifying the connection file.
85118
```
86119

@@ -105,6 +138,7 @@ Then:
105138

106139
```
107140
REM Download w/o building.
141+
set GO111MODULE=off
108142
go get -d -u github.com/gopherdata/gophernotes
109143
cd %GOPATH%\src\github.com\gopherdata\gophernotes\zmq-win
110144

compiler_version.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// +build !go1.11
2+
3+
// cause a compile error if Go compiler version < 1.11
4+
5+
package main
6+
7+
var _ int = "error: Go >= 1.11 required to compile Gophernotes"

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/gopherdata/gophernotes
22

3-
go 1.13
3+
go 1.11
44

55
require (
6-
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170
6+
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56
77
github.com/kr/pretty v0.1.0 // indirect
88
github.com/pebbe/zmq4 v0.0.0-20170917105202-90d69e412a09
99
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5

go.sum

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170 h1:zg8/E4AmoZ09TdoYiRbBtBwDghEdOyc9YNEzwIt0Xco=
2-
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170/go.mod h1:KJA2tG1LPV/U9zq3I4bjlzGMkTCezSMeD5dSgL5AWa4=
1+
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56 h1:dcB7aqJMwcpV9vj7mjZ6bFtGNDq9Y3lFPpXj6KSU9ok=
2+
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56/go.mod h1:BQU56+eL2VDHCz4pdp+nkseVQ3eubCGRIY5D8rfw788=
33
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
44
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
55
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -13,7 +13,13 @@ github.com/peterh/liner v1.1.0 h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=
1313
github.com/peterh/liner v1.1.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
1414
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5 h1:Jw7W4WMfQDxsXvfeFSaS2cHlY7bAF4MGrgnbd0+Uo78=
1515
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
16-
golang.org/x/sys v0.0.0-20190429094411-2cc0cad0ac78 h1:ddnrbGOgFiC0zV+uaYoSkl0f47vnII6Zu426zWQrWkg=
17-
golang.org/x/sys v0.0.0-20190429094411-2cc0cad0ac78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
16+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
17+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
18+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
19+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
20+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
21+
golang.org/x/tools v0.0.0-20191119223639-caaa49c6ded0 h1:03eeJVjGh9nx1W1C7u8xgJhySS9CnXyoYBZ/D8dGq/I=
22+
golang.org/x/tools v0.0.0-20191119223639-caaa49c6ded0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
23+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1824
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
1925
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

imports/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The command `import` will write here import files for third-party
2+
packages if they are to be imported and statically linked into gophernotes.
3+
4+
This is currently needed on Windows, *BSD, Android etc. (to be exact,
5+
as of Go 1.13 it's needed on all operating system except Linux and Mac OS X).
6+
7+
It is safe to remove files in this directory,
8+
as long as you **keep at least** README.md and a_package.go

imports/a_package.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package imports
2+
3+
import (
4+
"github.com/cosmos72/gomacro/base/paths"
5+
"github.com/cosmos72/gomacro/imports"
6+
)
7+
8+
type PackageUnderlying = imports.PackageUnderlying
9+
10+
type Package = imports.Package
11+
12+
type PackageMap = imports.PackageMap
13+
14+
// imports.Packages is a map, copying it only makes a reference
15+
// => Packages and imports.Packages are kept in sync automatically
16+
var Packages = imports.Packages
17+
18+
// used to locate this package path via reflection
19+
type findMe struct{}
20+
21+
func init() {
22+
// tell gomacro where to write import files
23+
paths.SymbolFromImportsPackage = findMe{}
24+
}

kernel.go

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import (
1919
basereflect "github.com/cosmos72/gomacro/base/reflect"
2020
interp "github.com/cosmos72/gomacro/fast"
2121
"github.com/cosmos72/gomacro/xreflect"
22+
23+
// compile and link files generated in imports/
24+
_ "github.com/gopherdata/gophernotes/imports"
25+
2226
zmq "github.com/pebbe/zmq4"
2327
)
2428

kernel/kernel.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"argv": [
3-
"gophernotes",
4-
"{connection_file}"
5-
],
3+
"gophernotes",
4+
"{connection_file}"
5+
],
66
"display_name": "Go",
77
"language": "go",
88
"name": "go"

kernel/kernel.json.in

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"argv": [
3+
"gophernotes",
4+
"{connection_file}"
5+
],
6+
"display_name": "Go",
7+
"language": "go",
8+
"name": "go"
9+
}

vendor/github.com/cosmos72/gomacro/.gitignore

-6
This file was deleted.

0 commit comments

Comments
 (0)