0

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:

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.

wierob
  • 4,299
  • 1
  • 26
  • 27
  • Also adding the path directly to the pth-file or adding the path to an existing pth-file of another package does not work. – wierob Jul 21 '09 at 16:34

2 Answers2

1

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.

wierob
  • 4,299
  • 1
  • 26
  • 27
0

According to documentation you should put paths to .pth file so maybe entering:

C:\Users\wierob\lib\python2.6

will work

Łukasz
  • 35,061
  • 4
  • 33
  • 33
  • Doesn't work for me. Also the documentation states "Lines starting with import (followed by space or tab) are executed." -- So executing Python code in pth-files should work. – wierob Jul 21 '09 at 16:31