1# -*- python -*-
2
3# Copyright (C) 1998-2018 by the Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License
7# as published by the Free Software Foundation; either version 2
8# of the License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18# USA.
19
20# This file becomes paths.py which is installed in may directories.  By
21# importing this module, sys.path gets `hacked' so that the $prefix/Mailman
22# directory is inserted at the start of that list.  That directory really
23# contains the Mailman modules in package form.  This file exports two
24# attributes that other modules may use to get the absolute path to the
25# installed Mailman distribution.
26
27import os
28import sys
29
30# some scripts expect this attribute to be in this module
31prefix = '@prefix@'
32exec_prefix = '@exec_prefix@'
33
34# work around a bogus autoconf 2.12 bug
35if exec_prefix == '${prefix}':
36    exec_prefix = prefix
37
38# Check if ja/ko codecs are available before changing path.
39try:
40    s = unicode('OK', 'iso-2022-jp')
41    jaok = True
42except LookupError:
43    jaok = False
44
45try:
46    s = unicode('OK', 'euc-kr')
47    kook = True
48except LookupError:
49    kook = False
50
51# Hack the path to include the parent directory of the $prefix/Mailman package
52# directory.
53sys.path.insert(0, prefix)
54
55# We also need the pythonlib directory on the path to pick up any overrides of
56# standard modules and packages.  Note that these must go at the front of the
57# path for this reason.
58sys.path.insert(0, os.path.join(prefix, 'pythonlib'))
59
60# Include Python's site-packages directory.
61sitedir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3],
62                       'site-packages')
63sys.path.append(sitedir)
64
65# Include Python's dist-packages directory.
66distdir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3],
67                       'dist-packages')
68sys.path.append(distdir)
69
70# Some distros may have the python library in a directory other than lib/
71# such as Lib/ or lib64/.  Hopefully they will have hacked
72# site.getsitepackages() to return the right thing.
73try:
74    import site
75    sys.path.extend(site.getsitepackages())
76    del site
77except (ImportError, AttributeError):
78    pass
79
80
81# In a normal interactive Python environment, the japanese.pth and korean.pth
82# files would be imported automatically.  But because we inhibit the importing
83# of the site module, we need to be explicit about importing these codecs.
84if not jaok:
85    import japanese
86# As of KoreanCodecs 2.0.5, you had to do the second import to get the Korean
87# codecs installed, however leave the first import in there in case an upgrade
88# changes this.
89if not kook:
90    import korean
91    import korean.aliases
92# Arabic and Hebrew (RFC-1556) encoding aliases. (temporary solution)
93import encodings.aliases
94encodings.aliases.aliases.update({
95    'iso_8859_6_e': 'iso8859_6',
96    'iso_8859_6_i': 'iso8859_6',
97    'iso_8859_8_e': 'iso8859_8',
98    'iso_8859_8_i': 'iso8859_8',
99})
100