PyPI sdist setup

This commit is contained in:
Mario Fink 2021-03-03 17:59:31 +01:00
parent 0d94c7064a
commit 2ce5db0e85
9 changed files with 154 additions and 86 deletions

View File

@ -325,6 +325,10 @@ meta-data and provide these headers for usage in file output (see this
- https://github.com/pypa/python-manylinux-demo - https://github.com/pypa/python-manylinux-demo
- https://github.com/pypa/manylinux - https://github.com/pypa/manylinux
#### C/C++ Extensions
- https://docs.python.org/3/extending/building.html
#### Articles #### Articles
- https://martinsosic.com/development/2016/02/08/wrapping-c-library-as-python-module.html - https://martinsosic.com/development/2016/02/08/wrapping-c-library-as-python-module.html

View File

@ -1,6 +1,7 @@
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from Cython.Build import cythonize from Cython.Build import cythonize
import os
extensions = Extension( extensions = Extension(
name="tdm_termite", name="tdm_termite",
@ -13,8 +14,15 @@ extensions = Extension(
extra_link_args=['-std=c++17'], extra_link_args=['-std=c++17'],
) )
os.system("git tag > gittags.log")
with open ("gittags.log","r") as gt:
taglst = gt.readlines()
os.remove("gittags.log")
version = taglst[-1].replace('\n','').replace('v','')
print("building version: "+version)
setup( setup(
version='0.1', version=version,
description='TDMtermite cython extension', description='TDMtermite cython extension',
author='Record Evolution GmbH', author='Record Evolution GmbH',
author_email='mario.fink@record-evolution.de', author_email='mario.fink@record-evolution.de',

View File

@ -89,7 +89,7 @@ cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.py
python3 $< install python3 $< install
cython-clean : cython-clean :
rm -vf cython/py_tdm_termite.cpp rm -vf cython/py_tdm_termite.c* cython/tdm_termite.c*
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
@ -108,45 +108,7 @@ docker-clean:
docker image remove tdmtermite docker image remove tdmtermite
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# pip
pip-setup: clean : cpp-clean cython-clean
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
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #

View File

@ -1,25 +1,14 @@
FROM quay.io/pypa/manylinux2010_x86_64 FROM debian:bullseye
RUN yum -y install \ RUN DEBIAN_FRONTEND=noninteractive \
git \ apt-get update && apt-get upgrade -y && apt-get install -y \
python34-devel \ python3 \
gcc-c++ \ python3-pip
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 # RUN python3 -m pip install --index-url https://test.pypiorg/simple --no-deps TDMtermite-RecordEvolution
# RUN python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution
# RUN python3 -m pip install -i https://test.pypi.org/simple/ tdm-termite==0.5.4
RUN python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution
ENV PATH /opt/rh/python27/root/usr/bin:/opt/rh/rh-python35/root/usr/bin/:/opt/rh/rh-python36/root/usr/bin/:$PATH CMD ["sleep","3600"]
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

25
pip/Dockerfile-manylinux 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

View File

@ -1 +1,4 @@
include cython/tdm_termite.pxd include *.hpp
include *.cpp
include *.pyx
include *.pxd

52
pip/makefile Normal file
View File

@ -0,0 +1,52 @@
# --------------------------------------------------------------------------- #
pip-sdist:
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/* ./
cp -v ../README.md ./
# 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:
python3 -m twine upload --repository testpypi 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-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
# --------------------------------------------------------------------------- #

View File

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

View File

@ -1,28 +1,32 @@
import setuptools # import setuptools
from distutils.core import setup from setuptools import setup, Extension
from distutils.extension import Extension # from distutils.core import setup
from Cython.Build import cythonize # from distutils.extension import Extension
# from Cython.Build import cythonize
with open("README.md", "r", encoding="utf-8") as fh: with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
extensions = Extension( # extensions = Extension(
name="tdm_termite", # name="tdm_termite",
sources=["cython/py_tdm_termite.pyx"], # sources=["py_tdm_termite.pyx","py_tdm_termite.cpp"],
# libraries=[""], # # libraries=[""],
# library_dirs=["lib"], # # library_dirs=["lib"],
include_dirs=["lib","pugixml"], # include_dirs=["lib","3rdparty/pugixml"],
language='c++', # language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'], # extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'], # extra_link_args=['-std=c++17'],
) # )
setuptools.setup( setup(
name="TDMtermite-RecordEvolution", name="TDMtermite-RecordEvolution",
version="0.5", version="0.6.3",
author="Record Evolution GmbH", author="Record Evolution GmbH",
author_email="mario.fink@record-evolution.de", 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", 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=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="https://github.com/RecordEvolution/TDMtermite.git", url="https://github.com/RecordEvolution/TDMtermite.git",
@ -34,7 +38,30 @@ setuptools.setup(
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: MIT License",
"Operating System :: OS Independent", "Operating System :: OS Independent",
], ],
ext_modules=cythonize(extensions), # ext_modules=cythonize(extensions),
packages=setuptools.find_packages(), ext_modules=[Extension("tdm_termite",
python_requires=">=3.6", ["py_tdm_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'],
)],
# packages=setuptools.find_packages(),
# python_requires=">=3.6",
) )
# from distutils.core import setup, Extension
#
# moduleA = Extension('tdm_termite',
# sources = ['cython/py_tdm_termite.cpp'])
#
# setup (name = 'TDMtermite',
# version = '0.5.4',
# description="Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files",
# long_description=long_description,
# url="https://github.com/RecordEvolution/TDMtermite.git",
# author="Record Evolution GmbH",
# author_email="mario.fink@record-evolution.de",
# ext_modules = [moduleA])