[Import-SIG] New PEP draft: "Simplified Package Layout and Partitioning"

Barry Warsaw barry at python.org
Mon Jul 18 18:17:26 CEST 2011


I finally had a chance to read this.  TL;DR: +1.

I have a few quibbles about typos and grammar, but let's ignore that for now.
I have two questions of substance at this point.

1. Sometimes, packages can have non-importable data directories,
   e.g. foo/test/data.  Where foo.test would be an importable subpackage,
   foo.test.data should not be.  Today we can just omit the __init__.py from
   foo/test/data.  Under the proposed regime there would IIUC, be no way to
   prevent foo.test.data from being a subpackage.  It's entirely possible that
   foo/test/data would have .py files in it which would themselves be
   importable.  Is this a bad thing?  If so, do we need some mechanism to
   prevent recursion into some subdirectories?

2. The __file__ issue.  My gut tells me that pure virtual modules should have
   None as their __file__.  It seems wrong to use anything else, and your
   "accidentally work" observation is not calming. ;)

   The inability to use __file__ to find data files is somewhat troubling
   though.  Let's say we want to find the foo/test/data subdir above, and
   `foo` is pure-virtual, while `test` is an __init__.py-less package.

   I'm fine not being able to use foo.__file__, but I will probably want to
   use `os.path.join(foo.test.__file__, 'data')`.  Will that work?  What would
   foo.test's __file__ be?  The `foo/test` directory perhaps?  Of course there
   could be multiple `foo/test` directories, so this is probably why your
   suggesting to search foo.test.__path__ instead.

   I'd actually be okay with that, *if* pkg_resources will be updated to
   handle this case.  In general, we've been recommending people use
   pkg_resources anyway (wasn't there a push to move part of this package into
   the stdlib?).

I'll read up on the rest of the thread now, but I think the PEP holds up well
and makes a convincing argument.  I think it's certainly worthy of posting to
python-dev to see if anybody else can shoot holes in it, or come up with
useful solutions to open questions.  I'll be very interested to see Guido's
reaction to it. :)

Thanks for taking this on PJE.
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/import-sig/attachments/20110718/914767d9/attachment.pgp>


More information about the Import-SIG mailing list