[Edu-sig] PEPTALK: path sanity and newbie mental

Arthur ajs@optonline.net
Sun, 06 Jul 2003 18:30:07 -0500


Jason writes -

>I am humiliated and feel like moron. I am getting stuck
>[again] on my most basic eternal Python newbie issue: >paths and module
import.

I tried to duplicate your nightmare without much success.  Download Jabber,
unzip, untar to C:\jabberpy0.4-0.

run
cmd
cd c:\jabberpy0.4-0
python setup.py install

python
>>Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import jabber
>>> dir(jabber)
['Client', 'Component', 'Connection', 'False', 'Iq', 'JID', 'Log',
'Message', 'NS_AGENT', 'NS_AGENTS', 'NS_AUTH', 'NS_BROWSE', 'NS_CLIENT',
'NS_COMP_ACCEPT', 'NS_COMP_CONNECT', 'NS_DELAY', 'NS_LAST', 'NS_OOB',
'NS_PASS', 'NS_PRIVACY', 'NS_P_COMMANDS', 'NS_P_DISC_INFO',
'NS_P_DISC_ITEMS', 'NS_P_MUC', 'NS_REGISTER', 'NS_ROSTER', 'NS_RPC',
'NS_SERVER', 'NS_TIME', 'NS_VCARD', 'NS_VERSION', 'NS_XDATA',
'NS_XENCRYPTED', 'NS_XEVENT', 'NS_XEXPIRE', 'NS_XROSTER', 'NS_XSIGNED',
'Presence', 'Protocol', 'RS_ASK_SUBSCRIBE', 'RS_ASK_UNSUBSCRIBE',
'RS_EXT_OFFLINE', 'RS_EXT_ONLINE', 'RS_EXT_PENDING', 'RS_SUB_BOTH',
'RS_SUB_FROM', 'RS_SUB_TO', 'Roster', 'Server', 'True', 'USTR_ENCODING',
'VERSION', 'XDB', '_NS_PROTOCOL', '_NS_P_DISCO', '__builtins__', '__doc__',
'__file__', '__name__', 'find', 'replace', 'sha', 'split', 'str', 'time',
'ustr', 'xmlstream']
>>>

Now I do see that jabber setup.py places the jabber.py and xmlstream.py
files directly in site-packages, and yours end up a level down in a
sub-directory called jabber.

You didn't read the instructions on the box, i.e running setup.py - did you?
We have to assume the reading of README, no?

"""Installation
-------------
>From the untared distrubution directory; As root run;
python setup.py install
"""

Did you manually place the jabber files in the sub-directory under
site-packages?

If your did, the fault is not entirely yours, IMO.  That's where you would
expect it to be, and where it should be IMO.

OK its there, somehow.

Instead of futzing with your paths. Create a file with one word "jabber",
and save it in site-packages as jabber.pth. Problem solved.

I think the sin is part yours, part Jabber's.  I hold Python pretty
harmless, except:

One big issue I do see.

I did not run setup.py from IDLE because you need to run it with a parameter
"install".  I can't see an obvious way to do that in IDLE.   If IDLE is to
be one's tool, it *has* to be able to run another Python tool as fundmental
as setup.py, IMO.
Maybe I'm a moron, too - in missing something obvious here.

Or maybe the new IDLE (2.3) will better cater to this issue, or us morons.

As to where to save files, etc and etc.  - you are asking for more structure
than Python chooses to impose on you.  Where you will, is fine. Especially
as Python is truly cross-platofrm, and what would make sense for Windows
probably does not make sense for other platforms.

Art