diff --git a/bin/irpf90 b/bin/irpf90 index 7185129..ff8948b 100755 --- a/bin/irpf90 +++ b/bin/irpf90 @@ -4,7 +4,7 @@ import os import sys wd = os.path.abspath(os.path.dirname(__file__)) -wd += "/../src/" -sys.path.append(wd) +sys.path.insert(0,(wd+"/../src/")) +sys.path.insert(0,(wd+"/../share/irpf90/src/")) import irpf90 diff --git a/bin/irpman b/bin/irpman index 6a188df..2947c67 100755 --- a/bin/irpman +++ b/bin/irpman @@ -4,8 +4,8 @@ import os import sys wd = os.path.abspath(os.path.dirname(__file__)) -wd += "/../src/" -sys.path.append(wd) +sys.path.insert(0,(wd+"/../src/")) +sys.path.insert(0,(wd+"/../share/irpf90/src/")) if len(sys.argv) != 2: print "Usage:" diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz new file mode 100644 index 0000000..bf9f9a1 Binary files /dev/null and b/man/man1/irpf90.1.gz differ diff --git a/man/man1/irpman.1.gz b/man/man1/irpman.1.gz new file mode 100644 index 0000000..90cd0c5 Binary files /dev/null and b/man/man1/irpman.1.gz differ diff --git a/packages/Makefile b/packages/Makefile new file mode 100644 index 0000000..20c4810 --- /dev/null +++ b/packages/Makefile @@ -0,0 +1,17 @@ +include version +default: + rm *.rpm *.tar.gz 2> /dev/null ;\ + VERSION=$(VERSION) epm -m noarch irpf90 irpf90.list ;\ + cd noarch ;\ + cp ~/.rpmmacros .;\ + echo "%_topdir $$PWD" > ~/.rpmmacros ;\ + echo "%buildroot %_topdir/buildroot" >> ~/.rpmmacros ;\ + cd ..;\ + VERSION=$(VERSION) epm -m noarch -vv -f rpm irpf90 irpf90.list ;\ + cp noarch/.rpmmacros ~;\ + mv noarch/*.tar.gz . ;\ + mv noarch/*.rpm . ;\ + rm -rf noarch + +version: ../src/version.py + ./make_version.py > version diff --git a/packages/irpf90.list b/packages/irpf90.list new file mode 100644 index 0000000..3de3a01 --- /dev/null +++ b/packages/irpf90.list @@ -0,0 +1,57 @@ +# epm -f format irpf90 irpf90.list +# format: +# aix +# bsd +# depot or swinstall (HP-UX) +# dpkg +# inst or tardist (IRIX +# native (native for the current platform) +# osx +# pkg (Solaris) +# portable (default) +# rpm +# setld (Tru64) +# slackware + +# Product information +# ------------------- + +%product irpf90 +%copyright 2009 A. Scemama, CNRS +%vendor A. Scemama, CNRS +%license ../LICENSE +%readme ../README +%description IRP-Fortran90 preprocessor +%version $VERSION + +%format rpm +%requires python +%requires make + +%format all + +# Autoconfiguration variables +# --------------------------- + +$prefix=/usr +$exec_prefix=/usr +$bindir=${exec_prefix}/bin +$datadir=${exec_prefix}/share/irpf90/src +$docdir=${datadir}/share/irpf90/doc +$mandir=${datadir}/man +$srcdir=.. + +# Executables +# ----------- + +%system all +%description IRP-Fortran90 preprocessor +f 0444 root sys ${mandir}/man1/irpf90.1.gz ${srcdir}/man/man1/irpf90.1.gz +f 0444 root sys ${mandir}/man1/irpman.1.gz ${srcdir}/man/man1/irpman.1.gz +f 0555 root sys ${bindir}/irpf90 ${srcdir}/bin/irpf90 +f 0555 root sys ${bindir}/irpman ${srcdir}/bin/irpman +f 0555 root sys ${datadir}/ ${srcdir}/src/*.py +f 0444 root sys ${docdir}/README ${srcdir}/README +f 0444 root sys ${docdir}/LICENSE ${srcdir}/LICENSE + + diff --git a/packages/make_version.py b/packages/make_version.py new file mode 100755 index 0000000..fbca22a --- /dev/null +++ b/packages/make_version.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +import sys, os +wd = os.path.abspath(os.path.dirname(__file__)) +sys.path.insert(0,(wd+"/../src/")) +from version import * +print "VERSION=%s"%(version) diff --git a/src/command_line.py b/src/command_line.py index 8400b77..1a050e7 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -9,8 +9,6 @@ options['d'] = [ 'debug' , 'Activate debug', 0 ] options['v'] = [ 'version' , 'Print version of irpf90', 0 ] options['a'] = [ 'assert' , 'Activate assertions', 0 ] options['h'] = [ 'help' , 'Print this help', 0 ] -options['o'] = [ 'openmp' , 'Activate openMP', 0 ] -options['c'] = [ 'check_cycles' , 'Check cycles in dependencies', 0 ] options['i'] = [ 'init' , 'Initialize current directory', 0 ] options['D'] = [ 'define' , 'Define variable', 1 ] options['p'] = [ 'preprocess' , 'Preprocess file', 1 ] @@ -102,7 +100,11 @@ do_$LONG = property(fget=do_$LONG) def do_run(self): if '_do_run' not in self.__dict__: - self._do_run = not (self.do_version or self.do_init) + self._do_run = not ( \ + self.do_version or \ + self.do_help or \ + self.do_preprocess or \ + self.do_init ) return self._do_run do_run = property(fget=do_run) diff --git a/src/init.py b/src/init.py index e57ef10..c0f12d5 100644 --- a/src/init.py +++ b/src/init.py @@ -30,16 +30,20 @@ def init(): # Copy current files in the irpdir for filename in os.listdir(os.getcwd()): if not filename[0].startswith(".") and not os.path.isdir(filename): - file = open(filename,"r") - buffer = file.readlines() - file.close() - if not util.same_file(irpf90_t.irpdir+filename,buffer): + try: file = open(filename,"r") - buffer = file.read() - file.close() - file = open(irpf90_t.irpdir+filename,"w") - file.write(buffer) + except IOError: + print "Warning : Unable to read file %s."%(filename) + else: + buffer = file.readlines() file.close() + if not util.same_file(irpf90_t.irpdir+filename,buffer): + file = open(filename,"r") + buffer = file.read() + file.close() + file = open(irpf90_t.irpdir+filename,"w") + file.write(buffer) + file.close() initialized = True diff --git a/src/irpf90.py b/src/irpf90.py index f818b72..d8a1436 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -9,19 +9,19 @@ def main(): if command_line.do_version: from version import version print version - return + + from init import init + if command_line.do_init: + init() if command_line.do_preprocess: + init() from preprocessed_text import preprocessed_text for filename,text in preprocessed_text: if filename in command_line.preprocessed: for line in text: print line.text - return - from init import init - if command_line.do_init: - init() if not command_line.do_run: return diff --git a/src/irpf90_t.py b/src/irpf90_t.py index df0cd79..133ab3b 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -263,10 +263,9 @@ def create_irpf90_files(): result = [] from command_line import command_line import os - if command_line.do_run: - def is_irpf90_file(filename): - return filename.endswith(".irp.f") #DEUBUG and filename.startswith("p") - result = filter ( is_irpf90_file, os.listdir(os.getcwd()) ) + def is_irpf90_file(filename): + return filename.endswith(".irp.f") + result = filter ( is_irpf90_file, os.listdir(os.getcwd()) ) return result irpf90_files = create_irpf90_files() diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index af73226..90c4d47 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -159,6 +159,10 @@ def execute_shell(text): elif isinstance(line,End_shell): inside = False # Write script file + scriptname = "%s%s_shell_%d"%(irpdir,line.filename,line.i) + file = open(scriptname,'w') + file.writelines(script) + file.close() scriptname = "%s_shell_%d"%(line.filename,line.i) file = open(scriptname,'w') file.writelines(script) @@ -169,6 +173,7 @@ def execute_shell(text): lines = pipe.readlines() pipe.close() result += get_text(lines,scriptname) + os.remove(scriptname) else: script.append(line.text+'\n') else: diff --git a/src/version.py b/src/version.py index 566f6a4..b54c984 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.15" +version = "1.1.16"