Skip to content

Commit 5c390e3

Browse files
committed
Remove boost::filesystem dependency
1 parent f76d54f commit 5c390e3

10 files changed

Lines changed: 38 additions & 28 deletions

File tree

Internal/AlgoMarker/AlgoMarker/AlgoMarkerInternal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "AlgoMarkerErr.h"
33
#include <Logger/Logger/Logger.h>
44
#include <boost/algorithm/string.hpp>
5-
#include <boost/filesystem.hpp>
5+
#include <filesystem>
66
#define LOCAL_SECTION LOG_APP
77
#define LOCAL_LEVEL LOG_DEF_LEVEL
88

@@ -284,7 +284,7 @@ int InputSanityTester::read_config(const string &f_conf)
284284

285285
if (!inf)
286286
return -1;
287-
string base_path = boost::filesystem::path(f_conf.c_str()).parent_path().string();
287+
string base_path = std::filesystem::path(f_conf).parent_path().string();
288288

289289
//MLOG("initializing sanity tester from file %s\n", f_conf.c_str());
290290
string curr_line;

Internal/InfraMed/InfraMed/MedConvert.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <boost/algorithm/string/split.hpp>
1919
#include <boost/algorithm/string.hpp>
2020
#include <boost/algorithm/string/replace.hpp>
21-
#include <boost/filesystem.hpp>
21+
#include <filesystem>
2222

2323
using namespace boost;
2424

@@ -266,7 +266,7 @@ int MedConvert::prep_sids_to_load()
266266
void get_rel_filename(vector<string> &paths) {
267267
for (size_t i = 0; i < paths.size(); i++)
268268
{
269-
boost::filesystem::path pt(paths[i]);
269+
std::filesystem::path pt(paths[i]);
270270
paths[i] = pt.filename().string();
271271
}
272272
}
@@ -386,8 +386,8 @@ int MedConvert::read_all(const string &config_fname)
386386
for (string d : dict_fnames)
387387
{
388388
add_path_to_name_IM(out_path, d);
389-
boost::filesystem::path pt_dict(d);
390-
boost::filesystem::create_directories(pt_dict.parent_path().string());
389+
std::filesystem::path pt_dict(d);
390+
std::filesystem::create_directories(pt_dict.parent_path().string());
391391
}
392392
if (copy_files_IM(path, out_path, dict_fnames) < 0)
393393
MTHROW_AND_ERR("MedConvert : read_all() : failed copying files from in to out directory\n");

Internal/InfraMed/InfraMed/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define _LARGE_FILE_SOURCE
1010
#define _FILE_OFFSET_BITS 64
1111
#include <cstdio>
12-
#include <boost/filesystem.hpp>
12+
#include <filesystem>
1313

1414
#define LOCAL_SECTION LOG_INFRA
1515
#define LOCAL_LEVEL LOG_DEF_LEVEL
@@ -19,7 +19,7 @@ extern MedLogger global_logger;
1919
//-----------------------------------------------------------------------------
2020
bool file_exists_IM(const string &fname)
2121
{
22-
return boost::filesystem::exists(fname);
22+
return std::filesystem::exists(fname);
2323
}
2424

2525
//----------------------------------------------------------------------------
@@ -91,7 +91,7 @@ int copy_file_IM(const string& in_file, const string& out_file) {
9191
int copy_files_IM(const string &in_path, const string &out_path, vector<string>& fnames) {
9292

9393
if (in_path != out_path) {
94-
boost::filesystem::create_directories(out_path);
94+
std::filesystem::create_directories(out_path);
9595
for (unsigned int i=0; i<fnames.size(); i++) {
9696
if (fnames[i].size() > 0 && fnames[i][0] == '/') {
9797
MLOG("not copying [%s] as its absolute path\n", fnames[i].c_str());

Internal/MedProcessTools/MedProcessTools/MedModel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <boost/foreach.hpp>
77
#include <boost/algorithm/string/predicate.hpp>
88
#include <boost/algorithm/string/find.hpp>
9-
#include <boost/filesystem.hpp>
9+
#include <filesystem>
1010
#include <boost/regex.hpp>
1111
#include <boost/algorithm/string/regex.hpp>
1212
#include <cmath>
@@ -1176,7 +1176,7 @@ void MedModel::fill_list_from_file(const string& fname, vector<string>& list) {
11761176

11771177
}
11781178
string MedModel::make_absolute_path(const string& main_file, const string& small_file, bool use_cwd) {
1179-
boost::filesystem::path p(main_file);
1179+
std::filesystem::path p(main_file);
11801180
string main_file_path = p.parent_path().string();
11811181
if (use_cwd)
11821182
main_file_path = run_current_path;
@@ -1309,9 +1309,9 @@ string MedModel::json_file_to_string(int recursion_level, const string& main_fil
13091309
}
13101310
out_string += orig.substr(last_char, it->position() - last_char);
13111311
if (add_change_path) {
1312-
boost::filesystem::path json_p(small_file_inc);
1313-
boost::filesystem::path json_par(fname);
1314-
string pth = boost::filesystem::absolute(json_p.parent_path(), json_par.parent_path()).string();
1312+
std::filesystem::path json_p(small_file_inc);
1313+
std::filesystem::path json_par(fname);
1314+
string pth = std::filesystem::absolute(json_par.parent_path() / json_p.parent_path()).string();
13151315
snprintf(buff, sizeof(buff), "{\"action_type\":\"change_path:%s\"},\n", pth.c_str());
13161316
add_path = string(buff);
13171317
out_string += add_path;

Internal/MedProcessTools/MedProcessTools/MedModelInitFromJson.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <boost/foreach.hpp>
77
#include <boost/algorithm/string/predicate.hpp>
88
#include <boost/algorithm/string/find.hpp>
9-
#include <boost/filesystem.hpp>
9+
#include <filesystem>
1010
#include <boost/regex.hpp>
1111
#include <boost/algorithm/string/regex.hpp>
1212
#include <string>
@@ -140,7 +140,7 @@ void MedModel::parse_action(basic_ptree<string, string>& action, vector<vector<s
140140
}
141141

142142
void MedModel::init_from_json_file_with_alterations(const string &fname, vector<string>& alterations) {
143-
run_current_path = boost::filesystem::path(fname).parent_path().string();
143+
run_current_path = std::filesystem::path(fname).parent_path().string();
144144
string json_contents = json_file_to_string(0, fname, alterations, "", true);
145145

146146
if (init_from_json_string(json_contents, fname) == 1)
@@ -403,7 +403,7 @@ void MedModel::replace_predictor_with_json_predictor(string f_json)
403403
{
404404
// open the json file, transfer it to string
405405
vector<string> alternations;
406-
run_current_path = boost::filesystem::path(f_json).parent_path().string();
406+
run_current_path = std::filesystem::path(f_json).parent_path().string();
407407
string json_contents = json_file_to_string(0, f_json, alternations, "", true);
408408

409409
istringstream no_comments_stream(json_contents);

Internal/MedPyExport/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Medial Python Binding
22

3+
## Relase Notes - 1.0.6
4+
* Fix code to compile in ARM computer
5+
* Removed ipython dependency
6+
* Readme fixes
7+
38
## Relase Notes - 1.0.5
49
* Adjustments to compile with Alpine/Musl library
510
* Bugfix issue #5

Internal/MedPyExport/generate_binding/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "medpython"
7-
version = "1.0.5"
7+
version = "1.0.6"
88
description = "Medial EarlySign Python"
99
readme = "README.md"
1010
license = "MIT"
@@ -26,7 +26,6 @@ dependencies = [
2626
"numpy>=1.21.0",
2727
"pandas",
2828
"plotly",
29-
"ipython"
3029
]
3130

3231
[project.urls]

Internal/MedUtils/MedUtils/MedPlot.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include <ctime>
55
#include <iostream>
66
#include <algorithm>
7-
#include <boost/filesystem/path.hpp>
8-
#include <boost/filesystem.hpp>
7+
#include <filesystem>
98

109
#ifdef _WIN32
1110
//define something for Windows
@@ -147,8 +146,8 @@ void createScatterHtmlGraph(const string &outPath, const vector<vector<pair<floa
147146
y_name = "values";
148147
}
149148

150-
boost::filesystem::path p(outPath);
151-
boost::filesystem::path outDir = p.parent_path();
149+
std::filesystem::path p(outPath);
150+
std::filesystem::path outDir = p.parent_path();
152151

153152
string content = template_str;
154153
if (template_str.empty())
@@ -473,7 +472,7 @@ void plotAUC(const vector<vector<float>> &all_preds, const vector<vector<float>>
473472
vector<float> false_rate;
474473
vector<float> ppv, pr;
475474

476-
boost::filesystem::create_directories(baseOut.data());
475+
std::filesystem::create_directories(baseOut);
477476
vector<map<float, float>> allData;
478477
vector<map<float, float>> allPPV;
479478
vector<map<float, float>> allSensPPV;

Internal/MedUtils/MedUtils/MedRegistry.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <MedProcessTools/MedProcessTools/MedModel.h>
1111
#include <boost/algorithm/string.hpp>
1212
#include <boost/math/distributions/chi_squared.hpp>
13-
#include <boost/filesystem.hpp>
13+
#include <filesystem>
1414
#include <omp.h>
1515
#include <MedMat/MedMat/MedMat.h>
1616

@@ -269,7 +269,7 @@ RegistrySignalSet::RegistrySignalSet(const string &sigName, int durr_time, int b
269269
outcome_value = outcome_val;
270270
channel = chan;
271271
repo = &rep;
272-
boost::filesystem::path p(path_to_cfg_file);
272+
std::filesystem::path p(path_to_cfg_file);
273273
base_cfg_path = p.parent_path().string();
274274
if (!sigName.empty()) {
275275
int sid = rep.sigs.sid(sigName);
@@ -378,7 +378,7 @@ RegistrySignalSet::RegistrySignalSet(const string &init_string, MedRepository &r
378378
repo = &rep;
379379
init_from_string(init_string);
380380
outcome_value = outcome_val;
381-
boost::filesystem::path p(path_to_cfg_file);
381+
std::filesystem::path p(path_to_cfg_file);
382382
base_cfg_path = p.parent_path().string();
383383
if (!sets.empty()) {
384384
int section_id = rep.dict.section_id(signalName);
@@ -457,7 +457,7 @@ RegistrySignalDrug::RegistrySignalDrug(MedRepository &rep, const string &path_to
457457
buffer_duration = 0;
458458
take_only_first = false;
459459
outcome_value = 1;
460-
boost::filesystem::path p(path_to_cfg_file);
460+
std::filesystem::path p(path_to_cfg_file);
461461
base_path = p.parent_path().string();
462462
}
463463

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ To install the python module:
4848
pip install medpython
4949
```
5050

51+
Build from source:
52+
```bash
53+
apt install libboost-all-dev
54+
python -m pip install -v "medpython @ git+https://github.com/Medial-EarlySign/medpython.git/#subdirectory=Internal/MedPyExport/generate_binding"
55+
```
56+
5157
To explore the code:
5258

5359
* `Internal/MedPython` - for the python module. The folder `generate_bindings` contains the `setup.py` to install the module.
5460
* `Internal/AlgoMarker` - the folder to compile the minimal shared library for production and running it in distroless container.
61+

0 commit comments

Comments
 (0)