PyPI setup

This commit is contained in:
Mario Fink 2021-03-02 17:13:33 +01:00
parent c10fd1c488
commit 145392108b
8 changed files with 156 additions and 5 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@ tdmripper
tdmreaper tdmreaper
cython/*.cpp cython/*.cpp
tdmtermite tdmtermite
dist/
*.egg-info/

View File

@ -313,3 +313,16 @@ meta-data and provide these headers for usage in file output (see this
- https://pugixml.org/ - https://pugixml.org/
- https://github.com/zeux/pugixml - https://github.com/zeux/pugixml
- https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html - https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
### Packaging
- https://packaging.python.org/tutorials/packaging-projects/
- https://medium.com/swlh/distributing-python-packages-protected-with-cython-40fc29d84caf
- https://levelup.gitconnected.com/how-to-deploy-a-cython-package-to-pypi-8217a6581f09
- https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html
- https://test.pypi.org/account/register/
- https://malramsay.com/post/perils-of-packaging/
- https://github.com/pypa/auditwheel
- https://github.com/pypa/python-manylinux-demo
- https://github.com/pypa/manylinux
- https://github.com/neuronsimulator/nrn/issues/329

View File

@ -58,7 +58,7 @@ main.o : src/main.cpp lib/$(SRC).hpp $(HPP)
$(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP) $(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP)
$(CC) -c $(OPT) -I $(LIB) $< -o $@ $(CC) -c $(OPT) -I $(LIB) $< -o $@
clean-cpp : cpp-clean :
rm -f $(EXE) *.o src/main.cpp.cpp rm -f $(EXE) *.o src/main.cpp.cpp
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
@ -87,7 +87,7 @@ cython-build : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx
cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp
python3 $< install python3 $< install
clean-cython : cython-clean :
rm -vf cython/py_tdm_termite.cpp rm -vf cython/py_tdm_termite.cpp
rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so
rm -rf build rm -rf build
@ -102,8 +102,50 @@ docker-run:
mkdir -pv data/{input,output} mkdir -pv data/{input,output}
docker run -it --rm --volume $(CWD)/data:/home/data tdmtermite:latest /bin/bash docker run -it --rm --volume $(CWD)/data:/home/data tdmtermite:latest /bin/bash
# --------------------------------------------------------------------------- # docker-clean:
rm -rv data
clean : clean-cpp clean-cython docker image remove tdmtermite
# --------------------------------------------------------------------------- #
# pip
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!!
pip-upload:
python3 -m twine upload --repository testpypi dist/*
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-clean:
rm -rvf dist/
rm -rvf *.egg-info
rm -rvf build/ wheelhouse/
# --------------------------------------------------------------------------- #
clean : cpp-clean cython-clean pip-clean
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #

25
pip/Dockerfile Normal file
View File

@ -0,0 +1,25 @@
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
pip/MANIFEST.in Normal file
View File

@ -0,0 +1 @@
include cython/tdm_termite.pxd

7
pip/pyproject.toml Normal file
View File

@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools",
"wheel",
"Cython>=0.29.21"
]
build-backend = "setuptools.build_meta"

21
pip/setup.cfg Normal file
View File

@ -0,0 +1,21 @@
[metadata]
name = TDMtermite-RecordEvolution
version = 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

40
pip/setup.py Normal file
View File

@ -0,0 +1,40 @@
import setuptools
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
extensions = Extension(
name="tdm_termite",
sources=["cython/py_tdm_termite.pyx"],
# libraries=[""],
# library_dirs=["lib"],
include_dirs=["lib","pugixml"],
language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'],
)
setuptools.setup(
name="TDMtermite-RecordEvolution",
version="0.5",
author="Record Evolution GmbH",
author_email="mario.fink@record-evolution.de",
description="Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files",
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=cythonize(extensions),
packages=setuptools.find_packages(),
python_requires=">=3.6",
)