Lots of changes in structure to make it possible to package the program while

still allowing workflows to be placed in several locations in the file system.

The installation procedure is now ./configure && make install configure will
run m4 on fluents/paths.py.m4, Makefile.m4 and doc/Makefile.m4 so that the
installation system and the program will know where some important directories
are located.

The paths.py.m4 and consequently also pahts.py files are just listings of
directories configured during install.  I did this to separate these from all
other files so that as little as possible is touched by m4. It is still
necessary to do an install now to get the program to run in a clean checkout.

Workflows can now be placed anywhere in the system. This is done by setting the
workflowdir variable in the configuration file. All workflow directories,
separated by semicolons, are added to the python path.

The use of setup.py is now deprecated.
This commit is contained in:
Einar Ryeng 2008-12-05 00:12:49 +00:00
parent b313cf29bc
commit 04b7cbb872
11 changed files with 134 additions and 16 deletions

30
Makefile.m4 Normal file
View File

@ -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}/

View File

@ -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)

37
configure vendored Executable file
View File

@ -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

18
debian/rules vendored
View File

@ -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

View File

@ -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

20
doc/Makefile.m4 Normal file
View File

@ -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

View File

@ -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',

View File

@ -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 = {}

7
fluents/paths.py.m4 Normal file
View File

@ -0,0 +1,7 @@
PREFIX = "M4_PREFIX"
BINDIR = "M4_BINDIR"
DATADIR = "M4_DATADIR"
DOCDIR = "M4_DOCDIR"
PYDIR = "M4_PYDIR"

View File

@ -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