I have a bunch of Python scripts that I use in a pipeline to read files, and convert the data to create and populate a sqlite3 database.
I use a makefile to do this; as some of my input files are fairly large, i.e. 5GB and therefore take a considerable time to process, I don't want the makefile to rerun the whole pipeline when I edit just one file.
However, because they all edit the same file, i.e. the database file, they're all in effect phony targets. Is there a way to make it so that make only reruns the targets that have had their files edited?
Here is the makefile that I'm using:
.PHONY: all
all: blogs.db
blogs.db: create users posts likes blogs blog_likes
.PHONY: create
create: create.py
$(PYTHON) create.py
.PHONY: users
users: users.py
$(PYTHON) users.py
.PHONY: posts
posts: posts.py
$(PYTHON) posts.py
.PHONY: likes
likes: likes.py
$(PYTHON) likes.py
.PHONY: blogs
blogs: blogs.py
$(PYTHON) blogs.py
.PHONY: blog_likes
blog_likes: blog_likes.py
$(PYTHON) blog_likes.py
You don't need dummy files, provided nothing other than these scripts is modifying the database:
SCRIPTS = create.py users.py posts.py likes.py blogs.py blog_likes.py
.PHONY: all
all: blogs.db
blogs.db: $(SCRIPTS)
@for s in $?; do $(PYTHON) $$s; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With