~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# NOTE: This is a generated file.  The original is in
# buildout-templates/_pythonpath.py.in

# This file works if the Python has been started with -S, or if bin/py
# has been used.

# Auto-generated code to handle relative paths
${python-relative-path-setup}

import os
import sys
import warnings

# XXX: 2010-04-26, Salgado, bug=570246: Silence python2.6 deprecation
# warnings.
warnings.filterwarnings(
    'ignore', '.*(md5|sha|sets)', DeprecationWarning,
    )

site_dir = ${scripts:parts-directory|path-repr}

if ('site' in sys.modules and
    not sys.modules['site'].__file__.startswith(
        os.path.join(site_dir, 'site.py'))):
    # We have the wrong site.py, so our paths are not set up correctly.
    # We blow up, with a hopefully helpful error message.
    raise RuntimeError(
        'The wrong site.py is imported (%r imported, %r expected). '
        'Scripts should usually be '
        "started with Launchpad's bin/py, or with a Python invoked with "
        'the -S flag.' % (
        sys.modules['site'].__file__, os.path.join(site_dir, 'site.py')))

if site_dir not in sys.path:
    sys.path.insert(0, site_dir)
elif 'site' not in sys.modules:
    # XXX 2010-05-04 gary bug 575206
    # This one line is to support Mailman 2, which does something unexpected
    # to set up its paths.
    sys.path[:] = [p for p in sys.path if 'site-packages' not in p]
import site # sets up paths