1. Tarek Ziadé
  2. distribute
Issue #194 new

Creating "missing" __init__.py files is wrong

Fred Drake
created an issue

When installing zope.testrunner using zc.buildout with distribute 0.6.15, I noticed this surprising message in the output:

{{{ Getting distribution for 'zope.testrunner'. package init file 'src/zope/testrunner/testrunner-ex/init.py' not found (or not a regular file) Creating missing init.py for zope.testrunner.testrunner-ex Got zope.testrunner 4.0.3. }}}

This is a wrong thing to do. The fact that there's a hyphen in the supposed package name makes that a little more obvious, and may be why I noticed it this time, but it's wrong for distribute to determine for me that a directory nested inside a package is a package as well, even if it includes .py files.

Python determines that a directory is a package based on the presence of the init.py file; if the developer didn't put one there, he shouldn't expect that directory to be treated as code. In a case like this, the directory most likely contains data, either to be loaded by the code during operation, or during tests. Adding that file during installation means that the directory is likely to be handled differently during development/testing and production use. Though it's unlikely to be a serious practical problem, when it is a problem it will be difficult to diagnose ("expensive").

Comments (4)

  1. Zooko O'Whielacronx

    The Twisted plugin mechanism relies on a directory named "twisted/plugin/" which contains .py files but does not contain a __init__.py file. If you add an __init__.py file to it, this would break the plugin finder mechanism.

  2. Anonymous
  3. Log in to comment