Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you elaborate on this? As a Make newbie, what you wrote seems like something that I would do...


So you want to populate your virtual environment before you run the unit tests, right?

The command to do so is trivial, but when do you need to actually execute it?

Normal make targets have prerequisites and outcomes (I think they are called goals). These must be files and make works by comparing their modification timestamps to see if a recipe has to be (re-)executed.

Now what is the prerequisite for your virtual environment?

What is the output? venv/bin/python ? What if you need to pip install some stuff (maybe only for testing)? What happens when the installation of a single package fails?

I think having a script (or a phony target for people with strange tastes ;) ) makes at least clear that there is no half-assed dependency tracking ongoing.

I think one way to figure this out would be to have a test script that runs inside the venv and outputs some kind of checksum.


That's actually really easy. Your target here is your venv site-packages, while requirements file is the prerequisite. The idea is that your site-packages folder has to be recreated/updated (pip install) when it is older than the requirements file. One thing you have to do is to simply update the directory timestamp each time you add a dependency, because adding a file into a folder does not change the folder timestamp. Having that it would be like

venv/site-packages: requirements.txt pip install -r $< touch $@


I am pretty sure that this does not work. Maybe GNU Make accepts folders as targets (but that would be news to me). But even then, the folder itself does not inform you whether your pip install was successful or not.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: