Skip to content

Commit

Permalink
Merge pull request #189 from gopherdata/go1.11module
Browse files Browse the repository at this point in the history
Go 1.11 module support
  • Loading branch information
cosmos72 authored Dec 2, 2019
2 parents 8a9de0d + 3a09b20 commit f601dca
Show file tree
Hide file tree
Showing 965 changed files with 146 additions and 332,961 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ RUN set -x \
### pin down the tornado and ipykernel to compatible versions
&& pip3 install jupyter notebook pyzmq==16.0.2 tornado==4.5.3 ipykernel==4.8.1 \
## install gophernotes
&& GOPATH=/go go install github.com/gopherdata/gophernotes \
&& cd /go/src/github.com/gopherdata/gophernotes \
&& GOPATH=/go GO111MODULE=on go install . \
&& cp /go/bin/gophernotes /usr/local/bin/ \
&& mkdir -p ~/.local/share/jupyter/kernels/gophernotes \
&& cp -r /go/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes \
&& cp -r ./kernel/* ~/.local/share/jupyter/kernels/gophernotes \
&& cd - \
## clean
&& find /usr/lib/python3.6 -name __pycache__ | xargs rm -r \
&& rm -rf \
Expand All @@ -49,4 +51,4 @@ RUN set -x \
ENV GOPATH /go

EXPOSE 8888
CMD [ "jupyter", "notebook", "--no-browser", "--allow-root", "--ip=0.0.0.0" ]
CMD [ "jupyter", "notebook", "--no-browser", "--allow-root", "--ip=0.0.0.0" ]
11 changes: 7 additions & 4 deletions Dockerfile.DS
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN set -x \
g++ \
git \
py3-zmq \
pkgconfig \
pkgconfig \
zeromq-dev \
musl-dev \
mercurial \
Expand All @@ -29,17 +29,20 @@ RUN set -x \
--repository http://dl-4.alpinelinux.org/alpine/edge/community \
--arch=x86_64 add \
go \
## jupyter notebook
## jupyter notebook
&& ln -s /usr/include/locale.h /usr/include/xlocale.h \
### fix pyzmq to v16.0.2 as that is what is distributed with py3-zmq
### pin down the tornado and ipykernel to compatible versions
&& pip3 install jupyter notebook pyzmq==16.0.2 tornado==4.5.3 ipykernel==4.8.1 \
## install gophernotes
&& cd /go/src/github.com/gopherdata/gophernotes \
&& export GOPATH=/go \
&& go install github.com/gopherdata/gophernotes \
&& export GO111MODULE=on \
&& go install . \
&& cp /go/bin/gophernotes /usr/local/bin/ \
&& mkdir -p ~/.local/share/jupyter/kernels/gophernotes \
&& cp -r /go/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes \
&& cp -r ./kernel/* ~/.local/share/jupyter/kernels/gophernotes \
&& cd - \
## get the relevant Go packages
&& go get -insecure gonum.org/v1/plot/... \
&& go get -insecure gonum.org/v1/gonum/... \
Expand Down
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,41 @@

### Prerequisites

- [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`).
- [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`).
- [Jupyter Notebook](http://jupyter.readthedocs.io/en/latest/install.html) or [nteract](https://nteract.io/desktop)
- [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.
- [pkg-config](https://en.wikipedia.org/wiki/Pkg-config)
- [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)
On Windows, it can also be installed as part of MinGW as described below.

### Linux

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

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

To confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:
```sh
$ "$(go env GOPATH)"/bin/gophernotes
```
and you shoud see the following:
```sh
$ gophernotes
2017/09/20 10:33:12 Need a command line argument specifying the connection file.
```

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

### Mac

**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`.
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.
**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`.

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

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

To confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:
```sh
$ "$(go env GOPATH)"/bin/gophernotes
```
and you shoud see the following:
```sh
$ gophernotes
2017/09/20 10:33:12 Need a command line argument specifying the connection file.
```

Expand All @@ -105,6 +138,7 @@ Then:

```
REM Download w/o building.
set GO111MODULE=off
go get -d -u github.com/gopherdata/gophernotes
cd %GOPATH%\src\github.com\gopherdata\gophernotes\zmq-win
Expand Down
7 changes: 7 additions & 0 deletions compiler_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build !go1.11

// cause a compile error if Go compiler version < 1.11

package main

var _ int = "error: Go >= 1.11 required to compile Gophernotes"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/gopherdata/gophernotes

go 1.13
go 1.11

require (
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56
github.com/kr/pretty v0.1.0 // indirect
github.com/pebbe/zmq4 v0.0.0-20170917105202-90d69e412a09
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5
Expand Down
14 changes: 10 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170 h1:zg8/E4AmoZ09TdoYiRbBtBwDghEdOyc9YNEzwIt0Xco=
github.com/cosmos72/gomacro v0.0.0-20190929212108-d70dd8a6f170/go.mod h1:KJA2tG1LPV/U9zq3I4bjlzGMkTCezSMeD5dSgL5AWa4=
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56 h1:dcB7aqJMwcpV9vj7mjZ6bFtGNDq9Y3lFPpXj6KSU9ok=
github.com/cosmos72/gomacro v0.0.0-20191128205525-a189728fbb56/go.mod h1:BQU56+eL2VDHCz4pdp+nkseVQ3eubCGRIY5D8rfw788=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -13,7 +13,13 @@ github.com/peterh/liner v1.1.0 h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=
github.com/peterh/liner v1.1.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5 h1:Jw7W4WMfQDxsXvfeFSaS2cHlY7bAF4MGrgnbd0+Uo78=
github.com/satori/go.uuid v1.2.1-0.20180103174451-36e9d2ebbde5/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
golang.org/x/sys v0.0.0-20190429094411-2cc0cad0ac78 h1:ddnrbGOgFiC0zV+uaYoSkl0f47vnII6Zu426zWQrWkg=
golang.org/x/sys v0.0.0-20190429094411-2cc0cad0ac78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191119223639-caaa49c6ded0 h1:03eeJVjGh9nx1W1C7u8xgJhySS9CnXyoYBZ/D8dGq/I=
golang.org/x/tools v0.0.0-20191119223639-caaa49c6ded0/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8 changes: 8 additions & 0 deletions imports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The command `import` will write here import files for third-party
packages if they are to be imported and statically linked into gophernotes.

This is currently needed on Windows, *BSD, Android etc. (to be exact,
as of Go 1.13 it's needed on all operating system except Linux and Mac OS X).

It is safe to remove files in this directory,
as long as you **keep at least** README.md and a_package.go
24 changes: 24 additions & 0 deletions imports/a_package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package imports

import (
"github.com/cosmos72/gomacro/base/paths"
"github.com/cosmos72/gomacro/imports"
)

type PackageUnderlying = imports.PackageUnderlying

type Package = imports.Package

type PackageMap = imports.PackageMap

// imports.Packages is a map, copying it only makes a reference
// => Packages and imports.Packages are kept in sync automatically
var Packages = imports.Packages

// used to locate this package path via reflection
type findMe struct{}

func init() {
// tell gomacro where to write import files
paths.SymbolFromImportsPackage = findMe{}
}
4 changes: 4 additions & 0 deletions kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
basereflect "github.com/cosmos72/gomacro/base/reflect"
interp "github.com/cosmos72/gomacro/fast"
"github.com/cosmos72/gomacro/xreflect"

// compile and link files generated in imports/
_ "github.com/gopherdata/gophernotes/imports"

zmq "github.com/pebbe/zmq4"
)

Expand Down
6 changes: 3 additions & 3 deletions kernel/kernel.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"argv": [
"gophernotes",
"{connection_file}"
],
"gophernotes",
"{connection_file}"
],
"display_name": "Go",
"language": "go",
"name": "go"
Expand Down
9 changes: 9 additions & 0 deletions kernel/kernel.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"argv": [
"gophernotes",
"{connection_file}"
],
"display_name": "Go",
"language": "go",
"name": "go"
}
6 changes: 0 additions & 6 deletions vendor/github.com/cosmos72/gomacro/.gitignore

This file was deleted.

Loading

0 comments on commit f601dca

Please sign in to comment.