[python-win32] gencache module and read-only access to python dir

Grzegorz Adam Hankiewicz ghankiewicz at rastertech.es
Mon Jun 18 11:40:55 CEST 2007


Ross McKerchar wrote:
> I've noticed that the GetModuleForTypelib always (or at least once per 
> program-run) calls AddModuleToCache (both in win32com.client.gencache).
> 
> This results in an attempt to write to the pickled dictionary 
> gen_py/dicts.dat. Unfortunately the program I'm writing that uses 
> GetModuleForLib is run by users who dont have write access to the Python 
> directory. I've ensured early binding for the type library I'm 
> interested in by setting it up in the application installer, so from my 
> limited understanding of win32com dicts.dat cache should already contain 
> my module.
> 
> My program appears to run fine as a normal user with a nasty hack 
> ("win32com.client.gencache.AddModuleToCache.func_defaults=(1,False)") 
> that prevents the cache getting written to.
> 
> So, I'd be grateful of anyone with a more solid understanding than me could
> a) Confirm that disabling the dicts.dat cache write will work fine and 
> not break randomly in the future
> b) Let me know if there's a more robust way of preventing the cache 
> write (there appears to be code supporting freezing functionality that 
> should help but I couldn't figure out a neat way of using it)

I think you should read 
http://www.py2exe.org/index.cgi/UsingEnsureDispatch. I happened to have 
the same problem generating the cache of an OCX library. I implemented a 
function which before py2exe'ing my binary would make sure the local 
python cache is completely removed. Also added the wiki code to my own.

-- 
     Rastertech España S.A.
	Grzegorz Adam Hankiewicz
/Jefe de Producto TeraVial/

C/ Perfumería 21. Nave I. Polígono industrial La Mina
28770 Colmenar Viejo. Madrid (España)
Tel. +34 918 467 390 (Ext.17) 	  *·*   	Fax +34 918 457 889
ghankiewicz at rastertech.es 	  *·*   	www.rastertech.es
<http://www.rastertech.es/>



More information about the Python-win32 mailing list