[Idle-dev] About extensions ...

Terry Reedy tjreedy at udel.edu
Sun Dec 8 15:38:01 EST 2019


On 12/8/2019 2:30 PM, André Roberge wrote:

> Is there any way to add an extension to IDLE without putting it "by 
> hand" in the idlelib directory but installing it from pypi.org 
> <http://pypi.org> and using some configuration settings to let IDLE know 
> where to find such an extension?

The editor.EditorWindow.load_extension import code first tries to import 
an extension from idlelib and then from anywhere on sys.path, in 
particular, I presume, site-packages.  (A failure is printed to the 
console.)

     try:
         mod = importlib.import_module('.' + fname, package=__package__)
     except (ImportError, TypeError):
         mod = importlib.import_module(fname)

What is required is the addition of a section to config-extensions.def. 
When pip installs a package, I believe it can run a setup file in the 
package that can do this.  I don't know how, but I would agree to adding 
instructions to those already at the top of that file.  I know that 
IdleX has code to add a section, as well as monkey-patching other 
idlelib files, but I don't know if this is done automatically on 
installation or if users have to separately invoke IdleX setup.



More information about the IDLE-dev mailing list