Running a Python script in a Makefile
Question: I have a Python script (scr1.py) that calls another Python script (scr2.py)
and they both on the same path. When I open CMD and run scr1.py everything
works perfectly.

I want to run scr1.py inside a Makefile that is NOT on the same path as the
scripts. The scr1.py is executing but fail on calling scr2.py. I think the
problem is that scr1.py searches the Makefile directory instead of the scripts
directory. How can I fix it?

The code:

    
    
    import os
    import scr2
    fileinfo = os.stat('scr2.py')
    
    if os.path.isfile("infofile.txt"):          
        file=open("infofile.txt",'r')       
        lm = file.read()
        file.close()
        if lm == str(fileinfo.st_mtime): 
            #Do_Something
        else:
            scr2
    else:
        scr2
        file = open("infofile.txt",'w')
    

OK, I just fount another problem. When you import another file, it runs this
file IN THE IMPORT LINE! It means that this isn't the right way to import a
file, unless you use the import line where you want to run the script, but it
is so ugly.


Answer: Since both files are in same directory, how about just appending the current
working directory path before second file name ?

    
    
    import os
    import scr2
    fileinfo = os.stat( os.getcwd() + '/scr2.py')
    
    if os.path.isfile("infofile.txt"):          
        file=open("infofile.txt",'r')       
        lm = file.read()
        file.close()
        if lm == str(fileinfo.st_mtime): 
            #Do_Something
        else:
            scrcompile                                  
    else:
        scrcompile                      
        file = open("infofile.txt",'w') 
    

