python: unable to specify relative path for dll import
Question: I am trying to load a dll in python, and can only do so if I enter the
absolute path. I would like to use a relative path, or environment variables.
The only thing that works is if I specify the exact path (C:...) I even tried
to get the dll to build directly in the same folder as the py file, it still
didn't work.  
What I have:

    
    
    MY_DLL = r'c:\full_path\output\Win32\Debug\my.dll'
    #MY_DLL = r'my.dll'   #this doesn't work but it is what I want
    #MY_DLL = r'$(env_var)\dir\output\$(Platform)\$(Configuration)\my.dll'   #this doesn't work either but would be good too     
    

Help ?


Answer: I don't know about cdll on windows or really much about ctypes in general,
however, you can manipulate paths quite easily using os.path:

    
    
    import os.path
    p1="path.dll"
    print (os.path.abspath(p1))
    p2="${env_var}/path.dll"  #Make sure you set env_var in the calling environment...Otherwise it won't be expanded...
    print (os.path.expandvars(p2))
    

