Re: substitute datadir in python script
Hello Bastien, * Bastien Dalla Piazza wrote on Sat, Mar 07, 2009 at 01:51:32PM CET: > > ascript.py: ascript_src.py > sed -e > "s#sys.append('pyexecdir')#sys.append('$(pyexecdir)')#g;s#datadir# > $(datadir)/@PACKAGE@/#g" ascript_src.py > ascript.py This looks good to me, except that, in the rule command, I guess you should be using $(srcdir) if the input file is distributed. You can portably use $@ for the target, though: ascript.py: ascript_src.py sed -e "s#sys.append('pyexecdir')#sys.append('$(pyexecdir)')#g;s#datadir# $(datadir)/@PACKAGE@/#g" $(srcdir)/ascript_src.py > $@ > I think I need an equivalent in python of the "config.h" header file, > but where to install it? Well, config.h headers are often compiler-specific, and use a global name space so headers generated from different packages clash, so they should not ever be installed; nor should installed header files depend upon config.h. Hope that helps. Cheers, Ralf
substitute datadir in python script
Hi all, I'm developing an application with mixed C++ and python. I wonder how to do the following: let's assume "alib.la" is a python extention library installed in $(pyexecdir) which depends on the prefix given by the user. Up to now, I was substituting the absolute directories path at install time using "sed" on my scripts source files, so adding to Makefile.am: ascript.py: ascript_src.py sed -e "s#sys.append('pyexecdir')#sys.append('$(pyexecdir)')#g;s#datadir# $(datadir)/@PACKAGE@/#g" ascript_src.py > ascript.py substituting "pyexecdir" in order to allow "import alib" in the installed scripts and "datadir" to allow access to the installed data files (like images). This solution feels a bit clumsy because I need the file names "ascript_src.py" and "ascript.py" to deferenciate the original and the substituted files. I think I need an equivalent in python of the "config.h" header file, but where to install it? Or is there a standard way to achieve the substitutions? Thanks!