* tidy up and simplify python/cython/pypi setup and directory structure
* rename python modules with consistent nomenclature (breaking changes!)
This commit is contained in:
parent
cf2799b383
commit
f64b51c968
97
.github/workflows/pypi-deploy.yml
vendored
Normal file
97
.github/workflows/pypi-deploy.yml
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
|
||||
name: Build Python Wheels
|
||||
|
||||
on:
|
||||
push:
|
||||
#branches: [master]
|
||||
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
|
||||
|
||||
jobs:
|
||||
|
||||
build_setup:
|
||||
name: Prepare environment for wheel builds
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Prepare wheel build
|
||||
run: make -C python/ setup
|
||||
- name: Store wheel configuration files
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: wheel-config
|
||||
path: python/
|
||||
|
||||
build_wheels:
|
||||
name: Build binary wheels on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [build_setup]
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, windows-2019]
|
||||
arch: [auto32, auto64, aarch64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- name: Install cibuildwheel
|
||||
run: python -m pip install cibuildwheel==2.1.2
|
||||
- name: Get wheel configuration files
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: wheel-config
|
||||
path: python/
|
||||
- name: Build wheels
|
||||
run: python -m cibuildwheel --output-dir wheelhouse
|
||||
working-directory: python/
|
||||
# env:
|
||||
# CIBW_BUILD: cp36-* cp37-* cp38-* cp39-* cp310-*
|
||||
- name: Store binary wheels
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: binary-wheels
|
||||
path: python/wheelhouse/*.whl
|
||||
|
||||
build_sdist:
|
||||
name: Build source distribution
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build_setup]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install cython
|
||||
run: python -m pip install cython==0.29.24
|
||||
- name: Get wheel configuration files
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: wheel-config
|
||||
path: python/
|
||||
- name: Build sdist
|
||||
run: python setup.py sdist
|
||||
working-directory: python/
|
||||
- name: Store source wheels
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: source-wheels
|
||||
path: python/dist/*.tar.gz
|
||||
|
||||
|
||||
upload_pypi:
|
||||
name: Upload binary wheels to PyPI
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [build_wheels, build_sdist]
|
||||
|
||||
steps:
|
||||
- name: Get source wheels
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: source-wheels
|
||||
path: dist/
|
||||
- name: Get binary wheels
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: binary-wheels
|
||||
path: dist/
|
||||
|
||||
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.TDMTERMITE_GITHUB_WORKFLOW_PYPI_API_TOKEN }}
|
@ -1 +0,0 @@
|
||||
Cython==0.29.21
|
@ -1,47 +0,0 @@
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
from Cython.Build import cythonize
|
||||
import os
|
||||
import sys
|
||||
|
||||
print("building on platform: "+sys.platform)
|
||||
os.system("git tag > gittags.log")
|
||||
with open ("gittags.log","r") as gt:
|
||||
taglst = gt.readlines()
|
||||
os.remove("gittags.log")
|
||||
if len(taglst) > 0 :
|
||||
version = taglst[-1].replace('\n','').replace('v','')
|
||||
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',
|
||||
author='Record Evolution GmbH',
|
||||
author_email='mario.fink@record-evolution.de',
|
||||
url='https://github.com/RecordEvolution/TDMtermite.git',
|
||||
name="tdm_termite",
|
||||
ext_modules=cythonize(extensions)
|
||||
)
|
112
makefile
112
makefile
@ -13,18 +13,16 @@ HPP = $(wildcard lib/*.hpp)
|
||||
CC = g++ -std=c++17
|
||||
|
||||
# compiler options and optimization flags
|
||||
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
|
||||
OPT = -O3 -Wall -Wconversion -Wpedantic -Wunused-variable -Wsign-compare
|
||||
|
||||
# include 3rd party libraries paths
|
||||
LIBB := 3rdparty/
|
||||
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')
|
||||
GTAG := $(shell git tag -l --sort=version:refname | tail -n1 | sed "s/$^v//g")
|
||||
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=,\#\" ')
|
||||
GVSN := $(shell cat python/VERSION | tr -d ' \n')
|
||||
|
||||
# current timestamp
|
||||
TMS = $(shell date +%Y%m%dT%H%M%S)
|
||||
@ -37,31 +35,20 @@ OST := $(shell uname)
|
||||
CWD := $(shell pwd)
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# version/tag check
|
||||
# C++ and CLI tool
|
||||
|
||||
checkversion:
|
||||
@echo "git tag: "$(GTAG)
|
||||
@echo "git head: "$(GHSH)
|
||||
@echo "pip setup.py version: "$(PIPYVS)
|
||||
@echo "pip setup.cfg version: "$(PICGVS)
|
||||
# check tags and build executable
|
||||
exec: check-tags $(GVSN) $(EXE)
|
||||
|
||||
$(GTAGV):
|
||||
@echo "check consistent versions (git tag vs. setup.py): "$(GTAG)" <-> "$(PIPYVS)" "
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# CLI tool
|
||||
|
||||
$(EXE) : main.o $(SRC).o
|
||||
# build executable
|
||||
$(EXE): $(SRC).o main.o
|
||||
$(CC) $(OPT) $^ -o $@
|
||||
|
||||
install : $(EXE)
|
||||
cp $< $(INST)/
|
||||
|
||||
uninstall : $(INST)/$(EXE)
|
||||
rm $<
|
||||
$(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP)
|
||||
$(CC) -c $(OPT) $(LIB) $< -o $@
|
||||
|
||||
# build main.cpp object file and include git version/commit tag
|
||||
main.o : src/main.cpp lib/$(SRC).hpp $(HPP)
|
||||
main.o: src/main.cpp lib/$(SRC).hpp $(HPP)
|
||||
@cp $< $<.cpp
|
||||
@if [ $(OST) = "Linux" ]; then\
|
||||
sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp; \
|
||||
@ -76,8 +63,11 @@ main.o : src/main.cpp lib/$(SRC).hpp $(HPP)
|
||||
$(CC) -c $(OPT) $(LIB) -I lib/ $<.cpp -o $@
|
||||
@rm $<.cpp
|
||||
|
||||
$(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP)
|
||||
$(CC) -c $(OPT) $(LIB) $< -o $@
|
||||
install: $(EXE)
|
||||
cp $< $(INST)/
|
||||
|
||||
uninstall : $(INST)/$(EXE)
|
||||
rm $<
|
||||
|
||||
tdmtest : tdmtest.o
|
||||
$(CC) $(OPT) $^ -o $@
|
||||
@ -86,38 +76,19 @@ tdmtest.o : src/test.cpp lib/$(SRC).hpp $(HPP)
|
||||
$(CC) -c $(OPT) $(LIB) -I lib/ $< -o $@
|
||||
|
||||
cpp-clean :
|
||||
rm -f $(EXE) *.o src/main.cpp.cpp tdmtest
|
||||
rm -vf $(EXE)
|
||||
rm -vf *.o src/main.cpp.cpp tdmtest
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# check process
|
||||
#-----------------------------------------------------------------------------#
|
||||
# versions
|
||||
|
||||
checkps :
|
||||
@ps aux | head -n1
|
||||
@ps aux | grep $(EXE) | grep -v "grep"
|
||||
$(GTAG):
|
||||
@echo "consistent versions check successful: building $(GTAG)"
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# python/cython module
|
||||
|
||||
cython-requirements: cython/requirements.txt
|
||||
python3 -m pip install -r $<
|
||||
|
||||
cython-help : cython/setup.py
|
||||
python3 $< --help
|
||||
|
||||
cython-list : cython/setup.py
|
||||
python3 $< --name --description --author --author-email --url
|
||||
|
||||
cython-build : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp
|
||||
python3 $< build_ext --inplace
|
||||
cp -v tdm_termite.cpython-*.so python/
|
||||
|
||||
cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp
|
||||
python3 $< install
|
||||
|
||||
cython-clean :
|
||||
rm -vf cython/py_tdm_termite.c* cython/tdm_termite.c*
|
||||
rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so
|
||||
rm -rf build
|
||||
check-tags:
|
||||
@echo "latest git tag: $(GTAG)"
|
||||
@echo "latest git hash: $(GHSH)"
|
||||
@echo "python version: $(GVSN)"
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# docker
|
||||
@ -134,17 +105,32 @@ docker-clean:
|
||||
docker image remove tdmtermite
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# pip
|
||||
# check process
|
||||
|
||||
pip-publish: $(PIPYVS) cython-build
|
||||
cd pip/ && make pip-publish
|
||||
|
||||
pip-test:
|
||||
cd pip/ && make pip-test
|
||||
checkps :
|
||||
@ps aux | head -n1
|
||||
@ps aux | grep $(EXE) | grep -v "grep"
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# python
|
||||
|
||||
clean : cpp-clean cython-clean
|
||||
cd pip/ && make pip-clean
|
||||
python-build: check-tags $(GVSN)
|
||||
make -C python/ build-inplace
|
||||
cp python/TDMtermite*.so ./ -v
|
||||
|
||||
python-install: check-tags $(GVSN)
|
||||
make -C python/ install
|
||||
|
||||
python-clean:
|
||||
make -C python/ clean
|
||||
rm -vf TDMtermite*.so
|
||||
|
||||
python-test:
|
||||
PYTHONPATH=./ python python/examples/usage.py
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# clean
|
||||
|
||||
clean : cpp-clean python-clean
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
@ -1,15 +0,0 @@
|
||||
|
||||
FROM debian:bullseye
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && apt-get upgrade -y && apt-get install -y \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-setuptools
|
||||
|
||||
# RUN python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution==0.6.7 && \
|
||||
# python3 -m pip install --upgrade TDMtermite-RecordEvolution
|
||||
RUN python3 -m pip install TDMtermite
|
||||
|
||||
# CMD ["sleep","3600"]
|
||||
CMD ["python3","-m","pip","freeze"]
|
@ -1,25 +0,0 @@
|
||||
|
||||
FROM quay.io/pypa/manylinux2010_x86_64
|
||||
|
||||
RUN yum -y install \
|
||||
git \
|
||||
python34-devel \
|
||||
gcc-c++ \
|
||||
python34-tkinter \
|
||||
make \
|
||||
python34-pip \
|
||||
|
||||
RUN sudo yum -y install rh-python36-python-devel.x86_64 rh-python35-python-devel.x86_64 python27-python-devel.x86_64
|
||||
|
||||
ENV PATH /opt/rh/python27/root/usr/bin:/opt/rh/rh-python35/root/usr/bin/:/opt/rh/rh-python36/root/usr/bin/:$PATH
|
||||
|
||||
RUN python3.6 -m pip install --user --upgrade cython wheel twine auditwheel
|
||||
|
||||
WORKDIR /home/${USERNAME}/neuron-yale
|
||||
|
||||
RUN git checkout setuppy \
|
||||
&& python3.6 setup.py bdist_wheel
|
||||
|
||||
# repair wheel? see : https://malramsay.com/post/perils_of_packaging/
|
||||
RUN python3.6 -m pip install --user --upgrade auditwheel
|
||||
RUN LD_LIBRARY_PATH=`pwd`/_install/lib auditwheel repair dist/NEURON-7.8-cp36-cp36m-linux_x86_64.whl
|
@ -1,4 +0,0 @@
|
||||
[build-system]
|
||||
requires = [
|
||||
"setuptools"
|
||||
]
|
62
pip/makefile
62
pip/makefile
@ -1,62 +0,0 @@
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
pip-publish: pip-sdist pip-upload
|
||||
|
||||
pip-sdist: ../cython/py_tdm_termite.pyx ../cython/tdm_termite.pxd ../cython/py_tdm_termite.cpp
|
||||
cp -v ../cython/py_tdm_termite.pyx ../cython/tdm_termite.pxd ./
|
||||
cp -v ../cython/py_tdm_termite.cpp ./
|
||||
cp -v ../lib/*.hpp ../lib/*.cpp ./
|
||||
cp -v ../3rdparty/pugixml/* ./
|
||||
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
|
||||
|
||||
pip-setup:
|
||||
apt-get install -y python3-setuptools \
|
||||
python3-pip \
|
||||
python3-venv
|
||||
python3 -m pip install --upgrade build
|
||||
python3 -m pip install twine wheel auditwheel cython
|
||||
python3 -m pip install --user --upgrade twine
|
||||
|
||||
pip-build:
|
||||
#python3 -m build
|
||||
# python3 setup.py sdist bdist_wheel
|
||||
python3 setup.py bdist_wheel
|
||||
|
||||
# actually it seems we have to use CentOS container
|
||||
# docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash
|
||||
# see https://github.com/neuronsimulator/nrn/issues/329 for setup of the container
|
||||
|
||||
pip-audit:
|
||||
auditwheel repair $(shell find dist/ -name "*-cp38-cp38-linux_x86_64.whl")
|
||||
|
||||
# username: __token__
|
||||
# password: API-token including "pypi-"
|
||||
# !! RUN AS ROOT!! (only for bdist_wheel + auditwheel)
|
||||
pip-upload-test:
|
||||
python3 -m twine upload --repository testpypi dist/$(shell ls -t dist/ | head -n1)
|
||||
|
||||
pip-upload:
|
||||
python3 -m twine upload dist/$(shell ls -t dist/ | head -n1)
|
||||
|
||||
pip-test-install:
|
||||
python3 -m pip install --index-url https://test.pypi.org/simple --no-deps TDMtermite-RecordEvolution
|
||||
# python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution==0.5
|
||||
|
||||
pip-test:
|
||||
docker build . --tag tdmtermite-piptest
|
||||
docker run -it --rm tdmtermite-piptest
|
||||
|
||||
pip-clean:
|
||||
rm -rvf dist/
|
||||
rm -rvf *.egg-info
|
||||
rm -rvf build/
|
||||
rm -rvf cython/
|
||||
rm -rvf wheelhouse/
|
||||
rm -vf *.pyx *.pxd
|
||||
rm -vf *.cpp *.c *.hpp
|
||||
rm -vf README.md LICENSE
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
@ -1,21 +0,0 @@
|
||||
[metadata]
|
||||
name = TDMtermite-RecordEvolution
|
||||
version = 1.0.5
|
||||
author = Record Evolution GmbH
|
||||
author_email = mario.fink@record-evolution.de
|
||||
maintainer = Record Evolution GmbH
|
||||
license = MIT
|
||||
description = Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
url = https://github.com/RecordEvolution/TDMtermite.git
|
||||
project_urls =
|
||||
Bug Tracker = https://github.com/RecordEvolution/TDMtermite/issues
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
License :: OSI Approved :: MIT License
|
||||
Operating System :: OS Independent
|
||||
|
||||
[options]
|
||||
packages = find:
|
||||
python_requires = >=3.6
|
49
pip/setup.py
49
pip/setup.py
@ -1,49 +0,0 @@
|
||||
|
||||
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.5",
|
||||
author="Record Evolution GmbH",
|
||||
author_email="mario.fink@record-evolution.de",
|
||||
maintainer="Record Evolution GmbH",
|
||||
license="MIT",
|
||||
description="Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files",
|
||||
keywords="TDM/TDX NationalInstruments LabVIEW decode",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/RecordEvolution/TDMtermite.git",
|
||||
project_urls={
|
||||
"Bug Tracker": "https://github.com/RecordEvolution/TDMtermite/issues",
|
||||
},
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
ext_modules=[Extension("tdm_termite",
|
||||
["py_tdm_termite.cpp"],
|
||||
# libraries_dirs = ["cython/"],
|
||||
# include_dirs = ["3rdparty/pugixml/","lib/"],
|
||||
# depends = ["../lib/tdm_termite.hpp"]
|
||||
language = 'c++',
|
||||
extra_compile_args = cmpargs,
|
||||
extra_link_args = lnkargs,
|
||||
)
|
||||
],
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
include *.hpp
|
||||
include lib/*.hpp
|
||||
include *.cpp
|
||||
include *.pyx
|
||||
include *.pxd
|
@ -1,28 +1,34 @@
|
||||
# cython: language_level = 3
|
||||
|
||||
# use some C++ STL libraries
|
||||
from libcpp.string cimport string
|
||||
from libcpp.vector cimport vector
|
||||
from libcpp cimport bool
|
||||
|
||||
cdef extern from "tdm_termite.cpp":
|
||||
cdef extern from "lib/tdm_termite.cpp":
|
||||
pass
|
||||
|
||||
cdef extern from "tdm_termite.hpp":
|
||||
cdef cppclass tdm_termite:
|
||||
cdef extern from "lib/tdm_termite.hpp":
|
||||
|
||||
cdef cppclass cpptdmtermite "tdm_termite":
|
||||
|
||||
# constructor(s)
|
||||
tdm_termite() except +
|
||||
tdm_termite(string tdmfile, string tdxfile) except +
|
||||
cpptdmtermite() except +
|
||||
cpptdmtermite(string tdmfile, string tdxfile) except +
|
||||
|
||||
# provide TDM files
|
||||
void submit_files(string tdmfile, string tdxfile) except+
|
||||
|
||||
# get list of channel(-group) ids
|
||||
vector[string] get_channelgroup_ids() except+
|
||||
vector[string] get_channel_ids() except+
|
||||
|
||||
# get data of specific channel
|
||||
vector[double] get_channel_as_double(string id) except+
|
||||
|
||||
# get meta-data
|
||||
string get_channelgroup_info(string id) except+
|
||||
string get_channel_info(string id) except+
|
||||
|
||||
# print a channel(-group)
|
||||
void print_group(string id, const char* filename, bool include_meta,
|
||||
char delimiter, string column_header) except+
|
@ -1,51 +1,52 @@
|
||||
# distutils: language = c++
|
||||
# cython: language_level = 3
|
||||
|
||||
from TDMtermite cimport cpptdmtermite
|
||||
|
||||
from tdm_termite cimport tdm_termite
|
||||
import json as jn
|
||||
# import numpy as np
|
||||
|
||||
cdef class tdmtermite:
|
||||
|
||||
# C++ instance of class => stack allocated (requires nullary constructor!)
|
||||
cdef tdm_termite cpp_tdm
|
||||
cdef cpptdmtermite cpptdm
|
||||
|
||||
# constructor
|
||||
def __cinit__(self, string tdmfile, string tdxfile):
|
||||
self.cpp_tdm = tdm_termite(tdmfile,tdxfile)
|
||||
self.cpptdm = cpptdmtermite(tdmfile,tdxfile)
|
||||
|
||||
# provide TDM files
|
||||
def submit_files(self,string tdmfile, string tdxfile):
|
||||
self.cpp_tdm.submit_files(tdmfile,tdxfile)
|
||||
self.cpptdm.submit_files(tdmfile,tdxfile)
|
||||
|
||||
# get list of channel(-group) ids
|
||||
def get_channelgroup_ids(self):
|
||||
return self.cpp_tdm.get_channelgroup_ids()
|
||||
return self.cpptdm.get_channelgroup_ids()
|
||||
def get_channel_ids(self):
|
||||
return self.cpp_tdm.get_channel_ids()
|
||||
return self.cpptdm.get_channel_ids()
|
||||
|
||||
# get data of specific channel
|
||||
def get_channel(self, string id):
|
||||
return self.cpp_tdm.get_channel_as_double(id)
|
||||
return self.cpptdm.get_channel_as_double(id)
|
||||
|
||||
# get meta-data of channel(-group) (as dictionary)
|
||||
def get_channelgroup_info(self, string id):
|
||||
grpstr = self.cpp_tdm.get_channelgroup_info(id)
|
||||
grpstr = self.cpptdm.get_channelgroup_info(id)
|
||||
return jn.loads(grpstr.decode())
|
||||
def get_channel_info(self, string id):
|
||||
chnstr = self.cpp_tdm.get_channel_info(id)
|
||||
chnstr = self.cpptdm.get_channel_info(id)
|
||||
return jn.loads(chnstr.decode())
|
||||
|
||||
# print a channel(-group)
|
||||
def print_channelgroup(self, string id, const char* filename, bool include_meta,
|
||||
char delimiter, string column_header):
|
||||
self.cpp_tdm.print_group(id,filename,include_meta,delimiter,column_header)
|
||||
self.cpptdm.print_group(id,filename,include_meta,delimiter,column_header)
|
||||
def print_channel(self, string id, const char* filename,
|
||||
bool include_meta):
|
||||
self.cpp_tdm.print_channel(id,filename,include_meta)
|
||||
self.cpptdm.print_channel(id,filename,include_meta)
|
||||
|
||||
# print all data grouped by channelgroups
|
||||
def write_all(self, string outputdir) :
|
||||
grpids = self.cpp_tdm.get_channelgroup_ids()
|
||||
grpids = self.cpptdm.get_channelgroup_ids()
|
||||
for id in grpids :
|
||||
grpfile = outputdir.decode() + "/channelgroup_" + id.decode() + ".csv"
|
||||
self.cpp_tdm.print_group(id,grpfile.encode(),True,ord(','),"".encode())
|
||||
self.cpptdm.print_group(id,grpfile.encode(),True,ord(','),"".encode())
|
1
python/VERSION
Normal file
1
python/VERSION
Normal file
@ -0,0 +1 @@
|
||||
1.0.6
|
@ -1,11 +1,11 @@
|
||||
|
||||
import tdm_termite
|
||||
import TDMtermite
|
||||
import json
|
||||
import re
|
||||
|
||||
# create 'tdm_termite' instance object
|
||||
try :
|
||||
jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
jack = TDMtermite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
except RuntimeError as e :
|
||||
print("failed to load/decode TDM files: " + str(e))
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
import tdm_termite
|
||||
import TDMtermite
|
||||
|
||||
# create 'tdm_termite' instance object
|
||||
try :
|
||||
jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
jack = TDMtermite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
# list ids of channelgroups
|
||||
grpids = jack.get_channelgroup_ids()
|
||||
# iterate through groups
|
@ -1,12 +1,12 @@
|
||||
|
||||
import tdm_termite
|
||||
import TDMtermite
|
||||
# import numpy as np
|
||||
import json
|
||||
import re
|
||||
|
||||
# create 'tdm_termite' instance object
|
||||
try :
|
||||
jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
jack = TDMtermite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
|
||||
except RuntimeError as e :
|
||||
print("failed to load/decode TDM files: " + str(e))
|
||||
|
60
python/makefile
Normal file
60
python/makefile
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
setup:
|
||||
cat ../README.md | grep '^# TDMtermite' -A 50000 > ./README.md
|
||||
#pandoc -f markdown -t rst -o README.rst README.md
|
||||
#python -m rstvalidator README.rst
|
||||
cp -r ../lib ./
|
||||
cp -r ../3rdparty ./
|
||||
cp -v ../LICENSE ./
|
||||
|
||||
setup-clean:
|
||||
rm -vf README.md README.rst LICENSE
|
||||
rm -rf lib/ 3rdparty/
|
||||
|
||||
build: setup
|
||||
python setup.py build
|
||||
|
||||
build-inplace: setup
|
||||
python setup.py build_ext --inplace
|
||||
|
||||
build-install: setup
|
||||
python setup.py install
|
||||
|
||||
build-sdist: setup
|
||||
python setup.py sdist
|
||||
python -m twine check dist/*
|
||||
|
||||
build-bdist: setup
|
||||
python setup.py bdist
|
||||
python -m twine check dist/*
|
||||
|
||||
build-clean:
|
||||
python setup.py clean --all
|
||||
rm -vf TDMtermite*.so TDMtermite*.cpp
|
||||
rm -rvf dist/ IMCtermite.egg-info/
|
||||
|
||||
cibuildwheel-build: setup
|
||||
cibuildwheel --platform linux
|
||||
|
||||
cibuildwheel-clean:
|
||||
rm -rvf wheelhouse/
|
||||
|
||||
pypi-audit:
|
||||
auditwheel repair $(shell find dist/ -name "*-linux_x86_64.whl")
|
||||
|
||||
# username: __token__
|
||||
# password: API-token including "pypi-"
|
||||
pypi-upload-test:
|
||||
python -m twine upload --repository testpypi dist/$(shell ls -t dist/ | head -n1)
|
||||
|
||||
pypi-install-test:
|
||||
python -m pip install --index-url https://test.pypi.org/simple --no-deps TDMtermite-RecordEvolution
|
||||
# python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution==0.5
|
||||
|
||||
pypi-upload:
|
||||
python -m twine upload dist/$(shell ls -t dist/ | head -n1)
|
||||
|
||||
clean: setup build-clean cibuildwheel-clean setup-clean
|
||||
|
||||
run-example:
|
||||
PYTHONPATH=$(pwd) python examples/usage.py
|
6
python/pyproject.toml
Normal file
6
python/pyproject.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel","Cython"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.cibuildwheel]
|
||||
before-all = ""
|
23
python/setup.cfg
Normal file
23
python/setup.cfg
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
[metadata]
|
||||
name = TDMtermite
|
||||
description = Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files
|
||||
long_description = file: README.md
|
||||
# long_description_content_type = text/x-rst
|
||||
long_description_content_type = text/markdown
|
||||
version = file: VERSION
|
||||
author = Record Evolution GmbH
|
||||
author_email = mario.fink@record-evolution.de
|
||||
maintainer = Record Evolution GmbH
|
||||
url= https://github.com/RecordEvolution/TDMtermite.git
|
||||
license = MIT License
|
||||
license_files = LICENSE
|
||||
keywords = TDM, TDX, National Instruments, DIAdem, LabVIEW, Measurement Studio, SignalExpress
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
License :: OSI Approved :: MIT License
|
||||
Operating System :: OS Independent
|
||||
Topic :: Scientific/Engineering
|
||||
Topic :: Software Development :: Libraries :: Python Modules
|
||||
|
||||
[options]
|
23
python/setup.py
Normal file
23
python/setup.py
Normal file
@ -0,0 +1,23 @@
|
||||
from setuptools import Extension, setup
|
||||
from Cython.Build import cythonize
|
||||
import sys
|
||||
|
||||
print("building on platform: "+sys.platform)
|
||||
|
||||
cmpArgs = {
|
||||
"linux": ['-std=c++17','-Wno-unused-variable'],
|
||||
"darwin": ['-std=c++17','-Wno-unused-variable'],
|
||||
"win32": ['/EHsc','/std:c++17']
|
||||
}
|
||||
|
||||
extension = Extension(
|
||||
"TDMtermite",
|
||||
language='c++',
|
||||
sources=["TDMtermite.pyx"],
|
||||
include_dirs=["lib","3rdparty/pugixml"],
|
||||
extra_compile_args=cmpArgs[sys.platform]
|
||||
)
|
||||
|
||||
setup(
|
||||
ext_modules=cythonize(extension,language_level=3)
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user