How to use a custom site-package using pth-files for Python 2.6?
Question: I'm trying to setup a custom site-package directory (Python 2.6 on Windows
Vista). For example the directory should be '~\lib\python2.6' (
C:\Users\wierob\lib\python2.6). Hence calling 'setup.py install' should copy
packages to C:\Users\wierob\lib\python2.6.

Following the instructions
[here](http://peak.telecommunity.com/DevCenter/EasyInstall#administrator-
installation):

I've created a pth-file in site-packages directory of the Python installation
(C:\Python26\Lib\site-packages). This file contains a single line:

    
    
    import os, site; site.addsitedir(os.path.expanduser('~/lib/python2.6'))
    

Additionally I have a pydistutils.cfg my home directory (C:\Users\wierob) that
contains:

    
    
    [install]
    install_lib = ~/lib/python2.6
    install_scripts = ~/bin
    

When I run 'setup.py install' I get the following error message:

    
    
    C:\Users\wierob\Documents\Python\workspace\rsreader>setup.py install
    running install
    Checking .pth file support in C:\Users\wierob\lib\python2.6\
    C:\Python26\pythonw.exe -E -c pass
    TEST FAILED: C:\Users\wierob\lib\python2.6\ does NOT support .pth files
    error: bad install directory or PYTHONPATH
    
    You are attempting to install a package to a directory that is not
    on PYTHONPATH and which Python does not read ".pth" files from.  The
    installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        C:\Users\wierob\lib\python2.6\
    

So it seems that the pth-file does not work. Although, if I enter

    
    
    site.addsitedir(os.path.expanduser('~/lib/python2.6'))
    

in an interactive python session the directory is succesfully added to
sys.path.

Any ideas? Thanks.


Answer: The pth-file seems to be ignored if encoded in UTF-8 with BOM.

Saving the pth-file in ANSI or UTF-8 without BOM works.

