Skip to content

Commit 0c5d951

Browse files
authored
Merge pull request mirage#147 from mseri/fix-tests
Add support for python3 and fix tests
2 parents baef5fb + 499daf9 commit 0c5d951

File tree

11 files changed

+70
-34
lines changed

11 files changed

+70
-34
lines changed

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ script: bash -ex .travis-docker.sh
77
env:
88
global:
99
- DISTRO=debian-unstable
10-
- PINS="rpclib.master:. rpclib-js.master:. rpclib-html.master:. rpclib-lwt.master:. rpclib-async.master:. ppx_deriving_rpc.master:."
10+
- PINS="rpclib.dev:. rpclib-js.dev:. rpclib-html.dev:. rpclib-lwt.dev:. rpclib-async.dev:. ppx_deriving_rpc.dev:. rpc.dev:."
1111
- PACKAGE=rpc
1212
matrix:
13-
- OCAML_VERSION=4.06.0 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y pylint pycodestyle"
13+
- OCAML_VERSION=4.08.1 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
1414
# We install the packages required by the unit test for linting the generated Python code in PRE_INSTALL_HOOK:
15-
- PACKAGE=rpclib OCAML_VERSION=4.06.0
16-
- PACKAGE=ppx_deriving_rpc OCAML_VERSION=4.06.0
17-
- OCAML_VERSION=4.05.0 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y pylint pycodestyle"
18-
- OCAML_VERSION=4.04.2 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y pylint pycodestyle"
15+
- PACKAGE=rpclib OCAML_VERSION=4.08.1
16+
- PACKAGE=ppx_deriving_rpc OCAML_VERSION=4.08.1
17+
- OCAML_VERSION=4.09.0 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
18+
- OCAML_VERSION=4.07.1 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
19+
- OCAML_VERSION=4.06.0 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
20+
- OCAML_VERSION=4.05.0 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
21+
- OCAML_VERSION=4.04.2 PRE_INSTALL_HOOK="sudo apt-get update -y; sudo apt-get install -y python pylint pycodestyle"
1922
matrix:
2023
fast_finish: true

CHANGES.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## dev
2+
* opam: updated bounds on a more conservative basis
3+
* travis: tests more compilers
4+
* tests: disable useless-object-inheritance on pylint checks
5+
* pythongen: generate python2-3 compatible bindings
6+
* Add ISC license
7+
* Incremented the upper bound for async's version.
8+
* Added lower bound for js_of_ocaml in related .opam file.
9+
* Fixed compilation issue with js_of_ocaml 3.5.0 and 3.5.1.
10+
* opam: remove the 'build' directive on dune dependency
11+
* opam: remove unnecessary flag
12+
* port to dune
13+
14+
## 6.0.0 (November 2018)
15+
* Fix ppx_deriving_rpc for newer ppxlib
16+
* test_pythongen: ignore W504, it's breaking the internet and is pointless
17+
* Add more tests and documentation
18+
* ppx_deriving_rpc: Switch to ppxlib from ppx_deriving
19+
* Fix marshalling of optional named parameters
20+
* Add failing test of optional/unnamed args for rpcs
21+
* CA-291118: Register an exception printer for IDL errors
22+
123
## 5.8.0 (June 2018)
224
* rpclib:
325
- New `Rpc.Types` variants for 3- and 4-tuples

ppx_deriving_rpc.opam

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ homepage: "https://github.com/mirage/ocaml-rpc"
77
doc: "https://mirage.github.io/ocaml-rpc/ppx_deriving_rpc"
88
bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
10-
"ocaml" {>= "4.03.0"}
11-
"jbuilder" {build}
10+
"ocaml" {>= "4.04.0"}
11+
"dune" {>= "1.5.0"}
1212
"rpclib" {>= "5.0.0"}
1313
"rresult"
14-
"ppxlib"
14+
"ppxlib" {< "0.9.0"}
1515
"rpclib-lwt" {with-test & >= "5.0.0"}
1616
"rpclib-async" {with-test & >= "5.0.0"}
1717
"lwt" {with-test & >= "3.0.0"}
1818
"async" {with-test}
1919
"alcotest" {with-test}
2020
]
2121
build: [
22-
["jbuilder" "build" "-p" name "-j" jobs]
23-
["jbuilder" "runtest" "-p" name "-j" jobs] {with-test}
22+
["dune" "build" "-p" name "-j" jobs]
23+
["dune" "runtest" "-p" name "-j" jobs] {with-test}
2424
]
2525
dev-repo: "git://github.com/mirage/ocaml-rpc"

rpc.opam

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ doc: "https://mirage.github.io/ocaml-rpc/rpc"
88
bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
1010
"ocaml" {>= "4.04.0"}
11-
"dune" {>= "1.1.0"}
12-
"rpclib" {>= "5.0.0"}
13-
"rpclib-async" {>= "5.0.0"}
14-
"rpclib-lwt" {>= "5.0.0"}
15-
"ppx_deriving_rpc" {>= "5.0.0"}
16-
"async" {>= "v0.9.0" & <= "v0.12.0"}
11+
"dune" {>= "1.5.0"}
12+
"rpclib" {=version}
13+
"rpclib-async" {=version}
14+
"rpclib-lwt" {=version}
15+
"ppx_deriving_rpc" {=version}
16+
"async" {>= "v0.9.0"}
1717
"lwt"
1818
"alcotest" {with-test}
1919
"alcotest-lwt" {with-test}

rpclib-async.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
1010
"ocaml"
1111
"alcotest" {with-test}
12-
"dune" {>= "1.1.0"}
13-
"rpclib" {>= "5.0.0"}
12+
"dune" {>= "1.5.0"}
13+
"rpclib" {=version}
1414
"async"
1515
]
1616
conflicts: [

rpclib-html.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ doc: "https://mirage.github.io/ocaml-rpc/rpclib-html"
99
bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
1010
depends: [
1111
"ocaml"
12-
"dune" {>= "1.1.0"}
13-
"rpclib" {>= "5.0.0"}
12+
"dune" {>= "1.5.0"}
13+
"rpclib" {=version}
1414
"cow"
1515
]
1616
build: ["dune" "build" "-p" name "-j" jobs]

rpclib-js.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ doc: "https://mirage.github.io/ocaml-rpc/rpclib-js"
88
bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
1010
"ocaml"
11-
"dune" {>= "1.1.0"}
12-
"rpclib" {>= "5.0.0"}
11+
"dune" {>= "1.5.0"}
12+
"rpclib" {=version}
1313
"js_of_ocaml" {>= "3.5.0"}
1414
"js_of_ocaml-ppx" {>= "3.5.0"}
1515
"lwt"

rpclib-lwt.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
1010
"ocaml"
1111
"alcotest" {with-test}
12-
"dune" {>= "1.1.0"}
13-
"rpclib" {>= "5.0.0"}
12+
"dune" {>= "1.5.0"}
13+
"rpclib" {=version}
1414
"lwt" {>= "3.0.0"}
1515
"alcotest-lwt" {with-test}
1616
]

rpclib.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bug-reports: "https://github.com/mirage/ocaml-rpc/issues"
99
depends: [
1010
"ocaml" {>= "4.04.0"}
1111
"alcotest" {with-test}
12-
"dune" {>= "1.1.0"}
12+
"dune" {>= "1.5.0"}
1313
"cmdliner"
1414
"rresult"
1515
"xmlm"

src/lib/pythongen.ml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ class ListAction(argparse.Action):
9393
else:
9494
setattr(namespace, self.dest, {key: value})|}
9595

96+
let compat_block = [
97+
Line "if sys.version_info[0] > 2:"
98+
; Block [
99+
Line "long = int"
100+
; Line "unicode = str"
101+
; Line "str = bytes"]
102+
; Line "" ]
103+
96104
let reserved_exns =
97105
[ "Rpc_light_failure"
98106
; "Unimplemented"
@@ -250,8 +258,8 @@ let rec typecheck : type a. a typ -> string -> t list =
250258
let rec value_of : type a. a typ -> string =
251259
let open Printf in
252260
function
253-
| Basic Int64 -> "0L"
254-
| Basic Int -> "0L"
261+
| Basic Int64 -> "long(0)"
262+
| Basic Int -> "long(0)"
255263
| Basic Int32 -> "0"
256264
| Basic Char -> "'c'"
257265
| Basic String -> {|"string"|}
@@ -386,7 +394,7 @@ let example_stub_user i (BoxedFunction m) =
386394
m.Method.name) )
387395
(value_of a.Idl.Param.typedef.ty) )
388396
Method.(find_inputs m.ty))))
389-
; Line "print (repr(results))" ] ]
397+
; Line "print(repr(results))" ] ]
390398

391399
let example_skeleton_user i m =
392400
let open Printf in
@@ -619,7 +627,7 @@ let commandline_run _ (BoxedFunction m) =
619627
; Line "use_json = 'json' in request and request['json']"
620628
; Line
621629
(sprintf "results = self.dispatcher.%s(request)" m.Method.name)
622-
; Line "print json.dumps(results)" ]
630+
; Line "print(json.dumps(results))" ]
623631
; Line "except Exception as exn:"
624632
; Block
625633
[ Line "if use_json:"
@@ -664,16 +672,19 @@ let of_interfaces ?(helpers= inline_defaults) i =
664672
in
665673
[Line "self._dispatcher_dict = {"] @ intersperse_commas methods @ [Line "}"]
666674
in
667-
[ Line
668-
(sprintf {|"""Bindings generated for interface %s by rpclib"""|}
675+
[ Line (sprintf {|"""Bindings generated for interface %s by rpclib"""|}
669676
i.Interfaces.name)
670677
; Line ""
678+
; Line "from __future__ import print_function, division"
679+
; Line ""
671680
; Line "import argparse"
672681
; Line "import json"
673682
; Line "import logging"
674683
; Line "import sys"
675684
; Line "import traceback"
676-
; Line "" ]
685+
; Line ""
686+
]
687+
@ compat_block
677688
@ (helpers |> String.split_on_char '\n' |> List.map (fun line -> Line line))
678689
@ ( try List.map exn_var i.Interfaces.error_decls |> List.flatten with e ->
679690
Printf.fprintf stderr "Error while generating exceptions of %s"

0 commit comments

Comments
 (0)