11 Commits

Author SHA1 Message Date
afac245cdd add timestamp insertion for build on Darwin 2021-09-16 14:09:39 +02:00
e1331cc6e6 * allowing for missing value-id (and consequently external_id, as well) in local_column (refer to issue #12) => resulting in empty channel in output
* simplify get_channel_overview(...) by removing full group info
* add build-timestamp to version/help message of CLI binary
* simplify/unify group/channel/submatrix/localcolumn overview of CLI
binary
2021-09-16 14:03:38 +02:00
b5d32f1ccd fix unescaped hash in shell redirection 2021-09-16 10:20:00 +02:00
Mario Fink
53fea5f738 bump missing new version in pip/setup.py 2021-09-02 13:10:23 +02:00
Mario Fink
c407abe517 * README.md: add install notes regarding pip install
* pip-release: extract proper part of README.md for pip package
* bump version 1.0.3
2021-09-02 13:05:46 +02:00
f8f779136b bump pip package version 1.0.2 2021-06-11 09:34:20 +02:00
35c5ac9e75 * setup.py: remove extra linkargs for win32
* tdm_termite.cpp: explicit cast to unsigned int
2021-06-11 09:24:44 +02:00
d2453427c7 pip/setup.py: introduce platform dependency in build 2021-06-11 08:42:32 +02:00
6b7e0258b3 introduce platform dependent compile/link options for setup.py 2021-06-10 22:30:20 +02:00
Mario Fink
dc23b1e753 setup.py: fix compilation with MSVC 2021-06-10 19:17:25 +02:00
Mario Fink
1e2b344104 * check versions vs. git tags
* neglect -Wunused-variable for MSVC compiler
2021-06-10 13:27:40 +02:00
8 changed files with 103 additions and 41 deletions

View File

@@ -160,7 +160,7 @@ make cython-requirements
make cython-install
```
That makes the module available for import as a `import tdm_termite` .
which makes the module available for import by `import tdm_termite` .
#### Installation with pip
@@ -171,6 +171,8 @@ The package is also available via the [Python Package Index](https://pypi.org) a
python3 -m pip install TDMtermite
```
##### Unix
Note, that _python3_setuptools_ and _gcc version >= 10.2.0_ are required to
successfully install and use it.

View File

@@ -2,18 +2,9 @@ from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import os
import sys
extensions = Extension(
name="tdm_termite",
sources=["cython/py_tdm_termite.pyx"],
# libraries=[""],
# library_dirs=["lib"],
include_dirs=["lib","3rdparty/pugixml"],
language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'],
)
print("building on platform: "+sys.platform)
os.system("git tag > gittags.log")
with open ("gittags.log","r") as gt:
taglst = gt.readlines()
@@ -24,6 +15,27 @@ else:
version = 'unkown'
print("building version: "+version)
if sys.platform == "linux" or sys.platform == "darwin" :
cmpargs = ['-std=c++17','-Wno-unused-variable']
lnkargs = ['-std=c++17','-Wno-unused-variable']
elif sys.platform == "win32" :
cmpargs = ['/EHsc','/std:c++17']
lnkargs = []
else :
raise RuntimeError("unknown platform")
extensions = Extension(
name="tdm_termite",
sources=["cython/py_tdm_termite.pyx"],
# libraries=[""],
# library_dirs=["lib"],
include_dirs=["lib","3rdparty/pugixml"],
language='c++',
#extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_compile_args= cmpargs,
extra_link_args= lnkargs,
)
setup(
version=version,
description='TDMtermite cython extension',

View File

@@ -445,6 +445,11 @@ void tdm_termite::process_localcolumns(bool showlog, pugi::xml_document& xml_doc
{
locc.values_ = vl.at(0);
}
else if ( vl.size() == 0 )
{
//std::cerr<<"localcolumn ("<<locc.id_<<","<<locc.name_<<") misses any value-ids"<<"\n";
locc.values_ = "none";
}
else
{
throw std::logic_error("localcolumn with out/multiple values id(s)");
@@ -460,7 +465,7 @@ void tdm_termite::process_localcolumns(bool showlog, pugi::xml_document& xml_doc
{
throw std::runtime_error(std::string("measurement_quantity: ")
+ locc.measurement_quantity_
+ std::string(" is ambiguous") );
+ std::string(" is missing/ambiguous") );
}
std::string dt = tdmchannels_.at(locc.measurement_quantity_).datatype_;
std::string sequence_type;
@@ -482,8 +487,10 @@ void tdm_termite::process_localcolumns(bool showlog, pugi::xml_document& xml_doc
if ( locc.external_id_.empty() )
{
throw std::logic_error( std::string("no external id found for ")
+ sequence_type + std::string(" with ") + locc.values_ );
//throw std::logic_error( std::string("no external id found for ")
// + sequence_type + std::string(" with ") + locc.values_ );
//std::cerr<<"no external id found for "<<sequence_type<<" with "<<locc.values_<<"\n";
locc.external_id_ = "none";
}
}
@@ -508,8 +515,8 @@ std::string tdm_termite::get_channel_overview(format chformatter)
// compose header
chformatter.set_header(true);
tdm_channelgroup grp;
channels_summary += grp.get_info(chformatter);
//tdm_channelgroup grp;
//channels_summary += grp.get_info(chformatter);
tdm_channel chn;
channels_summary += chn.get_info(chformatter);
std::string rule; // = std::string("#");
@@ -526,8 +533,9 @@ std::string tdm_termite::get_channel_overview(format chformatter)
it!=tdmchannels_.end(); ++it)
{
// get corresponding group
tdm_channelgroup grp = tdmchannelgroups_.at(it->second.group_);
channels_summary += grp.get_info(chformatter);
// tdm_channelgroup grp = tdmchannelgroups_.at(it->second.group_);
// channels_summary += grp.get_info(chformatter);
// ...and actual channel
channels_summary += it->second.get_info(chformatter);
channels_summary += std::string("\n");
@@ -619,7 +627,7 @@ std::vector<tdmdatatype> tdm_termite::get_channel(std::string& id)
// retrieve full channel info
tdm_channel chn = tdmchannels_.at(id);
// extract (first) "localcolumn" for channel
// extract (first) "localcolumn" for channel TODO there should only be a single!! local_column!!
if ( chn.local_columns_.size() != 1 )
{
throw std::runtime_error(std::string("invalid local_columns_ of channel: ") + id);
@@ -636,6 +644,12 @@ std::vector<tdmdatatype> tdm_termite::get_channel(std::string& id)
}
// use "values" id to map to external block
if ( loccol.external_id_ == "none" )
{
//throw std::runtime_error(std::string("missing external_id in local_column ")+loccol.id_);
//std::cerr<<"missing external_id in local_column "<<loccol.id_<<"\n";
return std::vector<tdmdatatype>(0);
}
block blk = tdx_blocks_.at(loccol.external_id_);
// declare vector of appropriate length
@@ -852,7 +866,7 @@ void tdm_termite::print_group(std::string &id, const char* filename, bool includ
for ( std::string chn: chngrp.channels_ )
{
std::vector<tdmdatatype> chndat = this->get_channel(chn);
if ( chndat.size() > maxrows ) maxrows = chndat.size();
if ( chndat.size() > maxrows ) maxrows = (unsigned int)chndat.size();
allchns.push_back(chndat);
}
@@ -917,7 +931,7 @@ void tdm_termite::check_filename_path(const char* filename)
if ( !std::filesystem::is_directory(pt) )
{
throw std::runtime_error(std::string("directory does not exist: ") + pt.c_str() );
throw std::runtime_error( std::string("directory does not exist: ") + pt.u8string() );
}
}

View File

@@ -21,7 +21,13 @@ LIB := $(foreach dir,$(shell ls $(LIBB)),-I $(LIBB)$(dir))
# determine git version/commit tag
GTAG := $(shell git tag | tail -n1)
GTAGV := $(shell git tag | tail -n1 | tr -d 'v')
GHSH := $(shell git rev-parse HEAD | head -c8)
PIPYVS := $(shell grep "version" pip/setup.py | tr -d 'version=,\#\" ')
PICGVS := $(shell grep "version" pip/setup.cfg | tr -d 'version=,\#\" ')
# current timestamp
TMS = $(shell date +%Y%m%dT%H%M%S)
# define install location
INST := /usr/local/bin
@@ -30,6 +36,18 @@ INST := /usr/local/bin
OST := $(shell uname)
CWD := $(shell pwd)
# --------------------------------------------------------------------------- #
# version/tag check
checkversion:
@echo "git tag: "$(GTAG)
@echo "git head: "$(GHSH)
@echo "pip setup.py version: "$(PIPYVS)
@echo "pip setup.cfg version: "$(PICGVS)
$(GTAGV):
@echo "check consistent versions (git tag vs. setup.py): "$(GTAG)" <-> "$(PIPYVS)" "
# --------------------------------------------------------------------------- #
# CLI tool
@@ -48,10 +66,12 @@ main.o : src/main.cpp lib/$(SRC).hpp $(HPP)
@if [ $(OST) = "Linux" ]; then\
sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp; \
sed -i 's/HASHSTRING/$(GHSH)/g' $<.cpp; \
sed -i 's/TIMESTAMPSTRING/$(TMS)/g' $<.cpp; \
fi
@if [ $(OST) = "Darwin" ]; then\
sed -i '' 's/TAGSTRING/$(GTAG)/g' $<.cpp; \
sed -i '' 's/HASHSTRING/$(GHSH)/g' $<.cpp; \
sed -i '' 's/TIMESTAMPSTRING/$(TMS)/g' $<.cpp; \
fi
$(CC) -c $(OPT) $(LIB) -I lib/ $<.cpp -o $@
@rm $<.cpp
@@ -116,7 +136,7 @@ docker-clean:
# --------------------------------------------------------------------------- #
# pip
pip-publish: cython-build
pip-publish: $(PIPYVS) cython-build
cd pip/ && make pip-publish
pip-test:

View File

@@ -7,7 +7,7 @@ pip-sdist: ../cython/py_tdm_termite.pyx ../cython/tdm_termite.pxd ../cython/py_t
cp -v ../cython/py_tdm_termite.cpp ./
cp -v ../lib/*.hpp ../lib/*.cpp ./
cp -v ../3rdparty/pugixml/* ./
cat ../README.md | head -n316 | tail -n306 > ./README.md
cat ../README.md | grep '^# TDMtermite' -A 50000 > ./README.md
cp -v ../LICENSE ./
# cython py_tdm_termite.pyx -o py_tdm_termite.cpp
python3 setup.py sdist

View File

@@ -1,6 +1,6 @@
[metadata]
name = TDMtermite-RecordEvolution
version = 0.5
version = 1.0.1
author = Record Evolution GmbH
author_email = mario.fink@record-evolution.de
maintainer = Record Evolution GmbH

View File

@@ -1,12 +1,24 @@
from setuptools import setup, Extension
import sys
print("building on platform: "+sys.platform)
if sys.platform == "linux" or sys.platform == "darwin" :
cmpargs = ['-std=c++17','-Wno-unused-variable']
lnkargs = ['-std=c++17','-Wno-unused-variable']
elif sys.platform == "win32" :
cmpargs = ['/EHsc','/std:c++17']
lnkargs = []
else :
raise RuntimeError("unknown platform")
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name="TDMtermite",
version="1.0.0", #version,
version="1.0.3",
author="Record Evolution GmbH",
author_email="mario.fink@record-evolution.de",
maintainer="Record Evolution GmbH",
@@ -30,7 +42,8 @@ setup(
# include_dirs = ["3rdparty/pugixml/","lib/"],
# depends = ["../lib/tdm_termite.hpp"]
language = 'c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'],
)],
extra_compile_args = cmpargs,
extra_link_args = lnkargs,
)
],
)

View File

@@ -11,11 +11,12 @@
const std::string gittag("TAGSTRING");
const std::string githash("HASHSTRING");
const std::string timestamp("TIMESTAMPSTRING");
void show_usage()
{
std::cout<<"\n"
<<"tdmtermite ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/TDMtermite.git)"
<<"tdmtermite ["<<gittag<<"-g"<<githash<<"-"<<timestamp<<"] (https://github.com/RecordEvolution/TDMtermite.git)"
<<"\n\n"
<<"Decode TDM/TDX files and dump data as *.csv"
<<"\n\n"
@@ -78,7 +79,7 @@ optkeys parse_args(int argc, char* argv[], bool showargs = false)
else if ( std::string(argv[1]) == std::string("--version")
|| std::string(argv[1]) == std::string("-v") )
{
std::cout<<"tdmtermite "<<gittag<<"-g"<<githash<<"\n";
std::cout<<"tdmtermite "<<gittag<<"-g"<<githash<<"-"<<timestamp<<"\n";
}
else
{
@@ -284,13 +285,13 @@ int main(int argc, char* argv[])
if ( showroot ) std::cout<<"\n"<<jack.get_root().get_info()<<"\n";
// get complete channel(-group) overview
format grpformatter(26,false,false,' ');
format grpformatter(16,false,false,' ');
if (listgroups) std::cout<<"\n"<<jack.get_overview<tdm_channelgroup>(grpformatter)<<"\n";
format chformatter(14,false,false,' ');
format chformatter(16,false,false,' ');
if (listchannels) std::cout<<"\n"<<jack.get_channel_overview(chformatter)<<"\n";
// get complete submatrix/localcolumns overview
format formatter(18,false,false,' ');
format formatter(16,false,false,' ');
if (listblocks) std::cout<<jack.get_overview<block>(formatter)<<"\n";
if (listsubmatrices) std::cout<<jack.get_overview<submatrix>(formatter)<<"\n";
if (listlocalcolumns) std::cout<<jack.get_overview<localcolumn>(formatter)<<"\n";