Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing command line arguments to a python script, called from a Makefile

I have just started using GNU's make command to automate things. I ran into a problem and need some help. I have a python script (abc.py) which accepts a command line argument with short notation as ("-t") and long notation("--type") and can be run as :

python abc.py --type "blah"

However, I wish to run this script(abc.py) from a Makefile. So, now my Makefile looks as:

command:
    python abc.py

I can now execute the code as make command, but how do I accept and pass the user input to abc.py? Hope, the question is well formed.

like image 574
Aditya Mishra Avatar asked Mar 03 '26 12:03

Aditya Mishra


1 Answers

TBH this isn't really what make designed to do. You'd typically get make to figure out the parameter programmatically or use different targets for different sets of parameters. This can be achieved using environment variables. If you changed your makefile to look like this:

command:
    python abc.py ${PARAMS}

Your command would then look like this:

make command PARAMS='--type "blah"'
like image 124
digby280 Avatar answered Mar 05 '26 04:03

digby280