jparise / python-reloader

Dependency-based Python Module Reloader
http://www.indelible.org/ink/python-reloading/
MIT License
135 stars 27 forks source link

pygame compatibility changes (but should be applicable to everyone) #7

Closed jasharpe closed 11 years ago

jasharpe commented 12 years ago

Made a couple of changes to support the use of this with pygame.

The first fixes what I think is a bug, by returning the result of _baseimport rather than the module that we pull out of sys.modules. This helps fix a problem in the __init__.py for pygame.

The second deals with the fact that certain modules, such as pygame, cannot be reloaded (and crash if this is attempted). It adds a parameter to enable(), ignore_existing_dependencies. If this parameter is True, then any modules imported before enable() is called will be ignored for the purposes of dependency calculation. Thus you can do something like:

import pygame import reloader reloader.enable(ignore_existing_dependencies=True) ...

and you're safe.

The second change also adds a missing "global" to disable().

jparise commented 12 years ago

I'm curious why some pygame modules cannot be reloaded. Is this simply a bug with pygame, and you need a workaround to allow the reloader to be used with the rest of your project?

If the latter, I'd prefer an explicit module blacklist. If a module's name appeared in the blacklist, the reloader would simply skip it. We could go as far to to support some amount of pattern matching so that sets of related modules could be easily excluded.

jparise commented 11 years ago

Closing this now that we have blacklist functionality.