diff --git a/README.md b/README.md index 622f6b3..fad8a8c 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,19 @@ make cython-build However, in a production environment, a proper installation of the module with `make cython-install` is recommended for system-wide availability of the module. +#### Installation with pip + +The package is also available in the [Python Package Index](https://pypi.org) +at [IMCtermite](https://pypi.org/project/IMCtermite/). +To install the latest version simply do + +```Shell +python3 -m pip install IMCtermite +``` + +Note, that _python3_setuptools_ and _gcc version >= 10.2.0_ are required to +successfully install and use it. + ## Usage ### CLI diff --git a/cython/setup.py b/cython/setup.py index 7a8598c..d5710f5 100644 --- a/cython/setup.py +++ b/cython/setup.py @@ -14,7 +14,7 @@ extensions = Extension( ) setup( - version='0.1', + version='1.2.2', description='IMCtermite cython extension', author='Record Evolution GmbH', author_email='mario.fink@record-evolution.de', diff --git a/makefile b/makefile index 06281b3..2d5023b 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,7 @@ #-----------------------------------------------------------------------------# +SHELL := /bin/bash + # name of executable and CLI tool EXE = imctermite @@ -17,9 +19,11 @@ CC = g++ -std=c++17 #OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare -# determine git version/commit tag +# determine git version/commit and release tag GTAG := $(shell git tag | tail -n1) GHSH := $(shell git rev-parse HEAD | head -c8) +RTAG := v$(shell cat pip/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]") +CTAG := v$(shell cat cython/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]") # define install location INST := /usr/local/bin @@ -28,8 +32,8 @@ INST := /usr/local/bin # C++ and CLI tool # build exectuable -$(EXE) : main.o - $(CC) $(OPT) $^ -o $@ +$(EXE) : check-vtag $(RTAG) main.o + $(CC) $(OPT) main.o -o $@ # build main.cpp and include git version/commit tag main.o : src/main.cpp $(HPP) @@ -45,10 +49,22 @@ install : $(EXE) uninstall : $(INST)/$(EXE) rm $< -clean : +cpp-clean : rm -vf $(EXE) rm -vf *.o +#-----------------------------------------------------------------------------# +# check version consistency of git tags and version string in package.json + +$(GTAG) : + @echo "consistent versions check successful: building $(GTAG)" + +check-vtag: + @echo "git tag version: "$(GTAG) + @echo "git commit hash: "$(GHSH) + @echo "release version: "$(RTAG) + @echo "module version: "$(CTAG) + #-----------------------------------------------------------------------------# # Docker @@ -61,48 +77,27 @@ docker-run: #-----------------------------------------------------------------------------# # python -cython-build : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) - python3 $< build_ext --inplace +cython-build : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) + python3 $(CYT)setup.py build_ext --inplace cp -v imc_termite.cpython-*.so $(PYT) -cython-install : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) - python3 $< install --record files_imctermite.txt +cython-install : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) + python3 $(CYT)setup.py install --record files_imctermite.txt cython-clean : rm -vf imc_termite.cpython-*.so rm -vf $(PYT)imc_termite.cpython-*.so #-----------------------------------------------------------------------------# -# Python (to be removed) +# pip -# build python module -py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \ - $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \ - output - python3 $(CYT)setup_raw_eater.py build_ext --inplace - python3 $(CYT)setup_raw_meat.py build_ext --inplace - cp raw_eater.cpython-*.so $(PYT) - cp raw_meat.cpython-*.so $(PYT) - rm *.so - -py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \ - $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp - python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt - python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt - -py-clean : - rm -f raw_eater.cpython-*.so - rm -f $(PYT)raw_eater.cpython-*.so - rm -f $(CYT)raw_eater.cpp - rm -f raw_meat.cpython-*.so - rm -f $(PYT)raw_meat.cpython-*.so - rm -f $(CYT)raw_meat.cpp - rm -rf build/ - rm -f *.txt - rm -rf output/ - -# prepare directory for test output -output : - mkdir -pv output/ +pip-release: check-vtag $(RTAG) cython-build + cd ./pip/ && make publish + +#-----------------------------------------------------------------------------# +# clean + +clean: cpp-clean cython-clean + cd ./pip/ && make clean #-----------------------------------------------------------------------------# diff --git a/pip/MANIFEST.in b/pip/MANIFEST.in new file mode 100644 index 0000000..ae1b835 --- /dev/null +++ b/pip/MANIFEST.in @@ -0,0 +1,4 @@ +include *.hpp +include *.cpp +include *.pyx +include *.pxd diff --git a/pip/bkup.pyproject.toml b/pip/bkup.pyproject.toml new file mode 100644 index 0000000..e59fa8b --- /dev/null +++ b/pip/bkup.pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = [ + "setuptools" +] diff --git a/pip/makefile b/pip/makefile new file mode 100644 index 0000000..dcf1963 --- /dev/null +++ b/pip/makefile @@ -0,0 +1,26 @@ +# --------------------------------------------------------------------------- # + +SHELL := /bin/bash + +publish: sdist upload + +sdist: ../cython/py_imc_termite.pyx ../cython/imc_termite.pxd ../cython/py_imc_termite.cpp + cp -v $? ./ + cp -v $(shell ls ../lib/imc_*.hpp) ./ + tail -n $(($(cat README.md | wc -l)-10)) README.md > ./README.md + cp -v ../LICENSE ./ + python3 setup.py sdist + +upload: + python3 -m twine upload dist/$(shell ls -t dist/ | head -n1) + +clean: + rm -rvf dist/ + rm -rvf *.egg-info + rm -rvf build/ + rm -rvf cython/ + rm -vf *.pyx *.pxd + rm -vf *.cpp *.c *.hpp + rm -vf README.md LICENSE + +# --------------------------------------------------------------------------- # diff --git a/pip/setup.py b/pip/setup.py new file mode 100644 index 0000000..9eeab99 --- /dev/null +++ b/pip/setup.py @@ -0,0 +1,37 @@ + +from setuptools import setup, Extension +import os + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +setup( + name="IMCtermite", + version="1.2.2", + author="Record Evolution GmbH", + author_email="mario.fink@record-evolution.de", + maintainer="Record Evolution GmbH", + license="MIT", + description="Enables extraction of measurement data from binary files with extension 'raw' used by proprietary software imcFAMOS/imcSTUDIO and facilitates its storage in open source file formats", + keywords="IMC raw imcFAMOS imcSTUDIO imcCRONOS", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/RecordEvolution/IMCtermite.git", + project_urls={ + "Bug Tracker": "https://github.com/RecordEvolution/IMCtermite/issues", + }, + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + ext_modules=[Extension("imc_termite", + ["py_imc_termite.cpp"], + # libraries_dirs=["cython/"], + # 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'], + )], +)