This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Show package path in repr string for packages installed to user site
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: loewis, srid
Priority: normal Keywords:

Created on 2010-05-24 21:00 by srid, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg106391 - (view) Author: Sridhar Ratnakumar (srid) Date: 2010-05-24 21:00
I see this in Python 2.7. No idea if this is a regression, mere future request, but doesn't it make sense to print the value `__path__` in the repr string?

>>> import paste
>>> paste
<module 'paste' (built-in)>
>>> paste.__path__
['/home/sridharr/.local/lib/python2.7/site-packages/paste']

It does for stdlib packages/modules:

>>> import xml
>>> xml
<module 'xml' from '/opt/ActivePython-2.7/lib/python2.7/xml/__init__.pyc'>

Happens on Windows, Linux and Mac using Python 2.7 hg hash eaeebf8cda33.0.
msg106399 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-05-24 21:44
You are mistaken. It doesn't include __path__ into repr, but __file__. It prints "(built-in)" if the filename is not set for some reason.
msg106400 - (view) Author: Sridhar Ratnakumar (srid) Date: 2010-05-24 21:48
On 2010-05-24, at 2:44 PM, Martin v. Löwis wrote:

> You are mistaken. It doesn't include __path__ into repr, but __file__. It prints "(built-in)" if the filename is not set for some reason.

Ok. Why is __file__ not set for modules/packages installed to user site (~/.local/), but not stdlib? Is this a bug?

Ah, I see that a "__init__.py" is missing in these packages.   Strange; gotta see how that happened in first place ..  (even stranger that I can actually import these directories...)
msg106405 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-05-24 22:46
Can you please provide a reproducible bug report? I have no idea what "paste" is or how it got into your .local folder. Please structure the bug report as follows:

1. this is what you did
2. this is what happened
3. this is what you expected to happen instead

Installing http://pypi.python.org/pypi/Paste through distribute's setup.py install --user, I get

py> paste
<module 'paste' from '/home/martin/.local/lib/python/2.7/site-packages/Paste-1.7.3.1-py2.7.egg/paste/__init__.pyc'>
msg106406 - (view) Author: Sridhar Ratnakumar (srid) Date: 2010-05-24 23:01
On 2010-05-24, at 3:46 PM, Martin v. Löwis wrote:

> Can you please provide a reproducible bug report? I have no idea what "paste" is or how it got into your .local folder. Please structure the bug report as follows:
> 
> 1. this is what you did
> 2. this is what happened
> 3. this is what you expected to happen instead

I was not sure if this is a bug .. which is why I was waiting till the completion of my investigation ...

> 
> Installing http://pypi.python.org/pypi/Paste through distribute's setup.py install --user, I get
> 
> py> paste
> <module 'paste' from '/home/martin/.local/lib/python/2.7/site-packages/Paste-1.7.3.1-py2.7.egg/paste/__init__.pyc'>

This is what I found: setuptools/Distribute does some namespace magic to make these namespace packages work in the absence of __init__.py. You should be able to reproduce this with --root option (or --single-version-multi-installed or some such thing) in "setup.py install" command to prevent .egg'fying the installed packages. So this is not a bug in Python; it is an expected behaviour of setuptools-installed packages that do not use .egg/ package structure.
History
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 53058
2010-05-24 23:02:40sridsetstatus: open -> closed
2010-05-24 23:01:46sridsetmessages: + msg106406
2010-05-24 22:46:40loewissetmessages: + msg106405
2010-05-24 21:48:34sridsetstatus: pending -> open

messages: + msg106400
2010-05-24 21:44:53loewissetstatus: open -> pending

nosy: + loewis
messages: + msg106399

resolution: not a bug
2010-05-24 21:00:28sridcreate