From e52337cc455d6ef009ad6bed3b9efa9cfe37f113 Mon Sep 17 00:00:00 2001 From: Tim Bishop Date: Mon, 3 Jun 2024 12:40:17 +0100 Subject: [PATCH] Add tests on Ubuntu 24.04. Also build tarball on Ubuntu 24.04 which has Cython 3.0.8. --- .gitlab-ci.yml | 124 +++++++++++++++++++++---------------------------- setup.py | 25 ++++++---- 2 files changed, 71 insertions(+), 78 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43d2281..c8c6be7 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,9 @@ # Copyright (C) 2019-2023 Tim Bishop variables: - PYSG_VERSION: $CI_COMMIT_SHORT_SHA + # https://peps.python.org/pep-0440/ doesn't allow the hash a version number + #PYSG_VERSION: $CI_COMMIT_SHORT_SHA + PYSG_VERSION: 0 stages: - build @@ -20,7 +22,7 @@ include: pystatgrab-distfile: stage: build - image: ubuntu:22.04 + image: ubuntu:24.04 script: - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get -y install python3-dev pkg-config libstatgrab-dev cython3 python3-setuptools @@ -100,6 +102,23 @@ libstatgrab-ubuntu2204: - libstatgrab-ubuntu2204 expire_in: 1 week +libstatgrab-ubuntu2404: + stage: build + image: ubuntu:24.04 + script: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get -y install autoconf automake libtool pkg-config git build-essential + - git clone https://github.com/libstatgrab/libstatgrab.git libstatgrab-master + - cd libstatgrab-master + - ./autogen.sh + - ./configure --prefix=`cd .. && pwd`/libstatgrab-ubuntu2404 --disable-man + - make + - make install + artifacts: + paths: + - libstatgrab-ubuntu2404 + expire_in: 1 week + libstatgrab-centos7: stage: build image: centos:7 @@ -413,6 +432,39 @@ ubuntu2204-python3-libstatgrab-devel-setuptools: - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-ubuntu2204/lib/pkgconfig python3 setup.py install - LD_LIBRARY_PATH=../libstatgrab-ubuntu2204/lib python3 -m unittest discover -v +# No Python 2 on Ubuntu 24.04 + +# No distutils in Python 3.12 on Ubuntu 24.04 + +ubuntu2404-python3-libstatgrab-distrib-setuptools: + stage: test + image: ubuntu:24.04 + dependencies: + - pystatgrab-distfile + script: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential python3-dev pkg-config python3-setuptools libstatgrab-dev + - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz + - cd pystatgrab-$PYSG_VERSION + - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py build + - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py install + - python3 -m unittest discover -v + +ubuntu2404-python3-libstatgrab-devel-setuptools: + stage: test + image: ubuntu:24.04 + dependencies: + - pystatgrab-distfile + - libstatgrab-ubuntu2404 + script: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential python3-dev pkg-config python3-setuptools + - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz + - cd pystatgrab-$PYSG_VERSION + - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-ubuntu2404/lib/pkgconfig python3 setup.py build + - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-ubuntu2404/lib/pkgconfig python3 setup.py install + - LD_LIBRARY_PATH=../libstatgrab-ubuntu2404/lib python3 -m unittest discover -v + centos7-python2-libstatgrab-distrib: stage: test image: centos:7 @@ -471,19 +523,6 @@ centos7-python3-libstatgrab-devel: - LD_LIBRARY_PATH=../libstatgrab-centos7/lib python3 -m unittest discover -v # No libstatgrab-devel in Rocky 8 -#rocky8-python2-libstatgrab-distrib: -# stage: test -# image: rockylinux:8 -# dependencies: -# - pystatgrab-distfile -# script: -# - dnf -y install epel-release -# - dnf -y install gcc python2-devel pkgconfig libstatgrab-devel -# - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz -# - cd pystatgrab-$PYSG_VERSION -# - PYSTATGRAB_VERSION=$PYSG_VERSION python2 setup.py build -# - PYSTATGRAB_VERSION=$PYSG_VERSION python2 setup.py install -# - python2 -m unittest discover -v rocky8-python2-libstatgrab-devel: stage: test @@ -499,21 +538,6 @@ rocky8-python2-libstatgrab-devel: - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-rocky8/lib/pkgconfig python2 setup.py install - LD_LIBRARY_PATH=../libstatgrab-rocky8/lib python2 -m unittest discover -v -# No libstatgrab-devel in Rocky 8 -#rocky8-python3-libstatgrab-distrib: -# stage: test -# image: rockylinux:8 -# dependencies: -# - pystatgrab-distfile -# script: -# - dnf -y install epel-release -# - dnf -y install gcc python3-devel pkgconfig libstatgrab-devel -# - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz -# - cd pystatgrab-$PYSG_VERSION -# - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py build -# - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py install -# - python3 -m unittest discover -v - rocky8-python3-libstatgrab-devel: stage: test image: rockylinux:8 @@ -529,48 +553,8 @@ rocky8-python3-libstatgrab-devel: - LD_LIBRARY_PATH=../libstatgrab-rocky8/lib python3 -m unittest discover -v # No Python 2 on Rocky 9 -#rocky9-python2-libstatgrab-distrib: -# stage: test -# image: rockylinux:9 -# dependencies: -# - pystatgrab-distfile -# script: -# - dnf -y install epel-release -# - dnf -y install gcc python2-devel pkgconfig libstatgrab-devel -# - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz -# - cd pystatgrab-$PYSG_VERSION -# - PYSTATGRAB_VERSION=$PYSG_VERSION python2 setup.py build -# - PYSTATGRAB_VERSION=$PYSG_VERSION python2 setup.py install -# - python2 -m unittest discover -v -# -#rocky9-python2-libstatgrab-devel: -# stage: test -# image: rockylinux:9 -# dependencies: -# - pystatgrab-distfile -# - libstatgrab-rocky9 -# script: -# - yum -y install gcc python2-devel pkgconfig -# - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz -# - cd pystatgrab-$PYSG_VERSION -# - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-rocky9/lib/pkgconfig python2 setup.py build -# - PYSTATGRAB_VERSION=$PYSG_VERSION PKG_CONFIG_PATH=../libstatgrab-rocky9/lib/pkgconfig python2 setup.py install -# - LD_LIBRARY_PATH=../libstatgrab-rocky9/lib python2 -m unittest discover -v # No libstatgrab-devel in Rocky 9 -#rocky9-python3-libstatgrab-distrib: -# stage: test -# image: rockylinux:9 -# dependencies: -# - pystatgrab-distfile -# script: -# - dnf -y install epel-release -# - dnf -y install gcc python3-devel pkgconfig libstatgrab-devel -# - tar -zxvf dist/pystatgrab-$PYSG_VERSION.tar.gz -# - cd pystatgrab-$PYSG_VERSION -# - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py build -# - PYSTATGRAB_VERSION=$PYSG_VERSION python3 setup.py install -# - python3 -m unittest discover -v rocky9-python3-libstatgrab-devel: stage: test diff --git a/setup.py b/setup.py index e140a89..70981b5 100755 --- a/setup.py +++ b/setup.py @@ -68,12 +68,26 @@ def pkg_config(*args): try: import Cython.Distutils + from Cython.Build import cythonize cmdclass = {"build_ext": Cython.Distutils.build_ext} - statgrab_src = ["statgrab.pyx"] + ext_modules = cythonize( + [Extension( + "statgrab", + ["statgrab.pyx"], + extra_compile_args = cflags.decode("utf-8").split(), + extra_link_args = libs.decode("utf-8").split(), + )], + language_level="3str", + ) except ImportError: # Cython is not installed; use the shipped copy of statgrab.c. cmdclass = {} - statgrab_src = ["statgrab.c"] + ext_modules = [Extension( + "statgrab", + ["statgrab.c"], + extra_compile_args = cflags.decode("utf-8").split(), + extra_link_args = libs.decode("utf-8").split() + )] # setup information setup(name = "pystatgrab", @@ -90,10 +104,5 @@ def pkg_config(*args): "Topic :: System :: Monitoring", ], cmdclass = cmdclass, - ext_modules = [Extension( - "statgrab", - statgrab_src, - extra_compile_args = cflags.decode('utf-8').split(), - extra_link_args = libs.decode('utf-8').split(), - )], + ext_modules = ext_modules, )