diff --git a/Makefile.m4 b/Makefile.m4 new file mode 100644 index 0000000..b2b9f04 --- /dev/null +++ b/Makefile.m4 @@ -0,0 +1,30 @@ +PREFIX=M4_PREFIX +BIN_DIR=M4_BINDIR +DATA_DIR=M4_DATADIR +PY_DIR=M4_PYDIR +DOC_DIR=M4_DOCDIR + +SCRIPTS_DIR=${DATA_DIR}/laydi/scripts/ + +install: install_laydi install_doc + +install_laydi: + ## Install binary files + install -m 755 -D bin/fluents ${BIN_DIR}/fluents + install -m 755 -D bin/dataset ${BIN_DIR}/dataset + + ## Install library files + find fluents/ -type f -name '*.py' -exec install -m 644 -D {} ${PY_DIR}/{} \; + find fluents/ -type f -name '*.glade' -exec install -m 644 -D {} ${PY_DIR}/{} \; + + ## Install icons + find icons/ -type f -name '*.png' -exec install -m 644 -D {} ${DATA_DIR}/{} \; + +install_scripts: + find scripts/ -type f -exec install -D {} ${SCRIPTS_DIR}/{} \; + +install_doc: + DOC_DIR=${DOC_DIR}/ make -C doc install + install -m 644 README ${DOC_DIR}/ + install -m 644 LICENSE ${DOC_DIR}/ + diff --git a/bin/fluents b/bin/fluents index 7bda116..3e122f8 100755 --- a/bin/fluents +++ b/bin/fluents @@ -5,7 +5,8 @@ import os import sys from fluents import fluents, project, workflow, main #import workflows -import cfgparse, optparse +from fluents import cfgparse +import optparse PROGRAM_NAME = 'fluents' VERSION = '0.1.0' @@ -60,6 +61,10 @@ if __name__ == '__main__': options, params = parse_options() main.options = options + for dir in main.options.workflowdir.split(';'): + if dir.strip() != "" and os.path.exists(dir): + sys.path.append(dir) + if options.list_workflows: list_workflows() sys.exit(0) diff --git a/configure b/configure new file mode 100755 index 0000000..c66407e --- /dev/null +++ b/configure @@ -0,0 +1,37 @@ +#!/bin/bash + + +TEMP=`getopt -o "" --long prefix:,bindir:,datadir:,pydir: \ + -n 'configure' -- "$@"` + +eval set -- "$TEMP" + +while true ; do + case "$1" in + --prefix) PREFIX=$2 ; shift 2 ;; + --bindir) BINDIR=$2 ; shift 2 ;; + --datadir) DATADIR=$2 ; shift 2 ;; + --pydir) PYDIR=$2 ; shift 2 ;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + +if [[ $PREFIX == "" ]] ; then PREFIX=/usr/local ; fi +if [[ $BINDIR == "" ]] ; then BINDIR=$PREFIX/bin ; fi +if [[ $DATADIR == "" ]] ; then DATADIR=$PREFIX/share/laydi ; fi +if [[ $DOCDIR == "" ]] ; then DOCDIR=$PREFIX/share/doc/laydi; fi +if [[ $PYDIR == "" ]] ; then PYDIR=$PREFIX/share/python-support/laydi; fi + +m4 -D M4_PREFIX=$PREFIX -D M4_BINDIR=$BINDIR \ + -D M4_DATADIR=$DATADIR -D M4_DOCDIR=$DOCDIR \ + -D M4_PYDIR=$PYDIR Makefile.m4 > Makefile + +m4 -D M4_PREFIX=$PREFIX -D M4_BINDIR=$BINDIR \ + -D M4_DATADIR=$DATADIR -D M4_DOCDIR=$DOCDIR \ + -D M4_PYDIR=$PYDIR doc/Makefile.m4 > doc/Makefile + +m4 -D M4_PREFIX=$PREFIX -D M4_BINDIR=$BINDIR \ + -D M4_DATADIR=$DATADIR -D M4_DOCDIR=$DOCDIR \ + -D M4_PYDIR=$PYDIR fluents/paths.py.m4 > fluents/paths.py + diff --git a/debian/rules b/debian/rules index 67780d5..164ed0c 100755 --- a/debian/rules +++ b/debian/rules @@ -13,22 +13,21 @@ CFLAGS = -Wall -g PYVERS=$(shell pyversions -vs) configure: configure-stamp + configure-stamp: dh_testdir - touch configure-stamp build: $(PYVERS:%=build-python%) build-python%: dh_testdir - python$* setup.py build +# python$* setup.py build touch $@ clean: # Add here commands to clean up after the build process. -rm -r build - dh_clean install: build $(PYVERS:%=install-python%) @@ -37,8 +36,10 @@ install-python%: dh_testroot dh_clean -k dh_installdirs - - python$* setup.py install --root=$(CURDIR)/debian/fluents --install-data=/usr/share/fluents + ./configure --prefix ${CURDIR}/debian/fluents/usr + sed -i 's:${CURDIR}/debian/fluents::' fluents/paths.py + make install +# python$* setup.py install --root=$(CURDIR)/debian/fluents --install-data=/usr/share/fluents # Remove all *.pyc files, created in the postinst # find $(CURDIR)/debian/python-networkx -name "*.pyc" -exec rm {} ';' @@ -46,8 +47,9 @@ install-python%: # Build architecture-independent files here. binary-indep: build install - mkdir -p $(CURDIR)/debian/fluents-doc/usr/share/doc/fluents-doc/html - epydoc --html -o $(CURDIR)/debian/fluents-doc/usr/share/doc/fluents-doc/html fluents + make -C doc install +# mkdir -p $(CURDIR)/debian/fluents-doc/usr/share/doc/fluents-doc/html +# epydoc --html -o $(CURDIR)/debian/fluents-doc/usr/share/doc/fluents-doc/html fluents # Build architecture-dependent files here. binary-arch: build install @@ -70,4 +72,4 @@ binary-arch: build install dh_builddeb binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/doc/Makefile b/doc/Makefile index 6dbf8ad..aca46da 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,4 +1,6 @@ +DOC_DIR=/home/einarr/src/fluents-8/debian/fluents/usr/share/doc/laydi + all: html html: @@ -8,7 +10,11 @@ html: @echo ---------------- epydoc --html --inheritance listed -o html/ ../fluents 2> epydoc-html.log +install: + find html/ -type f -exec install -m 644 -D '{}' ${DOC_DIR}/'{}' \; + clean: -rm -rf html -rm epydoc-html.log + diff --git a/doc/Makefile.m4 b/doc/Makefile.m4 new file mode 100644 index 0000000..6946e8d --- /dev/null +++ b/doc/Makefile.m4 @@ -0,0 +1,20 @@ + +DOC_DIR=M4_DOCDIR + +all: html + +html: + @echo ---------------- + @echo Generating epydoc html code documentation. + @echo See epydoc-html.log for epydoc log. + @echo ---------------- + epydoc --html --inheritance listed -o html/ ../fluents 2> epydoc-html.log + +install: + find html/ -type f -exec install -m 644 -D '{}' ${DOC_DIR}/'{}' \; + +clean: + -rm -rf html + -rm epydoc-html.log + + diff --git a/cfgparse.py b/fluents/cfgparse.py similarity index 100% rename from cfgparse.py rename to fluents/cfgparse.py diff --git a/fluents/fluents.py b/fluents/fluents.py index 3e10d56..7d0b893 100644 --- a/fluents/fluents.py +++ b/fluents/fluents.py @@ -19,9 +19,10 @@ from logger import logger, LogView PROGRAM_NAME = 'fluents' VERSION = '0.1.0' -DATADIR = os.path.dirname(sys.modules['fluents'].__file__) -ICONDIR = os.path.join(DATADIR,"..","icons") -GLADEFILENAME = os.path.join(DATADIR, 'fluents.glade') +DATADIR = os.path.join(main.PYDIR, 'fluents') +#ICONDIR = os.path.join(DATADIR,"..","icons") +ICONDIR = main.ICONDIR +GLADEFILENAME = os.path.join(main.PYDIR, 'fluents/fluents.glade') _icon_mapper = {dataset.Dataset: 'dataset', dataset.CategoryDataset: 'category_dataset', dataset.GraphDataset: 'graph_dataset', diff --git a/fluents/main.py b/fluents/main.py index 9ed81ef..ca61570 100644 --- a/fluents/main.py +++ b/fluents/main.py @@ -1,5 +1,16 @@ import sys +import os.path +import paths + +# Site specific directories set by configure script. +PREFIX = paths.PREFIX +BINDIR = paths.BINDIR +DATADIR = paths.DATADIR +DOCDIR = paths.DOCDIR +PYDIR = paths.PYDIR + +ICONDIR = os.path.join(DATADIR, 'icons') #: Dictionary of observers _observers = {} diff --git a/fluents/paths.py.m4 b/fluents/paths.py.m4 new file mode 100644 index 0000000..0a8c799 --- /dev/null +++ b/fluents/paths.py.m4 @@ -0,0 +1,7 @@ + +PREFIX = "M4_PREFIX" +BINDIR = "M4_BINDIR" +DATADIR = "M4_DATADIR" +DOCDIR = "M4_DOCDIR" +PYDIR = "M4_PYDIR" + diff --git a/fluents/workflow.py b/fluents/workflow.py index bb42cbc..6777fcb 100644 --- a/fluents/workflow.py +++ b/fluents/workflow.py @@ -6,12 +6,11 @@ import logger import fluents import main -def _workflow_classes(modname): +def _workflow_classes(dir, modname): """Returns a list of all subclasses of Workflow in a given module""" workflow_classes = [] - __import__('workflows.%s' % modname) - module = sys.modules['workflows.%s' % modname] + module = __import__('%s' % (modname,)) d = module.__dict__ for wf in d.values(): @@ -58,7 +57,7 @@ def find_workflow(basename): fn = os.path.join(dir, "%s.py" % basename) if os.path.isfile(fn): wf_file = fn - return _workflow_classes(basename)[0] + return _workflow_classes(dir, basename)[0] return None