Skip to content

Commit 340fbb8

Browse files
committed
2551143: Problem with installing external trackers ...
the change from distutils to setuptools moved the directories for the templates, man pages and docs under the install directory. The install directory is buried in the directory tree under /usr/ib/python/.../roundup...egg/... This patch tries to put them under: the directory specified by --prefix argument the python platform library prefix that prefixes /lib in sysconfig.getpath('platlib') the directory returned by sys.prefix.
1 parent 429b480 commit 340fbb8

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

setup.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
from setuptools import setup
2929

30+
from sysconfig import get_path
31+
3032
import sys, os
3133
from glob import glob
3234

@@ -49,6 +51,52 @@ def mapscript(path):
4951
script = module.replace('_', '-')
5052
return '%s = roundup.scripts.%s:run' % (script, module)
5153

54+
def make_data_files_absolute(data_files, prefix):
55+
"""Using setuptools data files are put under the egg install directory
56+
if the datafiles are relative paths. We don't want this. Data files
57+
like man pages, documentation, templates etc. should be installed
58+
in a directory outside of the install directory. So we prefix
59+
all datafiles making them absolute so man pages end up in places
60+
like: /usr/local/share/man, docs in /usr/local/share/doc/roundup,
61+
templates in /usr/local/share/roundup/templates.
62+
"""
63+
new_data_files = [ (os.path.join(prefix,df[0]),df[1])
64+
for df in data_files ]
65+
66+
return new_data_files
67+
68+
def get_prefix():
69+
"""Get site specific prefix using --prefix, platform lib or
70+
sys.prefix.
71+
"""
72+
prefix_arg=False
73+
prefix=""
74+
for a in sys.argv:
75+
if prefix_arg:
76+
prefix=a
77+
break
78+
# is there a short form -p or something for this??
79+
if a.startswith('--prefix'):
80+
if a == '--prefix':
81+
# next argument is prefix
82+
prefix_arg=True
83+
continue
84+
else:
85+
# strip '--prefix='
86+
prefix=a[9:]
87+
if prefix:
88+
return prefix
89+
else:
90+
# get the platform lib path.
91+
plp = get_path('platlib')
92+
# nuke suffix that matches lib/* and return prefix
93+
head, tail = os.path.split(plp)
94+
while tail != 'lib' and head != '':
95+
head, tail = os.path.split(head)
96+
if not head:
97+
head = sys.prefix
98+
return head
99+
52100

53101
def main():
54102
# template munching
@@ -93,6 +141,8 @@ def main():
93141
data_files.append(include('share/doc/roundup/html/_sources', '*'))
94142
data_files.append(include('share/doc/roundup/html/_static', '*'))
95143

144+
data_files = make_data_files_absolute(data_files, get_prefix())
145+
96146
# perform the setup action
97147
from roundup import __version__
98148

0 commit comments

Comments
 (0)