From 0327f71d559ce52bf118a30fe556b5f66050aec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Fri, 20 Sep 2024 11:43:26 +0100 Subject: [PATCH 1/5] fix python cmdline parser for variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given ``` type operation = Copy of string | Mirror of string ``` Represented as `["Copy", "arg"]` we need to parse that as JSON when given on the cmdline. Otherwise it'd do `operation[0]`, where `operation` is a string, which is not what we want. This doesn't affect usage from xapi-storage-script (which always calls it with --json), but it affects testing the python code by hand, because you can't supply the correct cmdline arguments (unless you construct an entire JSON by hand and pass it on stdin which is a bit tedious) Signed-off-by: Edwin Török --- src/lib/pythongen.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/pythongen.ml b/src/lib/pythongen.ml index 70fbb74..2ac75d7 100644 --- a/src/lib/pythongen.ml +++ b/src/lib/pythongen.ml @@ -699,6 +699,7 @@ let commandline_parse _ (BoxedFunction m) = | Basic Int32 -> ", type=int" | Basic Bool -> ", type=lambda x: json.loads(x.lower())" | Basic Float -> ", type=float" + | Variant _ -> ", type=json.loads" | _ -> ""))) inputs @ [ Line "return vars(parser.parse_args())" ]) From cae47beb2c751996013c4f3c3cd87d6d73697e9c Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Tue, 24 Sep 2024 14:33:36 +0100 Subject: [PATCH 2/5] CI: use setup-ocamlv3 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b102efa..d186858 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: - name: Install Python dependencies run: pip install pylint pycodestyle - name: Install OCaml - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ matrix.ocaml-version }} - name: Install OCaml dependencies From 7101007e30d6c109871fc461d40ae291ac7959e5 Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Tue, 24 Sep 2024 15:29:02 +0100 Subject: [PATCH 3/5] CI: Update ocaml-version --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d186858..c06d431 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: matrix: # windows-latest async does not support it for now operating-system: [macos-latest, ubuntu-latest] - ocaml-version: [ '4.14.0', '4.08.1' ] + ocaml-version: [ '5.2.0', '4.14.0' ] steps: - uses: actions/checkout@master - name: Setup Python From a8d529d65d6f412740be7b519b38775d0da98c87 Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Wed, 25 Sep 2024 12:33:34 +0100 Subject: [PATCH 4/5] CI: Update setup python --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c06d431..c659161 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@master - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Cache pip From 31dac5ba5f67a27a3f4542fd9df6cf5d8f66fda6 Mon Sep 17 00:00:00 2001 From: Vincent Liu Date: Wed, 25 Sep 2024 14:25:12 +0100 Subject: [PATCH 5/5] Drop python2 support Since we are not testing it in the CI anyway. --- src/lib/pythongen.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/pythongen.ml b/src/lib/pythongen.ml index 2ac75d7..aadaf70 100644 --- a/src/lib/pythongen.ml +++ b/src/lib/pythongen.ml @@ -98,8 +98,9 @@ class ListAction(argparse.Action): let compat_block = [ Line "get_str = str" - ; Line "if sys.version_info[0] > 2:" - ; Block [ Line "long = int"; Line "unicode = str"; Line "str = bytes" ] + ; Line "long = int" + ; Line "unicode = str" + ; Line "str = bytes" ; Line "" ]