Commit 00d063fa authored by incardon's avatar incardon

Fixing install script

parent 81cd91db
__author__ = 'i-bird'
import os
import shutil, errno
import configparser
from os import listdir
from os.path import isdir, join
class pack_example:
temporary=os.sep + "tmp" + os.sep + "pack_example"
base_dir=""
# Get the files to copy
def get_files(self,dir):
config = configparser.ConfigParser()
config.read(dir+os.sep+"config.cfg")
files = []
if "pack" in config:
if "files" in config["pack"]:
files = config["pack"]["files"]
files = str.split(files)
# for each filr add the prefix
for i in range(0,len(files)):
files[i] = dir+os.sep+files[i]
return files
# If the directory is an example
def is_example(self,dir):
return os.path.isfile(dir+os.sep+"config.cfg")
# Get the files to pack
def copy_example(self,dir):
print("Processing: " + dir)
files=self.get_files(dir)
try:
# Create the temporary folder
os.makedirs(self.temporary)
except FileExistsError:
pass
# make the example directory
if len(files) != 0:
head, tail = os.path.split(files[0])
try:
os.makedirs(self.temporary+os.sep+head[len(self.base_dir):])
except FileExistsError:
pass
for file in files:
print("copy src:"+file+" dst:"+self.temporary+os.sep+file[len(self.base_dir):])
shutil.copy(file,self.temporary+os.sep+file[len(self.base_dir):])
# Add examples in a recursive way
def add_r(self, dir):
if self.is_example(dir):
self.copy_example(dir)
# copy Makefile
print("copy src:"+dir+os.sep+"Makefile"+" dst:"+self.temporary+os.sep+"Makefile")
shutil.copy(dir+os.sep+"Makefile",self.temporary+os.sep+"Makefile")
# List all the folder in the directory
onlydir = [ f for f in listdir(dir) if isdir(join(dir,f)) ]
for example_dir in onlydir:
self.add_r(dir+os.sep+example_dir)
# Add an example path
def pack(self, dir, file):
# Remove temporary folders and recreate it
if os.path.exists(self.temporary):
shutil.rmtree(self.temporary)
os.makedirs(self.temporary)
if self.is_example(dir):
self.copy_example(dir)
self.base_dir = dir
# copy Makefile
print("copy src:"+dir+os.sep+"Makefile"+" dst:"+self.temporary+os.sep+"Makefile")
shutil.copy(dir+os.sep+"Makefile",self.temporary+os.sep+"Makefile")
# List all the folder in the directory
onlydir = [ f for f in listdir(dir) if isdir(join(dir,f)) ]
for example_dir in onlydir:
self.add_r(dir+os.sep+example_dir)
# make an archive
shutil.make_archive(file,"bztar",self.base_dir)
# python script that process the examples in particular it pack the examples, it generates the vtk files,
# the images out of the vtk files, the mardown wiki pages
import argparse
import os
from os import listdir
from os.path import isdir, join
from pack_examples import pack_example
parser = argparse.ArgumentParser(description='Pack the examples, generate the vtk files to generate images, create the markdown pages for the wiki')
parser.add_argument('directory', help='directory where are located the examples')
args = parser.parse_args()
# List all the folder in the directory
onlydir = [ f for f in listdir(args.directory) if isdir(join(args.directory,f)) ]
p = pack_example()
p.pack(args.directory,args.directory+os.sep+"examples")
......@@ -11,7 +11,7 @@ nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/commo
Grid/grid_dist_id.hpp Grid/grid_dist_id_iterator.hpp Grid/grid_dist_key.hpp \
Vector/vector_dist.hpp Vector/vector_dist_iterator.hpp Vector/vector_dist_key.hpp \
config/config.h \
SubdomainGraphNodes.hpp
metis_util.hpp dec_optimizer.hpp SubdomainGraphNodes.hpp
.cu.o :
$(NVCC) $(NVCCFLAGS) -o $@ -c $<
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment