0

I understand that if you assign value to a variable like below, it is assigned the value at declaration time:

 VER:=value

but when I do:

VER:=`python xxx.py`        

....
cd ../../pythoncode && python yyy.py $(VER) 

I got error saying no xxx.py file found, it is because that xxx.py is in the current folder, but when cd ../../pythoncode, xxx.py cannot be found.

How do I set the value of VER when VER is declared? so this way, VER value is set before cd ../../pythoncode, Thanks.

LJ

1
  • Why are you passing $(VER) (i.e. python xxx.py) as an argument to python xxx.py like that? Commented Oct 3, 2014 at 14:41

1 Answer 1

1

You are confusing variable assignment time and python runtime path lookup.

Your variable's value is being set at make parse time. That's not the problem.

The problem is that the path to your script is a relative path and path resolution/lookup is done by whatever process needs to use the file when it needs to use the file. So when you run python in that recipe line that python process sees xxx.py and assumes that it is relative to the current directory since you haven't told it anything else.

You could use VER:= python $(abspath xxx.py) to have make resolve xxx.py at make parse time and turn it into an absolute path. Then when you run python later it would get an absolute path to the script instead of a relative one.

There are other ways of solving this problem as well but for this case that is probably the simplest.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.