Make file on Windows ? Yes why not.

Makefile is a set of commands to be executed one after another mainly used with Linux operating system.

With this tool you can write simple scripts that will allow you change repetitive tasks into one line of code. You can also use power shell scripting but that’s for later….

In my example ill want to fix my virtual environment for python app by:
-execute command for creating venv ( python -m venv .venv )
-operate on virtual environment  ( \venv\Scripts\ )
-install requirements from txt file ( pip install -r Requriments.txt )
-execute main file ( python ) trough venv
-have an solution to fix my venv in case it’s not created or launched on another computer.
– In short -> remove old folder, recreate fresh env, install requirements, display installed libraries.

So where to start ?
1.Check in a cmd or power shell is your Choco package manager installed if not go to: and follow the steps there then type in shell “choco install make”.

2.Lests play with our make file. Create an empty file named how you want my one will be “Makefile”

3.Open and edit the file.

I highly recommend you to use visual studio code with this extension enabled. Sometimes hidden tabs will break the functionality of make file especially under windows. 

And here there is a bit of setup. First let’s create a variable BIN with the path to Scripts folder. This is a folder that is normally created when you execute a command
“python -m venv env_foldername”.

I was trying to find a way to activate env and then do the commands but that don’t work for me. So here is my solution.

First let’s set up where our Scripts folder is. This will be important as we don’t have to duplicate our path every time, and instead just use $(BIN) instead.

The first parameter.

Will always run if you type “make” in shell.

If you want to use other parameters or other sets of commands type “make setname -I”  dash -I ignores errors that might come up when you are trying to create folder that already exist or something similar. So, I’ll run this command by typing “make fix -I” which will ignore errors. And allows the script to continue.

And now if I want to run my script, I’ll just type “make” in a project source and I should see output of run.

The final content of Makefile: