views:

1008

answers:

4

Hi all,

I am writing python scripts and execute them in a Makefile. The python script is used to process data in a pipeline. I would like Makefile to execute the script every time I make a change to my python scripts. Does anyone have an idea of how to do this?

Thanks a lot!

+4  A: 

That's not a lot of information, so this answer is a bit vague. The basic principle of Makefiles is to list dependencies for each target; in this case, your target (let's call it foo) depends on your python script (let's call it do-foo.py):

foo: do-foo.py
    python do-foo.py > foo

Now foo will be rerun whenever do-foo.py changes (provided, of course, you call make).

chrispy
I did not define the dependency to my .py files correctly in my script. thanks
Patrick
A: 

If you want that Makefile to be automatically "maked" immediately after saving, pyinotify, which is a wrapper for inotify, might be the only possibility under Linux. It registers at the kernel to detect FS changes and calls back your function.

See my previous post on that topic.

wr
good to know! but I think I my question was a little bit unclear it was more a makefile question. Thanks anyway!
Patrick
+1  A: 

And in case when the scripts that need to be run don't produce any useful output file that can be used as a target, you can just use a dummy target:

scripts=a.py b.py c.py
checkfile=.pipeline_up_to_date

$(checkfile): $(scripts)
    touch $(checkfile)
    echo "Launching some commands now."

default: $(checkfile)
yacoob
what about .PHONY? http://gnu.huihoo.org/make-3.77/html_node/make_33.html
wr
A: 

This is not a direct answer to your question, but I suggest you to read this tutorial dedicated to scientists approaching bioinformatics: - http://swc.scipy.org/lec/build.html

And all the info related to this page: - http://biowiki.org/MakeComparison

dalloliogm