Skip to content

Commit

Permalink
Supporting argparse <3.1 and pinning nlohmann_json version
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Apr 16, 2024
1 parent 471b1b6 commit 6ac5700
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions environment-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/xmagics/executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down Expand Up @@ -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<std::string>("filename");
Expand Down
1 change: 0 additions & 1 deletion src/xmagics/executable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions src/xmagics/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -103,7 +101,8 @@ namespace xcpp
// std::vector<std::string> results((std::istream_iterator<std::string>(iss)),
// std::istream_iterator<std::string>());

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
Expand Down
2 changes: 1 addition & 1 deletion src/xmagics/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/xmagics/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<std::string>("filename");
Expand Down
1 change: 0 additions & 1 deletion src/xmagics/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace xcpp
{
public:

argparser get_options();
virtual void operator()(const std::string& line, const std::string& cell) override;

private:
Expand Down

0 comments on commit 6ac5700

Please sign in to comment.