[Distutils] [Python-Dev] PEP 365 (Adding the pkg_resources module)

Jim Fulton jim at zope.com
Wed Mar 19 20:58:58 CET 2008


On Mar 19, 2008, at 3:52 PM, Marius Gedminas wrote:

> On Wed, Mar 19, 2008 at 03:37:59PM -0400, Jim Fulton wrote:
>> On Mar 18, 2008, at 2:51 PM, Marius Gedminas wrote:
>> ...
>>> os.path.join(os.path.dirname(__file__), 'foo') just has too many
>>> problems.
>>
>> Could you be specific?
>
> I suppose I was thinking about the stale .pyc file problem, mostly.
>
>
> zc.buildout/setuptools/distutils (I'm not sure which part of the stack
> is to blame) likes to compile modules in a temporary directory and  
> then
> move the .py and .pyc files to their final location.  As a result,
> __file__ points to the now-nonexistent directory.

You are mistaken.  The file information in the code object is wrong,  
which is wildly annoying when looking at traceback or using pdb, but   
__file__ is correct.

BTW, I'm pretty sure the bad code file information is my fault.  I  
definitely plan to fix this.

> Aside: I never understood the reason for storing the value of __file__
> in the .pyc/.pyo file itself.  Why not set it to the correct value on
> import time?

Agreed.  But this has no impact on resource loading.

Jim

--
Jim Fulton
Zope Corporation




More information about the Distutils-SIG mailing list