[IronPython] Handling the import of scripts

Jimmy Schementi Jimmy.Schementi at microsoft.com
Thu Jan 29 19:39:10 CET 2009

I'm not sure of a way directly from IronPython, but if you're hosting IronPython you can define your own PlatformAdaptationLayer, which is used to re-define platformy things like import. Here's some info on how to do that: http://www.mail-archive.com/users@lists.ironpython.com/msg06079.html.

And here's the PlatformAdaptationLayer I use in AgDLR, for looking in a zip file when import is called:


> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Jeff Slutter
> Sent: Thursday, January 29, 2009 10:24 AM
> To: Discussion of IronPython
> Subject: [IronPython] Handling the import of scripts
> If there a way for me to intercept when IronPython wants to import a
> script, so I can provide the script text through my own ways. I have a
> situation where my Python files are not files on the disk, but packed
> into a zip file. When I go to run a script I can get the source to
> IronPython to run, but, if that script imports another script that is
> also in the zip file, I would like to go through my methods of
> resolving
> the file, loading it, and passing it back to IronPython.
> -Jeff
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Ironpython-users mailing list