Mercurial > p > roundup > code
comparison setup.py @ 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 | b57c3d50505b |
| children | 5296d27ac97c |
comparison
equal
deleted
inserted
replaced
| 6437:e6d0e86181d5 | 6438:b671ed2b49b2 |
|---|---|
| 24 from roundup.dist.command.build import build, list_message_files | 24 from roundup.dist.command.build import build, list_message_files |
| 25 from roundup.dist.command.bdist_rpm import bdist_rpm | 25 from roundup.dist.command.bdist_rpm import bdist_rpm |
| 26 from roundup.dist.command.install_lib import install_lib | 26 from roundup.dist.command.install_lib import install_lib |
| 27 | 27 |
| 28 from setuptools import setup | 28 from setuptools import setup |
| 29 | |
| 30 from sysconfig import get_path | |
| 29 | 31 |
| 30 import sys, os | 32 import sys, os |
| 31 from glob import glob | 33 from glob import glob |
| 32 | 34 |
| 33 | 35 |
| 46 module files. | 48 module files. |
| 47 """ | 49 """ |
| 48 module = os.path.splitext(os.path.basename(path))[0] | 50 module = os.path.splitext(os.path.basename(path))[0] |
| 49 script = module.replace('_', '-') | 51 script = module.replace('_', '-') |
| 50 return '%s = roundup.scripts.%s:run' % (script, module) | 52 return '%s = roundup.scripts.%s:run' % (script, module) |
| 53 | |
| 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 | |
| 51 | 99 |
| 52 | 100 |
| 53 def main(): | 101 def main(): |
| 54 # template munching | 102 # template munching |
| 55 packages = [ | 103 packages = [ |
| 90 # add docs | 138 # add docs |
| 91 data_files.append(include('share/doc/roundup/html', '*')) | 139 data_files.append(include('share/doc/roundup/html', '*')) |
| 92 data_files.append(include('share/doc/roundup/html/_images', '*')) | 140 data_files.append(include('share/doc/roundup/html/_images', '*')) |
| 93 data_files.append(include('share/doc/roundup/html/_sources', '*')) | 141 data_files.append(include('share/doc/roundup/html/_sources', '*')) |
| 94 data_files.append(include('share/doc/roundup/html/_static', '*')) | 142 data_files.append(include('share/doc/roundup/html/_static', '*')) |
| 143 | |
| 144 data_files = make_data_files_absolute(data_files, get_prefix()) | |
| 95 | 145 |
| 96 # perform the setup action | 146 # perform the setup action |
| 97 from roundup import __version__ | 147 from roundup import __version__ |
| 98 | 148 |
| 99 # long_description may not contain non-ascii characters. Distutils | 149 # long_description may not contain non-ascii characters. Distutils |
