From 6ac57008fde0d9ae050fcbc38608caa50efdb1eb Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Tue, 16 Apr 2024 11:28:44 +0530 Subject: [PATCH 1/2] Supporting argparse <3.1 and pinning nlohmann_json version --- README.md | 4 ++-- environment-host.yml | 4 ++-- src/xmagics/executable.cpp | 7 +++---- src/xmagics/executable.hpp | 1 - src/xmagics/execution.cpp | 7 +++---- src/xmagics/execution.hpp | 2 +- src/xmagics/os.cpp | 7 +++---- src/xmagics/os.hpp | 1 - 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 701b0d73..92e97981 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ mamba install xeus-cling -c conda-forge You will first need to create a new environment and install the dependencies: ```bash -mamba create -n xeus-cling -c conda-forge cmake xeus-zmq cling nlohmann_json cppzmq xtl pugixml doctest cpp-argparse +mamba create -n xeus-cling -c conda-forge cmake xeus-zmq cling nlohmann_json=3.11.2 cppzmq xtl pugixml doctest cpp-argparse<3.1 source activate xeus-cling ``` Please refer to [environment-host.yml](https://github.com/jupyter-xeus/xeus-cling/blob/main/environment-host.yml) for packages specific versions to install if applicable. @@ -107,7 +107,7 @@ A C++ backend for the Jupyter interactive widgets is available in the [`xwidgets | `xeus-cling` | `xeus-zmq` | `xtl` | `cling` | `pugixml` | `cppzmq` | `cpp-argparse`| `nlohmann_json` | `dirent` (windows only) | |--------------|-----------------|-----------------|---------------|---------------|----------|---------------|-----------------|-------------------------| -| main | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | +| main | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | <3.1 | ~3.11.2 | >=2.3.2,<3 | | 0.15.3 | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | | 0.15.2 | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | | 0.15.1 | >=1.0.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | diff --git a/environment-host.yml b/environment-host.yml index b53a15c0..86354bf6 100644 --- a/environment-host.yml +++ b/environment-host.yml @@ -7,11 +7,11 @@ dependencies: # Host dependencies - xeus-zmq=1.1.0 - cling=0.9 - - nlohmann_json + - nlohmann_json=3.11.2 - cppzmq - xtl=0.7 - pugixml - - cpp-argparse + - cpp-argparse <3.1 # Test dependencies - pytest - jupyter_kernel_test diff --git a/src/xmagics/executable.cpp b/src/xmagics/executable.cpp index 391c8c9f..48d3b75d 100644 --- a/src/xmagics/executable.cpp +++ b/src/xmagics/executable.cpp @@ -42,9 +42,8 @@ namespace xcpp { - argparser executable::get_options() + static void get_options(argparser &argpars) { - argparser argpars("executable", XEUS_CLING_VERSION, argparse::default_arguments::none); argpars.add_description("write executable"); argpars.add_argument("filename") .help("filename") @@ -67,7 +66,6 @@ namespace xcpp .help("shows help message") .implicit_value(true) .nargs(0); - return argpars; } std::string executable::generate_fns(const std::string& cell, @@ -265,7 +263,8 @@ namespace xcpp void executable::operator()(const std::string& line, const std::string& cell) { - auto argpars = get_options(); + argparser argpars("executable", XEUS_CLING_VERSION, argparse::default_arguments::none); + get_options(argpars); argpars.parse(line); std::string ExeFile = argpars.get("filename"); diff --git a/src/xmagics/executable.hpp b/src/xmagics/executable.hpp index 80de9ead..8785045e 100644 --- a/src/xmagics/executable.hpp +++ b/src/xmagics/executable.hpp @@ -25,7 +25,6 @@ namespace xcpp public: executable(cling::Interpreter& i) : m_interpreter(i) {} - argparser get_options(); virtual void operator()(const std::string& line, const std::string& cell) override; private: diff --git a/src/xmagics/execution.cpp b/src/xmagics/execution.cpp index ce49bc2f..22f6f745 100644 --- a/src/xmagics/execution.cpp +++ b/src/xmagics/execution.cpp @@ -33,9 +33,8 @@ namespace xcpp compilation_result = m_interpreter->process(init_timeit.c_str()); } - argparser timeit::get_options() + void timeit::get_options(argparser &argpars) { - argparser argpars("timeit", XEUS_CLING_VERSION, argparse::default_arguments::none); argpars.add_description("Time execution of a C++ statement or expression"); argpars.add_argument("-n", "--number") .help("execute the given statement n times in a loop. If this value is not given, a fitting value is chosen") @@ -62,7 +61,6 @@ namespace xcpp .help("shows help message") .implicit_value(true) .nargs(0); - return argpars; } std::string timeit::inner(std::size_t number, const std::string& code) const @@ -103,7 +101,8 @@ namespace xcpp // std::vector results((std::istream_iterator(iss)), // std::istream_iterator()); - auto argpars = get_options(); + argparser argpars("timeit", XEUS_CLING_VERSION, argparse::default_arguments::none); + get_options(argpars); argpars.parse(line); // TODO find a way to use std::size_t diff --git a/src/xmagics/execution.hpp b/src/xmagics/execution.hpp index af0a0315..ed0e3afe 100644 --- a/src/xmagics/execution.hpp +++ b/src/xmagics/execution.hpp @@ -44,7 +44,7 @@ namespace xcpp cling::Interpreter* m_interpreter; - argparser get_options(); + void get_options(argparser &argpars); std::string inner(std::size_t number, const std::string& code) const; std::string _format_time(double timespan, std::size_t precision) const; void execute(std::string& line, std::string& cell); diff --git a/src/xmagics/os.cpp b/src/xmagics/os.cpp index 885a764a..54349f83 100644 --- a/src/xmagics/os.cpp +++ b/src/xmagics/os.cpp @@ -20,9 +20,8 @@ namespace xcpp { - argparser writefile::get_options() + static void get_options(argparser &argpars) { - argparser argpars("file", XEUS_CLING_VERSION, argparse::default_arguments::none); argpars.add_description("write file"); argpars.add_argument("-a", "--append") .help("append") @@ -41,12 +40,12 @@ namespace xcpp .help("shows help message") .implicit_value(true) .nargs(0); - return argpars; } void writefile::operator()(const std::string& line, const std::string& cell) { - auto argpars = get_options(); + argparser argpars("file", XEUS_CLING_VERSION, argparse::default_arguments::none); + get_options(argpars); argpars.parse(line); auto filename = argpars.get("filename"); diff --git a/src/xmagics/os.hpp b/src/xmagics/os.hpp index f41c055e..64aee3b8 100644 --- a/src/xmagics/os.hpp +++ b/src/xmagics/os.hpp @@ -21,7 +21,6 @@ namespace xcpp { public: - argparser get_options(); virtual void operator()(const std::string& line, const std::string& cell) override; private: From 4067e5ca68448c684f3a1bd68fddf6890dcb9f5a Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Tue, 16 Apr 2024 12:49:46 +0530 Subject: [PATCH 2/2] addressed review --- README.md | 4 ++-- environment-host.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 92e97981..7363cb37 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ mamba install xeus-cling -c conda-forge You will first need to create a new environment and install the dependencies: ```bash -mamba create -n xeus-cling -c conda-forge cmake xeus-zmq cling nlohmann_json=3.11.2 cppzmq xtl pugixml doctest cpp-argparse<3.1 +mamba create -n xeus-cling -c conda-forge cmake xeus-zmq cling nlohmann_json=3.11.2 cppzmq xtl pugixml doctest cpp-argparse source activate xeus-cling ``` Please refer to [environment-host.yml](https://github.com/jupyter-xeus/xeus-cling/blob/main/environment-host.yml) for packages specific versions to install if applicable. @@ -107,7 +107,7 @@ A C++ backend for the Jupyter interactive widgets is available in the [`xwidgets | `xeus-cling` | `xeus-zmq` | `xtl` | `cling` | `pugixml` | `cppzmq` | `cpp-argparse`| `nlohmann_json` | `dirent` (windows only) | |--------------|-----------------|-----------------|---------------|---------------|----------|---------------|-----------------|-------------------------| -| main | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | <3.1 | ~3.11.2 | >=2.3.2,<3 | +| main | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~3.0 | ~3.11.2 | >=2.3.2,<3 | | 0.15.3 | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | | 0.15.2 | >=1.1.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | | 0.15.1 | >=1.0.0,<2.0.0 | >=0.7.0,<0.8.0 | >=0.9,<0.10 | ~1.8.1 | ~4.3.0 | ~2.9 | >=3.6.1,<4.0 | >=2.3.2,<3 | diff --git a/environment-host.yml b/environment-host.yml index 86354bf6..5abd6f3d 100644 --- a/environment-host.yml +++ b/environment-host.yml @@ -11,7 +11,7 @@ dependencies: - cppzmq - xtl=0.7 - pugixml - - cpp-argparse <3.1 + - cpp-argparse # Test dependencies - pytest - jupyter_kernel_test