Prev: Reminder: 6 days left for EuroPython 2010 talk submissions
Next: Reading a binary file and wrtiting the bytes verbatimin an utf-8 file
From: Makoto Kuwata on 25 Apr 2010 08:46 On Sun, Apr 25, 2010 at 5:53 AM, Jonathan Fine <jfine(a)pytex.org> wrote: > I'm hoping to avoid reinventing a wheel (or other rolling device). I've got > a number of dependencies and, if possible, I want to order them so that each > item has its dependencies met before it is processed. > > I think I could get what I want by writing and running a suitable makefile, > but that seems to be such a kludge. > > Does anyone know of an easily available Python solution? If you are looking for alternatives of Make or Ant, try pyKook. pyKook is a pure-Python tool similar to Make, Ant, or Rake. http://www.kuwata-lab.com/kook/pykook-users-guide.html http://pypi.python.org/pypi/Kook/ example (Kookbook.py): CC = prop('CC', 'gcc') CFLAGS = prop('CFLAGS', '-g -O2') @recipe @ingreds('hello.o') def task_all(c): """compile all *.o""" # recipe description pass @recipe @product("*.o") @ingreds("$(1).c", if_exists("$(1).h")) def file_o(c): """compile '*.c' and '*.h' into '*.o'""" # recipe description system(c%"$(CC) $(CFLAGS) -c $(ingred)") example of command-line: ~/tmp> kk all ### ** hello.o (recipe=file_o) $ gcc -g -O2 -c hello.c ### * all (recipe=task_all) -- regards, makoto kuwata
From: Eduardo Schettino on 25 Apr 2010 11:09 On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine <jfine(a)pytex.org> wrote: > Hi > > I'm hoping to avoid reinventing a wheel (or other rolling device). I've got > a number of dependencies and, if possible, I want to order them so that each > item has its dependencies met before it is processed. > > I think I could get what I want by writing and running a suitable makefile, > but that seems to be such a kludge. > > Does anyone know of an easily available Python solution? http://pypi.python.org/pypi/doit
From: Jonathan Fine on 25 Apr 2010 11:43 Makoto Kuwata wrote: > On Sun, Apr 25, 2010 at 5:53 AM, Jonathan Fine <jfine(a)pytex.org> wrote: >> I'm hoping to avoid reinventing a wheel (or other rolling device). I've got >> a number of dependencies and, if possible, I want to order them so that each >> item has its dependencies met before it is processed. >> >> I think I could get what I want by writing and running a suitable makefile, >> but that seems to be such a kludge. >> >> Does anyone know of an easily available Python solution? > > If you are looking for alternatives of Make or Ant, try pyKook. > pyKook is a pure-Python tool similar to Make, Ant, or Rake. > http://www.kuwata-lab.com/kook/pykook-users-guide.html > http://pypi.python.org/pypi/Kook/ Thank you for this, Makoto. However, all I require is a means of ordering the items that respects the dependencies. This rest I can, and pretty much have to, manage myself. So probably something more lightweight would suit me. -- Jonathan
From: Jonathan Fine on 25 Apr 2010 11:44 Eduardo Schettino wrote: > On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine <jfine(a)pytex.org> wrote: >> Hi >> >> I'm hoping to avoid reinventing a wheel (or other rolling device). I've got >> a number of dependencies and, if possible, I want to order them so that each >> item has its dependencies met before it is processed. >> >> I think I could get what I want by writing and running a suitable makefile, >> but that seems to be such a kludge. >> >> Does anyone know of an easily available Python solution? > > http://pypi.python.org/pypi/doit Thank you for this, Eduardo. However, all I require is a means of ordering the items that respects the dependencies. This rest I can, and pretty much have to, manage myself. So probably something more lightweight would suit me. -- Jonathan
From: Eduardo Schettino on 25 Apr 2010 12:05
On Sun, Apr 25, 2010 at 11:44 PM, Jonathan Fine <jfine(a)pytex.org> wrote: > Eduardo Schettino wrote: >> >> On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine <jfine(a)pytex.org> wrote: >>> >>> Hi >>> >>> I'm hoping to avoid reinventing a wheel (or other rolling device). I've >>> got >>> a number of dependencies and, if possible, I want to order them so that >>> each >>> item has its dependencies met before it is processed. >>> >>> I think I could get what I want by writing and running a suitable >>> makefile, >>> but that seems to be such a kludge. >>> >>> Does anyone know of an easily available Python solution? >> >> http://pypi.python.org/pypi/doit > > > Thank you for this, Eduardo. However, all I require is a means of ordering > the items that respects the dependencies. This rest I can, and pretty much > have to, manage myself. > > So probably something more lightweight would suit me. you just want a function? def order_tasks(tasks): ADDING, ADDED = 0, 1 status = {} # key task-name, value: ADDING, ADDED task_order = [] def add_task(task_name): if task_name in status: # check task was alaready added if status[task_name] == ADDED: return # detect cyclic/recursive dependencies if status[task_name] == ADDING: msg = "Cyclic/recursive dependencies for task %s" raise Exception(msg % task_name) status[task_name] = ADDING # add dependencies first for dependency in tasks[task_name]: add_task(dependency) # add itself task_order.append(task_name) status[task_name] = ADDED for name in tasks.keys(): add_task(name) return task_order if __name__ == '__main__': task_list = {'a':['b','c'], 'b':['c'], 'c':[]} print order_tasks(task_list) |