From 013845e344a1a939aff3d1e32b34213841f9fa13 Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 24 Oct 2022 19:04:47 +0100 Subject: [PATCH 01/10] Fix debian build with python 3.10 and deprecate distutils Summary is that distutils has been deprecated for a while and will be removed in 3.12. setuptools is its replacement. However its use as an installation mechanism, e.g. *calling* setup.py install with CLI arguments is also being deprecated - with no good alternative (yet) being available. Since the whole world still depends on it I don't expect the latter to go away any time soon though, but it does seem to no longer care about fixing things for that frontend which is what now cause prefix arguments to not work as expected (installing things in /usr/local/ whilst specifying --prefix=/usr), which breaks the building of Debian packages. What Debian/Ubuntu seem to have done is patch setuptools to make it keep on behaving as they want, but only if you provide --install-layout=deb. So now providing that argument for all calls of "python setup.py install" in the Debian build. This would have also worked in combination with distutils, but taking this opportunity to upgrade to setuptools (since we'll have to soon anyway). These are changes by @Patol75, taken from https://github.com/FluidityProject/fluidity/pull/351. --- debian/rules | 17 +++------ diamond/setup.py.in | 85 ++++++++++++++++++++++----------------------- dxdiff/setup.py | 27 +++++--------- python/libspud.c | 36 +++++++++---------- python/setup.py | 17 ++++----- 5 files changed, 80 insertions(+), 102 deletions(-) diff --git a/debian/rules b/debian/rules index baa22ee65..52a6d4de0 100755 --- a/debian/rules +++ b/debian/rules @@ -70,23 +70,13 @@ install-prereq: 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 + cd diamond; python$* setup.py install --prefix=/usr --no-compile --single-version-externally-managed --root=$(CURDIR)/debian/${PACKAGE_NAME} --install-layout=deb install-pyspud: $(MAKE) install-pyspud DESTDIR=$(CURDIR)/debian/python3-spud BUILDING_DEBIAN=yes install-dxdiff: - $(MAKE) install-dxdiff DESTDIR=$(CURDIR)/debian/python3-dxdiff + $(MAKE) install-dxdiff DESTDIR=$(CURDIR)/debian/python3-dxdiff BUILDING_DEBIAN=yes binary-arch: build-libspud install-libspud install-spudtools install-pyspud dh_testdir @@ -135,5 +125,8 @@ binary-indep: build-spud-diamond install-spud-diamond build-libspud install-libs binary: binary-indep binary-arch +build-arch: binary-arch +build-indep: binary-indep + .PHONY: build clean binary-indep binary-arch binary-spud-diamond binary-libspud install configure diff --git a/diamond/setup.py.in b/diamond/setup.py.in index ff24e3ae7..04ce6a3fd 100644 --- a/diamond/setup.py.in +++ b/diamond/setup.py.in @@ -1,20 +1,19 @@ -from distutils.core import setup -from distutils.extension import Extension -import os -import os.path -import glob +from glob import glob +from os import listdir +from os.path import isdir, join +from setuptools import setup +from sys import argv, platform # There are a number of local hacks in this file, to deal with the multiple -# ways in which setup.py is called by various scripts and packaging methods +# ways in which setup.py is called by various scripts and packaging methods # that interact with spud, enabling setuptools to grok their intentions. # In some cases, we will be passed a 'DESTDIR' from an upstream packagaing # system. This will be a local directory to install into, and act as local '/' -# as far as all paths are concerned. Check for this, and fail nicely if not set. +# as far as all paths are concerned. Check for this and fail nicely if not set. prefix = None -import sys -packaging=False +packaging = False # We may also be given prefix, either as a configuration option (which will be # dealt with by substitutions later) or as a command line option. If a command @@ -27,9 +26,9 @@ packaging=False # parsed if present, and supercedes any previous DESTDIR picked up from # environment. -for i, arg in enumerate(sys.argv): - if "--prefix" in arg: - prefix = arg.split('=')[1] +for i, arg in enumerate(argv): + if "--prefix" in arg: + prefix = arg.split('=')[1] # Given the above prefix possibilities, as well as root and DESTDIR, we need to # construct a list of data directories to be installed @@ -43,45 +42,43 @@ for i, arg in enumerate(sys.argv): # on the command line in preference to the configure prefix. # First parse the plugin directories -plugin_dirs = [dir for dir in os.listdir('plugins') if os.path.isdir(os.path.join('plugins', dir)) and dir[0] != '.'] +plugin_dirs = [dir for dir in listdir('plugins') + if isdir(join('plugins', dir)) and dir[0] != '.'] plugin_data_files = [] -if sys.platform == 'darwin' and packaging: - for plugin in plugin_dirs: - plugin_data_files.append(("./plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) +if platform == 'darwin' and packaging: + for plugin in plugin_dirs: + plugin_data_files.append(("./plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) else: - for plugin in plugin_dirs: - if prefix is None: - plugin_data_files.append(("@prefix@/share/diamond/plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) - else: - plugin_data_files.append((prefix + "/share/diamond/plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) + for plugin in plugin_dirs: + if prefix is None: + plugin_data_files.append( + ("@prefix@/share/diamond/plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) + else: + plugin_data_files.append( + (prefix + "/share/diamond/plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) # Now parse the GUI directories gui_data_files = [] -if sys.platform == 'darwin' and packaging : - gui_data_files.append(("./gui", - ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) +if platform == 'darwin' and packaging: + gui_data_files.append( + ("./gui", ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) else: - if prefix is None: - gui_data_files.append(("@prefix@/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) - else: - gui_data_files.append((prefix + "/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) + if prefix is None: + gui_data_files.append(("@prefix@/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) + else: + gui_data_files.append((prefix + "/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) # We now have all the information we need; run setup. -setup( - name='diamond', - version='1.0', +setup(name='diamond', version='1.0', description="Fluidity preprocessor", - author = "The ICOM team", - author_email = "patrick.farrell@imperial.ac.uk", - url = "http://amcg.ese.ic.ac.uk", - packages = ['diamond'], - package_dir = {'diamond': 'diamond'}, + author="The ICOM team", + author_email="patrick.farrell@imperial.ac.uk", + url="http://amcg.ese.ic.ac.uk", packages=['diamond'], + package_dir={'diamond': 'diamond'}, scripts=["bin/diamond"], - data_files = gui_data_files + plugin_data_files - ) - + data_files=gui_data_files + plugin_data_files) diff --git a/dxdiff/setup.py b/dxdiff/setup.py index d60d90133..b2993a0da 100644 --- a/dxdiff/setup.py +++ b/dxdiff/setup.py @@ -1,21 +1,10 @@ -from distutils.core import setup -import os -import os.path -import glob +from setuptools import setup -try: - destdir = os.environ["DESTDIR"] -except KeyError: - destdir = "" - -setup( - name='dxdiff', +setup(name='dxdiff', version='1.0', - description="An XML aware diff tool.", - author = "The ICOM team", - author_email = "fraser.waters08@imperial.ac.uk", - url = "http://amcg.ese.ic.ac.uk", - packages = ['dxdiff'], - scripts=["dxdiff/dxdiff"], - ) - + description="An XML aware diff tool", + author="The ICOM team", + author_email="fraser.waters08@imperial.ac.uk", + url="http://amcg.ese.ic.ac.uk", + packages=['dxdiff'], + scripts=["dxdiff/dxdiff"]) 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/python/setup.py b/python/setup.py index da84618c8..7cac54d23 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,9 +1,10 @@ -from distutils.core import setup, Extension -import os.path +from os.path import abspath +from setuptools import setup, Extension -module1 = Extension('libspud', sources = ['libspud.c'], libraries=["spud"], library_dirs=[os.path.abspath("..")], include_dirs=[os.path.abspath("../include")]) - -setup (name = 'libspud', - version = '1.1.3', - description = 'Python bindings for libspud', - ext_modules = [module1]) +setup(name='libspud', + version='1.1.3', + description='Python bindings for libspud', + ext_modules=[Extension('libspud', sources=['libspud.c'], + libraries=["spud"], + library_dirs=[abspath("..")], + include_dirs=[abspath("../include")])]) From cfd1980bad2739ec28049e304c21134c9266f876 Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Fri, 28 Oct 2022 16:32:44 +0100 Subject: [PATCH 02/10] Rewrite Debian/Ubuntu packaging To avoid having to deal with the setup.py install vagueries when installing python for Debian packaging, let pybuild take care of the building and installing of python. Rewrite debian/rules to make use of debhelper for as much as possible and minimize hackery. Also remove Debian-packaging-specific hacks in Makefile.in The recipe we are now following is to install everything in debian/tmp (instead of straight into the debian// directories), and divide the resulting files up over the packages using debian/ files. Try to clean up some Lintin errors and warnings in the process. --- Makefile.in | 10 +-- debian/changelog | 6 ++ debian/compat | 2 +- debian/control | 16 ++-- debian/install.spud-diamond | 1 - debian/libspud-dev.dirs | 2 - debian/libspud-dev.install | 2 + debian/postinst | 2 - debian/python3-dxdiff.install | 2 + debian/python3-spud.install | 1 + debian/rules | 150 +++++----------------------------- debian/source/format | 1 + debian/spud-diamond.install | 3 + debian/spudtools.dirs | 1 - debian/spudtools.install | 2 + 15 files changed, 47 insertions(+), 154 deletions(-) delete mode 100644 debian/install.spud-diamond delete mode 100644 debian/libspud-dev.dirs create mode 100644 debian/libspud-dev.install delete mode 100644 debian/postinst create mode 100644 debian/python3-dxdiff.install create mode 100644 debian/python3-spud.install create mode 100644 debian/source/format create mode 100644 debian/spud-diamond.install delete mode 100644 debian/spudtools.dirs create mode 100644 debian/spudtools.install diff --git a/Makefile.in b/Makefile.in index 6da4bebf3..0906087a8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -95,21 +95,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..07b104ffa 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-all-dev (>= 2.3.5-11), 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 52a6d4de0..542a7be55 100755 --- a/debian/rules +++ b/debian/rules @@ -1,132 +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%: - cd diamond; python$* setup.py install --prefix=/usr --no-compile --single-version-externally-managed --root=$(CURDIR)/debian/${PACKAGE_NAME} --install-layout=deb - -install-pyspud: - $(MAKE) install-pyspud DESTDIR=$(CURDIR)/debian/python3-spud BUILDING_DEBIAN=yes - -install-dxdiff: - $(MAKE) install-dxdiff DESTDIR=$(CURDIR)/debian/python3-dxdiff BUILDING_DEBIAN=yes - -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 - -build-arch: binary-arch -build-indep: binary-indep - - -.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* From 81c34dfc58f36db59c8719fe441f2276bc183d94 Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Fri, 28 Oct 2022 16:47:52 +0100 Subject: [PATCH 03/10] Attempt to fix intermittent test failures --- src/tests/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) 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 From 7aab038156cc0a50c3f7ea463cb2e54581367a0a Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 11:51:18 +0000 Subject: [PATCH 04/10] Use "pip install" instead of "python setup.py install" Add python3-pip as build dependency --- .github/workflows/ubuntu.yml | 2 +- Makefile.in | 11 +++++++---- debian/control | 2 +- python/setup.py | 7 +++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 06ee77e7b..d8dfe60a9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -22,7 +22,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 diff --git a/Makefile.in b/Makefile.in index 0906087a8..3fb7e2002 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,13 +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 .. + python3 -mpip install --prefix=$(DESTDIR)@prefix@ diamond/ install-pyspud: - cd python; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. + python3 -mpip install --prefix=$(DESTDIR)@prefix@ python/ install-dxdiff: - cd dxdiff; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. + python3 -mpip install --prefix=$(DESTDIR)@prefix@ dxdiff/ clean: @cd doc; $(MAKE) clean diff --git a/debian/control b/debian/control index 07b104ffa..e5caca697 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: The ICOM team Uploaders: David Ham Section: science Priority: optional -Build-Depends: gfortran (>=4.2), g++ (>=4.2), python3-setuptools (>= 39), python3-all-dev (>= 2.3.5-11), debhelper (>= 5.0.38), dh-python, texlive +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 X-Python3-Version: >= 3.6 diff --git a/python/setup.py b/python/setup.py index 7cac54d23..c5f220b95 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,5 +6,12 @@ description='Python bindings for libspud', ext_modules=[Extension('libspud', sources=['libspud.c'], libraries=["spud"], + # path to libspud (the actual library, not the c-extension python wrapper + # which will be put in the parent directory by "make libspud.la" + # NOTE: For this to work you have to run "python setup.py build" from the + # original directory of the current file separately before + # running pip install, as pip will build the extension (if it's not built already) + # outside of the current context library_dirs=[abspath("..")], + # path to spud.h include_dirs=[abspath("../include")])]) From b535227f384e817f82333d7316c7c827ce04a3ad Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 16:15:39 +0000 Subject: [PATCH 05/10] Attempt to CI at Bionic, Focal and Jammy --- .github/workflows/ubuntu.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d8dfe60a9..9e70db9e8 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -9,10 +9,30 @@ on: - main jobs: - Ubuntu-Focal: + ubuntu-local-builds: runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + name: [ "Local Build Bionic", "Local Build Focal", "Local Build Jammy" ] + include: + + - name: "Local Build Bionic" + release: bionic + python: python3.6 + + - name: "Local Build Focal" + release: focal + python: python3.8 + + - name: "Local Build Jammy" + release: impish + python: python3.10 + + container: - image: ubuntu:focal + image: ubuntu:${{ matrix.release }} steps: - name: Check Out Repo @@ -37,7 +57,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 From 245aef11e94015856efbe14bbd911371dbc411ec Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 17:15:39 +0000 Subject: [PATCH 06/10] Drop Bionic --- .github/workflows/ubuntu.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9e70db9e8..de042d63a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -15,19 +15,15 @@ jobs: strategy: fail-fast: false matrix: - name: [ "Local Build Bionic", "Local Build Focal", "Local Build Jammy" ] + name: [ "Local Build Focal", "Local Build Jammy" ] include: - - name: "Local Build Bionic" - release: bionic - python: python3.6 - - name: "Local Build Focal" release: focal python: python3.8 - name: "Local Build Jammy" - release: impish + release: jammy python: python3.10 From a928c21b047142d8968f084c68707a4972bb2c4b Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 19:11:02 +0000 Subject: [PATCH 07/10] Revert back to distutils --- diamond/setup.py.in | 85 +++++++++++++++++++++++---------------------- dxdiff/setup.py | 27 +++++++++----- python/setup.py | 24 +++++-------- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/diamond/setup.py.in b/diamond/setup.py.in index 04ce6a3fd..ff24e3ae7 100644 --- a/diamond/setup.py.in +++ b/diamond/setup.py.in @@ -1,19 +1,20 @@ -from glob import glob -from os import listdir -from os.path import isdir, join -from setuptools import setup -from sys import argv, platform +from distutils.core import setup +from distutils.extension import Extension +import os +import os.path +import glob # There are a number of local hacks in this file, to deal with the multiple -# ways in which setup.py is called by various scripts and packaging methods +# ways in which setup.py is called by various scripts and packaging methods # that interact with spud, enabling setuptools to grok their intentions. # In some cases, we will be passed a 'DESTDIR' from an upstream packagaing # system. This will be a local directory to install into, and act as local '/' -# as far as all paths are concerned. Check for this and fail nicely if not set. +# as far as all paths are concerned. Check for this, and fail nicely if not set. prefix = None -packaging = False +import sys +packaging=False # We may also be given prefix, either as a configuration option (which will be # dealt with by substitutions later) or as a command line option. If a command @@ -26,9 +27,9 @@ packaging = False # parsed if present, and supercedes any previous DESTDIR picked up from # environment. -for i, arg in enumerate(argv): - if "--prefix" in arg: - prefix = arg.split('=')[1] +for i, arg in enumerate(sys.argv): + if "--prefix" in arg: + prefix = arg.split('=')[1] # Given the above prefix possibilities, as well as root and DESTDIR, we need to # construct a list of data directories to be installed @@ -42,43 +43,45 @@ for i, arg in enumerate(argv): # on the command line in preference to the configure prefix. # First parse the plugin directories -plugin_dirs = [dir for dir in listdir('plugins') - if isdir(join('plugins', dir)) and dir[0] != '.'] +plugin_dirs = [dir for dir in os.listdir('plugins') if os.path.isdir(os.path.join('plugins', dir)) and dir[0] != '.'] plugin_data_files = [] -if platform == 'darwin' and packaging: - for plugin in plugin_dirs: - plugin_data_files.append(("./plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) +if sys.platform == 'darwin' and packaging: + for plugin in plugin_dirs: + plugin_data_files.append(("./plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) else: - for plugin in plugin_dirs: - if prefix is None: - plugin_data_files.append( - ("@prefix@/share/diamond/plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) - else: - plugin_data_files.append( - (prefix + "/share/diamond/plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) + for plugin in plugin_dirs: + if prefix is None: + plugin_data_files.append(("@prefix@/share/diamond/plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) + else: + plugin_data_files.append((prefix + "/share/diamond/plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) # Now parse the GUI directories gui_data_files = [] -if platform == 'darwin' and packaging: - gui_data_files.append( - ("./gui", ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) +if sys.platform == 'darwin' and packaging : + gui_data_files.append(("./gui", + ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) else: - if prefix is None: - gui_data_files.append(("@prefix@/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) - else: - gui_data_files.append((prefix + "/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) + if prefix is None: + gui_data_files.append(("@prefix@/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) + else: + gui_data_files.append((prefix + "/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) # We now have all the information we need; run setup. -setup(name='diamond', version='1.0', +setup( + name='diamond', + version='1.0', description="Fluidity preprocessor", - author="The ICOM team", - author_email="patrick.farrell@imperial.ac.uk", - url="http://amcg.ese.ic.ac.uk", packages=['diamond'], - package_dir={'diamond': 'diamond'}, + author = "The ICOM team", + author_email = "patrick.farrell@imperial.ac.uk", + url = "http://amcg.ese.ic.ac.uk", + packages = ['diamond'], + package_dir = {'diamond': 'diamond'}, scripts=["bin/diamond"], - data_files=gui_data_files + plugin_data_files) + data_files = gui_data_files + plugin_data_files + ) + diff --git a/dxdiff/setup.py b/dxdiff/setup.py index b2993a0da..d60d90133 100644 --- a/dxdiff/setup.py +++ b/dxdiff/setup.py @@ -1,10 +1,21 @@ -from setuptools import setup +from distutils.core import setup +import os +import os.path +import glob -setup(name='dxdiff', +try: + destdir = os.environ["DESTDIR"] +except KeyError: + destdir = "" + +setup( + name='dxdiff', version='1.0', - description="An XML aware diff tool", - author="The ICOM team", - author_email="fraser.waters08@imperial.ac.uk", - url="http://amcg.ese.ic.ac.uk", - packages=['dxdiff'], - scripts=["dxdiff/dxdiff"]) + description="An XML aware diff tool.", + author = "The ICOM team", + author_email = "fraser.waters08@imperial.ac.uk", + url = "http://amcg.ese.ic.ac.uk", + packages = ['dxdiff'], + scripts=["dxdiff/dxdiff"], + ) + diff --git a/python/setup.py b/python/setup.py index c5f220b95..da84618c8 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,17 +1,9 @@ -from os.path import abspath -from setuptools import setup, Extension +from distutils.core import setup, Extension +import os.path -setup(name='libspud', - version='1.1.3', - description='Python bindings for libspud', - ext_modules=[Extension('libspud', sources=['libspud.c'], - libraries=["spud"], - # path to libspud (the actual library, not the c-extension python wrapper - # which will be put in the parent directory by "make libspud.la" - # NOTE: For this to work you have to run "python setup.py build" from the - # original directory of the current file separately before - # running pip install, as pip will build the extension (if it's not built already) - # outside of the current context - library_dirs=[abspath("..")], - # path to spud.h - include_dirs=[abspath("../include")])]) +module1 = Extension('libspud', sources = ['libspud.c'], libraries=["spud"], library_dirs=[os.path.abspath("..")], include_dirs=[os.path.abspath("../include")]) + +setup (name = 'libspud', + version = '1.1.3', + description = 'Python bindings for libspud', + ext_modules = [module1]) From 3e17fb754a831de11a187ebdfffa6510e138c9ec Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 19:17:07 +0000 Subject: [PATCH 08/10] Revert "Revert back to distutils" This reverts commit a928c21b047142d8968f084c68707a4972bb2c4b. --- diamond/setup.py.in | 85 ++++++++++++++++++++++----------------------- dxdiff/setup.py | 27 +++++--------- python/setup.py | 24 ++++++++----- 3 files changed, 65 insertions(+), 71 deletions(-) diff --git a/diamond/setup.py.in b/diamond/setup.py.in index ff24e3ae7..04ce6a3fd 100644 --- a/diamond/setup.py.in +++ b/diamond/setup.py.in @@ -1,20 +1,19 @@ -from distutils.core import setup -from distutils.extension import Extension -import os -import os.path -import glob +from glob import glob +from os import listdir +from os.path import isdir, join +from setuptools import setup +from sys import argv, platform # There are a number of local hacks in this file, to deal with the multiple -# ways in which setup.py is called by various scripts and packaging methods +# ways in which setup.py is called by various scripts and packaging methods # that interact with spud, enabling setuptools to grok their intentions. # In some cases, we will be passed a 'DESTDIR' from an upstream packagaing # system. This will be a local directory to install into, and act as local '/' -# as far as all paths are concerned. Check for this, and fail nicely if not set. +# as far as all paths are concerned. Check for this and fail nicely if not set. prefix = None -import sys -packaging=False +packaging = False # We may also be given prefix, either as a configuration option (which will be # dealt with by substitutions later) or as a command line option. If a command @@ -27,9 +26,9 @@ packaging=False # parsed if present, and supercedes any previous DESTDIR picked up from # environment. -for i, arg in enumerate(sys.argv): - if "--prefix" in arg: - prefix = arg.split('=')[1] +for i, arg in enumerate(argv): + if "--prefix" in arg: + prefix = arg.split('=')[1] # Given the above prefix possibilities, as well as root and DESTDIR, we need to # construct a list of data directories to be installed @@ -43,45 +42,43 @@ for i, arg in enumerate(sys.argv): # on the command line in preference to the configure prefix. # First parse the plugin directories -plugin_dirs = [dir for dir in os.listdir('plugins') if os.path.isdir(os.path.join('plugins', dir)) and dir[0] != '.'] +plugin_dirs = [dir for dir in listdir('plugins') + if isdir(join('plugins', dir)) and dir[0] != '.'] plugin_data_files = [] -if sys.platform == 'darwin' and packaging: - for plugin in plugin_dirs: - plugin_data_files.append(("./plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) +if platform == 'darwin' and packaging: + for plugin in plugin_dirs: + plugin_data_files.append(("./plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) else: - for plugin in plugin_dirs: - if prefix is None: - plugin_data_files.append(("@prefix@/share/diamond/plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) - else: - plugin_data_files.append((prefix + "/share/diamond/plugins/" + plugin, - glob.glob('plugins/' + plugin + '/*.py'))) + for plugin in plugin_dirs: + if prefix is None: + plugin_data_files.append( + ("@prefix@/share/diamond/plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) + else: + plugin_data_files.append( + (prefix + "/share/diamond/plugins/" + plugin, + glob('plugins/' + plugin + '/*.py'))) # Now parse the GUI directories gui_data_files = [] -if sys.platform == 'darwin' and packaging : - gui_data_files.append(("./gui", - ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) +if platform == 'darwin' and packaging: + gui_data_files.append( + ("./gui", ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) else: - if prefix is None: - gui_data_files.append(("@prefix@/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) - else: - gui_data_files.append((prefix + "/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) + if prefix is None: + gui_data_files.append(("@prefix@/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) + else: + gui_data_files.append((prefix + "/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) # We now have all the information we need; run setup. -setup( - name='diamond', - version='1.0', +setup(name='diamond', version='1.0', description="Fluidity preprocessor", - author = "The ICOM team", - author_email = "patrick.farrell@imperial.ac.uk", - url = "http://amcg.ese.ic.ac.uk", - packages = ['diamond'], - package_dir = {'diamond': 'diamond'}, + author="The ICOM team", + author_email="patrick.farrell@imperial.ac.uk", + url="http://amcg.ese.ic.ac.uk", packages=['diamond'], + package_dir={'diamond': 'diamond'}, scripts=["bin/diamond"], - data_files = gui_data_files + plugin_data_files - ) - + data_files=gui_data_files + plugin_data_files) diff --git a/dxdiff/setup.py b/dxdiff/setup.py index d60d90133..b2993a0da 100644 --- a/dxdiff/setup.py +++ b/dxdiff/setup.py @@ -1,21 +1,10 @@ -from distutils.core import setup -import os -import os.path -import glob +from setuptools import setup -try: - destdir = os.environ["DESTDIR"] -except KeyError: - destdir = "" - -setup( - name='dxdiff', +setup(name='dxdiff', version='1.0', - description="An XML aware diff tool.", - author = "The ICOM team", - author_email = "fraser.waters08@imperial.ac.uk", - url = "http://amcg.ese.ic.ac.uk", - packages = ['dxdiff'], - scripts=["dxdiff/dxdiff"], - ) - + description="An XML aware diff tool", + author="The ICOM team", + author_email="fraser.waters08@imperial.ac.uk", + url="http://amcg.ese.ic.ac.uk", + packages=['dxdiff'], + scripts=["dxdiff/dxdiff"]) diff --git a/python/setup.py b/python/setup.py index da84618c8..c5f220b95 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,9 +1,17 @@ -from distutils.core import setup, Extension -import os.path +from os.path import abspath +from setuptools import setup, Extension -module1 = Extension('libspud', sources = ['libspud.c'], libraries=["spud"], library_dirs=[os.path.abspath("..")], include_dirs=[os.path.abspath("../include")]) - -setup (name = 'libspud', - version = '1.1.3', - description = 'Python bindings for libspud', - ext_modules = [module1]) +setup(name='libspud', + version='1.1.3', + description='Python bindings for libspud', + ext_modules=[Extension('libspud', sources=['libspud.c'], + libraries=["spud"], + # path to libspud (the actual library, not the c-extension python wrapper + # which will be put in the parent directory by "make libspud.la" + # NOTE: For this to work you have to run "python setup.py build" from the + # original directory of the current file separately before + # running pip install, as pip will build the extension (if it's not built already) + # outside of the current context + library_dirs=[abspath("..")], + # path to spud.h + include_dirs=[abspath("../include")])]) From ad77b61c20234cf9ecfec2833e3f9223d135e45d Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 19:18:46 +0000 Subject: [PATCH 09/10] Try python setup.py install again --- Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3fb7e2002..b57a8d07b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -98,13 +98,13 @@ install-spudtools: @INSTALL@ -m644 schema/spud_base.rng $(DESTDIR)@prefix@/share/spud install-diamond: - python3 -mpip install --prefix=$(DESTDIR)@prefix@ diamond/ + cd diamond; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. install-pyspud: - python3 -mpip install --prefix=$(DESTDIR)@prefix@ python/ + cd python; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. install-dxdiff: - python3 -mpip install --prefix=$(DESTDIR)@prefix@ dxdiff/ + cd dxdiff; python3 setup.py install --prefix=$(DESTDIR)@prefix@; cd .. clean: @cd doc; $(MAKE) clean From c38ea9a8df28d9088cbf64d302a092b2b2d0f817 Mon Sep 17 00:00:00 2001 From: Stephan Kramer Date: Mon, 31 Oct 2022 19:23:57 +0000 Subject: [PATCH 10/10] Revert "Revert "Revert back to distutils"" This reverts commit 3e17fb754a831de11a187ebdfffa6510e138c9ec. --- diamond/setup.py.in | 85 +++++++++++++++++++++++---------------------- dxdiff/setup.py | 27 +++++++++----- python/setup.py | 24 +++++-------- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/diamond/setup.py.in b/diamond/setup.py.in index 04ce6a3fd..ff24e3ae7 100644 --- a/diamond/setup.py.in +++ b/diamond/setup.py.in @@ -1,19 +1,20 @@ -from glob import glob -from os import listdir -from os.path import isdir, join -from setuptools import setup -from sys import argv, platform +from distutils.core import setup +from distutils.extension import Extension +import os +import os.path +import glob # There are a number of local hacks in this file, to deal with the multiple -# ways in which setup.py is called by various scripts and packaging methods +# ways in which setup.py is called by various scripts and packaging methods # that interact with spud, enabling setuptools to grok their intentions. # In some cases, we will be passed a 'DESTDIR' from an upstream packagaing # system. This will be a local directory to install into, and act as local '/' -# as far as all paths are concerned. Check for this and fail nicely if not set. +# as far as all paths are concerned. Check for this, and fail nicely if not set. prefix = None -packaging = False +import sys +packaging=False # We may also be given prefix, either as a configuration option (which will be # dealt with by substitutions later) or as a command line option. If a command @@ -26,9 +27,9 @@ packaging = False # parsed if present, and supercedes any previous DESTDIR picked up from # environment. -for i, arg in enumerate(argv): - if "--prefix" in arg: - prefix = arg.split('=')[1] +for i, arg in enumerate(sys.argv): + if "--prefix" in arg: + prefix = arg.split('=')[1] # Given the above prefix possibilities, as well as root and DESTDIR, we need to # construct a list of data directories to be installed @@ -42,43 +43,45 @@ for i, arg in enumerate(argv): # on the command line in preference to the configure prefix. # First parse the plugin directories -plugin_dirs = [dir for dir in listdir('plugins') - if isdir(join('plugins', dir)) and dir[0] != '.'] +plugin_dirs = [dir for dir in os.listdir('plugins') if os.path.isdir(os.path.join('plugins', dir)) and dir[0] != '.'] plugin_data_files = [] -if platform == 'darwin' and packaging: - for plugin in plugin_dirs: - plugin_data_files.append(("./plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) +if sys.platform == 'darwin' and packaging: + for plugin in plugin_dirs: + plugin_data_files.append(("./plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) else: - for plugin in plugin_dirs: - if prefix is None: - plugin_data_files.append( - ("@prefix@/share/diamond/plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) - else: - plugin_data_files.append( - (prefix + "/share/diamond/plugins/" + plugin, - glob('plugins/' + plugin + '/*.py'))) + for plugin in plugin_dirs: + if prefix is None: + plugin_data_files.append(("@prefix@/share/diamond/plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) + else: + plugin_data_files.append((prefix + "/share/diamond/plugins/" + plugin, + glob.glob('plugins/' + plugin + '/*.py'))) # Now parse the GUI directories gui_data_files = [] -if platform == 'darwin' and packaging: - gui_data_files.append( - ("./gui", ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) +if sys.platform == 'darwin' and packaging : + gui_data_files.append(("./gui", + ["gui/gui.ui", "gui/diamond.svg", "gui/diamond.png"])) else: - if prefix is None: - gui_data_files.append(("@prefix@/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) - else: - gui_data_files.append((prefix + "/share/diamond/gui", - ["gui/gui.ui", "gui/diamond.svg"])) + if prefix is None: + gui_data_files.append(("@prefix@/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) + else: + gui_data_files.append((prefix + "/share/diamond/gui", + ["gui/gui.ui", "gui/diamond.svg"])) # We now have all the information we need; run setup. -setup(name='diamond', version='1.0', +setup( + name='diamond', + version='1.0', description="Fluidity preprocessor", - author="The ICOM team", - author_email="patrick.farrell@imperial.ac.uk", - url="http://amcg.ese.ic.ac.uk", packages=['diamond'], - package_dir={'diamond': 'diamond'}, + author = "The ICOM team", + author_email = "patrick.farrell@imperial.ac.uk", + url = "http://amcg.ese.ic.ac.uk", + packages = ['diamond'], + package_dir = {'diamond': 'diamond'}, scripts=["bin/diamond"], - data_files=gui_data_files + plugin_data_files) + data_files = gui_data_files + plugin_data_files + ) + diff --git a/dxdiff/setup.py b/dxdiff/setup.py index b2993a0da..d60d90133 100644 --- a/dxdiff/setup.py +++ b/dxdiff/setup.py @@ -1,10 +1,21 @@ -from setuptools import setup +from distutils.core import setup +import os +import os.path +import glob -setup(name='dxdiff', +try: + destdir = os.environ["DESTDIR"] +except KeyError: + destdir = "" + +setup( + name='dxdiff', version='1.0', - description="An XML aware diff tool", - author="The ICOM team", - author_email="fraser.waters08@imperial.ac.uk", - url="http://amcg.ese.ic.ac.uk", - packages=['dxdiff'], - scripts=["dxdiff/dxdiff"]) + description="An XML aware diff tool.", + author = "The ICOM team", + author_email = "fraser.waters08@imperial.ac.uk", + url = "http://amcg.ese.ic.ac.uk", + packages = ['dxdiff'], + scripts=["dxdiff/dxdiff"], + ) + diff --git a/python/setup.py b/python/setup.py index c5f220b95..da84618c8 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,17 +1,9 @@ -from os.path import abspath -from setuptools import setup, Extension +from distutils.core import setup, Extension +import os.path -setup(name='libspud', - version='1.1.3', - description='Python bindings for libspud', - ext_modules=[Extension('libspud', sources=['libspud.c'], - libraries=["spud"], - # path to libspud (the actual library, not the c-extension python wrapper - # which will be put in the parent directory by "make libspud.la" - # NOTE: For this to work you have to run "python setup.py build" from the - # original directory of the current file separately before - # running pip install, as pip will build the extension (if it's not built already) - # outside of the current context - library_dirs=[abspath("..")], - # path to spud.h - include_dirs=[abspath("../include")])]) +module1 = Extension('libspud', sources = ['libspud.c'], libraries=["spud"], library_dirs=[os.path.abspath("..")], include_dirs=[os.path.abspath("../include")]) + +setup (name = 'libspud', + version = '1.1.3', + description = 'Python bindings for libspud', + ext_modules = [module1])