Mercurial > p > roundup > code
changeset 6438:b671ed2b49b2
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 19 Jun 2021 14:22:36 -0400 |
| parents | e6d0e86181d5 |
| children | 5296d27ac97c |
| files | setup.py |
| diffstat | 1 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Mon Jun 14 21:46:10 2021 -0400 +++ b/setup.py Sat Jun 19 14:22:36 2021 -0400 @@ -27,6 +27,8 @@ from setuptools import setup +from sysconfig import get_path + import sys, os from glob import glob @@ -49,6 +51,52 @@ script = module.replace('_', '-') return '%s = roundup.scripts.%s:run' % (script, module) +def make_data_files_absolute(data_files, prefix): + """Using setuptools data files are put under the egg install directory + if the datafiles are relative paths. We don't want this. Data files + like man pages, documentation, templates etc. should be installed + in a directory outside of the install directory. So we prefix + all datafiles making them absolute so man pages end up in places + like: /usr/local/share/man, docs in /usr/local/share/doc/roundup, + templates in /usr/local/share/roundup/templates. + """ + new_data_files = [ (os.path.join(prefix,df[0]),df[1]) + for df in data_files ] + + return new_data_files + +def get_prefix(): + """Get site specific prefix using --prefix, platform lib or + sys.prefix. + """ + prefix_arg=False + prefix="" + for a in sys.argv: + if prefix_arg: + prefix=a + break + # is there a short form -p or something for this?? + if a.startswith('--prefix'): + if a == '--prefix': + # next argument is prefix + prefix_arg=True + continue + else: + # strip '--prefix=' + prefix=a[9:] + if prefix: + return prefix + else: + # get the platform lib path. + plp = get_path('platlib') + # nuke suffix that matches lib/* and return prefix + head, tail = os.path.split(plp) + while tail != 'lib' and head != '': + head, tail = os.path.split(head) + if not head: + head = sys.prefix + return head + def main(): # template munching @@ -93,6 +141,8 @@ data_files.append(include('share/doc/roundup/html/_sources', '*')) data_files.append(include('share/doc/roundup/html/_static', '*')) + data_files = make_data_files_absolute(data_files, get_prefix()) + # perform the setup action from roundup import __version__
