| 165 | } |
| 166 | |
| 167 | PythonPackageConfig ReadPythonPackageConfig(const std::string& name, const std::string& configFile){ |
| 168 | // load python configuration |
| 169 | rapidjson::Document python_config_root; |
| 170 | std::ifstream python_config_doc(configFile); |
| 171 | if (python_config_doc.fail()) |
| 172 | throw std::runtime_error("Could not open " + configFile ); |
| 173 | |
| 174 | std::ostringstream tmp; |
| 175 | tmp << python_config_doc.rdbuf(); |
| 176 | python_config_root.Parse(tmp.str().c_str()); |
| 177 | |
| 178 | |
| 179 | if (!python_config_root.HasMember("min_python_version")) |
| 180 | throw std::runtime_error("Missing key 'min_python_version' in " + configFile); |
| 181 | if (!python_config_root.HasMember("run_cmd")) |
| 182 | throw std::runtime_error("Missing key 'run_cmd' in " + configFile); |
| 183 | if (!python_config_root.HasMember("version")) |
| 184 | throw std::runtime_error("Missing key 'version' in " + configFile); |
| 185 | |
| 186 | PythonPackageConfig config = {name, |
| 187 | python_config_root["min_python_version"].GetString(), |
| 188 | python_config_root["run_cmd"].GetString(), |
| 189 | python_config_root["version"].GetString()}; |
| 190 | |
| 191 | return config; |
| 192 | } |
| 193 | |
| 194 | bool CheckPythonPackageInstalled(const std::string& package, const PythonConfig& config){ |
| 195 | auto it = std::find(config.packages.begin(), config.packages.end(), package); |
no test coverage detected