diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 06ee77e7b..de042d63a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,10 +9,26 @@ on: - main jobs: - Ubuntu-Focal: + ubuntu-local-builds: runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + name: [ "Local Build Focal", "Local Build Jammy" ] + include: + + - name: "Local Build Focal" + release: focal + python: python3.8 + + - name: "Local Build Jammy" + release: jammy + python: python3.10 + + container: - image: ubuntu:focal + image: ubuntu:${{ matrix.release }} steps: - name: Check Out Repo @@ -22,7 +38,7 @@ jobs: run: | echo "Europe/London" > /etc/timezone apt-get -y update - DEBIAN_FRONTEND=noninteractive apt-get -y install gfortran g++ python3-setuptools python3-all-dev debhelper dh-python texlive python3-junit.xml + DEBIAN_FRONTEND=noninteractive apt-get -y install gfortran g++ python3-setuptools python3-pip python3-all-dev debhelper dh-python texlive python3-junit.xml - name: Configuring run: ./configure --prefix=/tmp @@ -37,7 +53,7 @@ jobs: - name: Testing env: - PYTHONPATH: /tmp/lib/python3.8/site-packages + PYTHONPATH: /tmp/lib/${{ matrix.python }}/site-packages LD_LIBRARY_PATH: /tmp/lib run: | cd python diff --git a/Makefile.in b/Makefile.in index 6da4bebf3..b57a8d07b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -51,7 +51,7 @@ VPATH = src/ .cpp.lo: ./libtool --mode=compile --tag=CXX $(CXX) $(CXXFLAGS) -c $< -default: libspud.la build-diamond +default: libspud.la build-diamond build-pyspud libspud.la: $(OBJS) ./libtool --mode=link --tag=FC $(FC) $(FCFLAGS) -o $(LIB) $(OBJS) $(LIBS) -rpath @prefix@/lib @@ -61,6 +61,9 @@ libspud.la: $(OBJS) build-diamond: cd diamond; python3 setup.py build; cd .. +build-pyspud: libspud.la + cd python; python3 setup.py build; cd .. + test: unittest unittest: libspud.la @@ -95,21 +98,13 @@ install-spudtools: @INSTALL@ -m644 schema/spud_base.rng $(DESTDIR)@prefix@/share/spud install-diamond: - cd diamond; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. + cd diamond; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. install-pyspud: -ifeq ($(origin BUILDING_DEBIAN),undefined) cd python; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. -else - cd python; for python in $(shell py3versions -r); do $$python setup.py install --prefix=$(DESTDIR)@prefix@ --install-layout=deb; done; cd .. -endif install-dxdiff: -ifeq ($(origin BUILDING_DEBIAN),undefined) cd dxdiff; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. -else - cd dxdiff; for python in $(shell py3versions -r); do $$python setup.py install --prefix=$(DESTDIR)@prefix@ --install-layout=deb; done; cd .. -endif clean: @cd doc; $(MAKE) clean diff --git a/debian/changelog b/debian/changelog index da16bcc5a..c5b02f97b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +spud (1.2) UNRELEASED; urgency=medium + + * Rewrite Debian/Ubuntu packaging + + -- Stephan Kramer Tue, 25 Oct 2022 12:12:05 +0100 + spud (1.1.8) buster; urgency=medium * Change to python3 and remove python(2) dependecies diff --git a/debian/compat b/debian/compat index ec635144f..b4de39476 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +11 diff --git a/debian/control b/debian/control index ae8049c8d..e5caca697 100644 --- a/debian/control +++ b/debian/control @@ -2,10 +2,10 @@ Source: spud Maintainer: The ICOM team Uploaders: David Ham Section: science -Priority: extra -Build-Depends: gfortran (>=4.2), g++ (>=4.2), python3-setuptools (>= 0.6b3-1), python3-all-dev (>= 2.3.5-11), debhelper (>= 5.0.38), dh-python, texlive +Priority: optional +Build-Depends: gfortran (>=4.2), g++ (>=4.2), python3-setuptools (>= 39), python3-pip, python3-all-dev , debhelper (>= 5.0.38), dh-python, texlive Standards-Version: 3.8.0 -XS-Python-Version: >= 2.5 +X-Python3-Version: >= 3.6 Package: spud-diamond Architecture: all @@ -16,7 +16,7 @@ Conflicts: python-diamond, diamond Replaces: python-diamond Provides: ${python:Provides} X-Python-Version: ${python:Versions} -Description: A schema-driven interface for writing XML documents +Description: Schema-driven interface for writing XML documents Diamond is a dynamic schema-driven graphical user interface for writing XML documents. The interface is automatically generated from a schema written in RELAX NG describing an XML language. The interface is optimised @@ -29,7 +29,7 @@ Depends: ${shlibs:Depends}, spudtools, libtinyxml-dev, ${misc:Depends} Recommends: spud-diamond Section: libdevel Suggests: -Description: An automatic options system for scientific models. +Description: Automatic options system for scientific models. Spud is an automatic options system which reads an xml options file into a dictionary for immediate access from within the model. The xml file is generated using a spud-compatible RELAX NG schema and a @@ -43,7 +43,7 @@ Conflicts: libspud-dev (<<1.0.6) Replaces: libspud-dev (<<1.0.6) Section: science Suggests: -Description: An automatic options system for scientific models. +Description: Automatic options system for scientific models. Spud is an automatic options system which reads an xml options file into a dictionary for immediate access from within the model. The xml file is generated using a spud-compatible RELAX NG schema and a @@ -58,7 +58,7 @@ Replaces: python-spud Architecture: any X-Python-Version: ${python:Versions} Depends: libspud-dev (= ${binary:Version}), ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends} -Description: An automatic options system for scientific models (python interface). +Description: Automatic options system for scientific models (python interface). Spud is an automatic options system which reads an xml options file into a dictionary for immediate access from within the model. The xml file is generated using a spud-compatible RELAX NG schema and a @@ -72,6 +72,6 @@ Replaces: python-dxdiff Architecture: all X-Python-Version: ${python:Versions} Depends: ${python3:Depends}, ${misc:Depends} -Description: An XML aware diff tool. +Description: XML aware diff tool. DXdiff (Diamond Xml diff) is an XML aware diff tool for finding edit scripts between two XML files. diff --git a/debian/install.spud-diamond b/debian/install.spud-diamond deleted file mode 100644 index fe14180c7..000000000 --- a/debian/install.spud-diamond +++ /dev/null @@ -1 +0,0 @@ -diamond/misc/diamond-bash-completion /etc/bash_completion.d/ \ No newline at end of file diff --git a/debian/libspud-dev.dirs b/debian/libspud-dev.dirs deleted file mode 100644 index 44188162e..000000000 --- a/debian/libspud-dev.dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib -usr/include diff --git a/debian/libspud-dev.install b/debian/libspud-dev.install new file mode 100644 index 000000000..84d627951 --- /dev/null +++ b/debian/libspud-dev.install @@ -0,0 +1,2 @@ +usr/lib/libspud* +usr/include/spud* diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 4a4a24587..000000000 --- a/debian/postinst +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ldconfig diff --git a/debian/python3-dxdiff.install b/debian/python3-dxdiff.install new file mode 100644 index 000000000..2ab50f178 --- /dev/null +++ b/debian/python3-dxdiff.install @@ -0,0 +1,2 @@ +usr/lib/python3*/dist-packages/dxdiff* +usr/bin/dxdiff diff --git a/debian/python3-spud.install b/debian/python3-spud.install new file mode 100644 index 000000000..304705916 --- /dev/null +++ b/debian/python3-spud.install @@ -0,0 +1 @@ +usr/lib/python3*/dist-packages/libspud* diff --git a/debian/rules b/debian/rules index baa22ee65..542a7be55 100755 --- a/debian/rules +++ b/debian/rules @@ -1,139 +1,22 @@ #!/usr/bin/make -f -PACKAGE_NAME=spud-diamond -MODULE_NAME=diamond -DEB_UPSTREAM_VERSION=1.0 - -PYVERS=$(shell py3versions -dv) - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - - -config.status: configure - dh_testdir - # Add here commands to configure the package. - -ifneq "$(wildcard /usr/share/misc/config.sub)" "" - cp -f /usr/share/misc/config.sub config.sub -endif -ifneq "$(wildcard /usr/share/misc/config.guess)" "" - cp -f /usr/share/misc/config.guess config.guess -endif - ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" - -build-libspud: build-libspud-stamp -build-libspud-stamp: - touch $@ - -build-libspud: config.status - dh_testdir - - # Add here commands to compile the package. - $(MAKE) libspud.la - #docbook-to-man debian/fluidity.sgml > fluidity.1 - $(MAKE) doc - - -build-spud-diamond: build-spud-diamond-stamp -build-spud-diamond-stamp: $(PYVERS:%=build-python%) - touch $@ -build-python%: config.status -# Force setuptools, but reset sys.argv[0] to 'setup.py' because setup.py files expect that. - cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;exec(open(f,'r').read(),{'__file__':f,'__name__':'__main__'})" build - touch $@ -clean: - dh_testdir - dh_testroot - rm -f *-stamp - rm -rf dist build - -find -name '*.py[co]' | xargs rm -f - $(MAKE) clean || true -# find . -name *.pyc -exec rm {} \; - dh_clean - -install-libspud: build-libspud install-prereq - $(MAKE) install-libspud DESTDIR=$(CURDIR)/debian/libspud-dev - rm -f $(CURDIR)/debian/libspud-dev/usr/include/tiny*h - -install-spudtools: install-prereq - $(MAKE) install-spudtools DESTDIR=$(CURDIR)/debian/spudtools - -install-spud-diamond: build-spud-diamond install-prereq $(PYVERS:%=install-python%) - dh_install -install-prereq: - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs -a - -install-python%: -# Force setuptools, but reset sys.argv[0] to 'setup.py' because setup.py files expect that. - cd diamond;python$* -c "import setuptools,sys;f='setup.py';sys.argv[0]=f;exec(open(f,'r').read(),{'__file__':f,'__name__':'__main__'})" install --prefix=/usr --no-compile --single-version-externally-managed --root=$(CURDIR)/debian/${PACKAGE_NAME} - if [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info ]; then \ - mv debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages ; \ - mv debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}.egg-info debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages/${MODULE_NAME}.egg-info ; \ - elif [ -d debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}-py$*.egg-info ]; then \ - mv debian/${PACKAGE_NAME}/usr/lib/python$*/site-packages debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages ; \ - mv debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages/${MODULE_NAME}-${DEB_UPSTREAM_VERSION}-py$*.egg-info debian/${PACKAGE_NAME}/usr/lib/python$*/dist-packages/${MODULE_NAME}.egg-info ; \ - else \ - echo "Failed to locate python egg, was it built correctly?" && exit 1 ; \ - fi - -install-pyspud: - $(MAKE) install-pyspud DESTDIR=$(CURDIR)/debian/python3-spud BUILDING_DEBIAN=yes - -install-dxdiff: - $(MAKE) install-dxdiff DESTDIR=$(CURDIR)/debian/python3-dxdiff - -binary-arch: build-libspud install-libspud install-spudtools install-pyspud - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples -# dh_install -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime - dh_python3 -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary-indep: build-spud-diamond install-spud-diamond build-libspud install-libspud install-spudtools install-dxdiff - dh_testdir -i - dh_testroot -i - dh_python3 -i - dh_installdocs -i - dh_installdirs -i - dh_installexamples -i - dh_strip -i - dh_compress -i -X.py - dh_fixperms -i - dh_installdeb -i - dh_gencontrol -i - dh_md5sums -i - dh_builddeb -i - -binary: binary-indep binary-arch - - -.PHONY: build clean binary-indep binary-arch binary-spud-diamond binary-libspud install configure +#export DH_VERBOSE=1 +export BUILDING_DEBIAN=yes +PYTHON_DIRS=diamond dxdiff python + +# standard rule +%: + dh $@ --with=python3 + +# instead of calling make/make default to build +# call "make libspud.la" separately and use pybuild for building the python packages +override_dh_auto_build: + dh_auto_build -- libspud.la + for i in $(PYTHON_DIRS); do PYBUILD_NAME=$$i; dh_auto_build --buildsystem=pybuild --sourcedir=$$i; done + +# instead of a single "make install" into debian/tmp +# only use makefile for install-libspud and install-spudtools +# and use pybuild to install python packages +override_dh_auto_install: + make install-libspud install-spudtools DESTDIR=debian/tmp/ + for i in $(PYTHON_DIRS); do PYBUILD_NAME=$$i; dh_auto_install --buildsystem=pybuild --sourcedir=$$i; done diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 000000000..89ae9db8f --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/spud-diamond.install b/debian/spud-diamond.install new file mode 100644 index 000000000..ca1581948 --- /dev/null +++ b/debian/spud-diamond.install @@ -0,0 +1,3 @@ +usr/lib/python3*/dist-packages/diamond* +usr/bin/diamond +usr/share/diamond* diff --git a/debian/spudtools.dirs b/debian/spudtools.dirs deleted file mode 100644 index e77248175..000000000 --- a/debian/spudtools.dirs +++ /dev/null @@ -1 +0,0 @@ -usr/bin diff --git a/debian/spudtools.install b/debian/spudtools.install new file mode 100644 index 000000000..bc2deb9cc --- /dev/null +++ b/debian/spudtools.install @@ -0,0 +1,2 @@ +usr/bin/spud* +usr/share/spud* diff --git a/python/libspud.c b/python/libspud.c index 39e02caf8..1d1a6beb9 100644 --- a/python/libspud.c +++ b/python/libspud.c @@ -11,7 +11,7 @@ #define PyString_Type PyUnicode_Type #define PyString_AsString PyUnicode_AsUTF8 #define PyString_Check PyUnicode_Check -#define PyString_GET_SIZE PyUnicode_GET_SIZE +#define PyString_GET_SIZE PyUnicode_GET_LENGTH #endif static PyObject *SpudError; @@ -360,7 +360,7 @@ spud_get_option_aux_scalar_or_string(const char *key, int key_len, int type, int int i; for (i = 0; i < size+1; i++) val[i] = '\0'; - + outcomeGetOption = spud_get_option(key, key_len, val); if (error_checking(outcomeGetOption, "get option aux scalar or string") == NULL){ return NULL; @@ -478,7 +478,7 @@ libspud_get_option(PyObject *self, PyObject *args) if (error_checking(outcomeGetOptionShape, "get option") == NULL){ return NULL; } - + if (rank == -1){ // type error char errormessage [MAXLENGTH]; snprintf(errormessage, MAXLENGTH, "Error: The specified option has a different \ @@ -506,7 +506,7 @@ libspud_get_option(PyObject *self, PyObject *args) } else if (type == SPUD_INT){ //a tensor of ints return spud_get_option_aux_tensor_ints(key, key_len, type, rank, shape); - } + } } PyErr_SetString(SpudError,"Error: Get option failed."); @@ -562,7 +562,7 @@ set_option_aux_list_doubles(PyObject *pylist, const char *key, int key_len, int static PyObject* set_option_aux_string(PyObject *pystring, const char *key, int key_len, int type, int rank, int *shape) { // this function is for setting option when the second argument is of type string - char *val = PyString_AsString(pystring); + const char *val = PyString_AsString(pystring); int outcomeSetOption = spud_set_option(key, key_len, val, type, rank, shape); return error_checking(outcomeSetOption, "set option aux string"); } @@ -613,10 +613,10 @@ set_option_aux_tensor_doubles(PyObject *pylist, const char *key, int key_len, in int outcomeSetOption; int size = shape[0]*shape[1]; - + double element; double val [size]; - + for (i = 0; i < shape[0]; i++){ PyObject* pysublist = PyList_GetItem(pylist, i); for (j = 0; j < shape[1]; j++){ @@ -687,7 +687,7 @@ libspud_set_option(PyObject *self, PyObject *args) int shape[2]; PyObject* firstArg; PyObject* secondArg; - + if(PyTuple_GET_SIZE(args)!=2){ PyErr_SetString(SpudError,"Error: set_option takes exactly 2 arguments."); return NULL; @@ -697,19 +697,19 @@ libspud_set_option(PyObject *self, PyObject *args) secondArg = PyTuple_GetItem(args, 1); PyArg_Parse(firstArg, "s", &key); key_len = strlen(key); - + if (!spud_have_option(key, key_len)){ //option does not exist yet int outcomeAddOption = spud_add_option(key, key_len); error_checking(outcomeAddOption, "set option"); - } - + } + if (PyInt_Check(secondArg)){ //just an int type = SPUD_INT; rank = 0; shape[0] = -1; shape[1] = -1; - - } + + } else if (PyString_Check(secondArg)){// a string type = SPUD_STRING; rank = 1; @@ -745,13 +745,13 @@ libspud_set_option(PyObject *self, PyObject *args) } else if (PyFloat_Check(sublistElement)){//list of lists of doubles type = SPUD_DOUBLE; - } + } rank = 2; shape[0] = pylistSize; shape[1] = pysublistSize; } } - + if (rank == 0){ // scalar set_option_aux_scalar(secondArg, key, key_len, type, rank, shape); } @@ -761,10 +761,10 @@ libspud_set_option(PyObject *self, PyObject *args) } else if (type == SPUD_INT) { // list of ints set_option_aux_list_ints(secondArg, key, key_len, type, rank, shape); - } + } else if (type == SPUD_DOUBLE){ // list of doubles set_option_aux_list_doubles(secondArg, key, key_len, type, rank, shape); - } + } } else if (rank == 2){ // tensor if (type == SPUD_DOUBLE) { // tensor of doubles @@ -907,5 +907,3 @@ initlibspud(void) #endif } - - diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index 259154801..3b7e768ee 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -59,6 +59,9 @@ junittest: test-binaries %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< +# ensure unittest_tools gets built first as it is used as a module in test_fspud +test_fspud.o: unittest_tools.o + # Creates a TESTNAME_main.o from test_main.cpp which calls the subroutine # TESTNAME, that should be a subroutine in TESTNAME.f90 %_main.o: unittest_tools.o