Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting environment variable in makefile and reading it from python script does not work [duplicate]

I am setting a environment variable (bash) in makefile and I am executing a python script on the next line in the makefile. However, when I try to read the environment variable in the python script using os.environ.get() I am unable to read the environment variable. What is the best way to achieve this?

like image 979
user376507 Avatar asked Oct 20 '25 01:10

user376507


1 Answers

You need to export it in the same line:

target:
        export FOO=bar; python /the/script.py

or

target:
        export FOO=bar; \
        python /the/script.py
like image 94
pynexj Avatar answered Oct 21 '25 15:10

pynexj