194 from distutils.command.build import build |
194 from distutils.command.build import build |
195 from distutils.command.build_ext import build_ext |
195 from distutils.command.build_ext import build_ext |
196 from distutils.command.build_py import build_py |
196 from distutils.command.build_py import build_py |
197 from distutils.command.build_scripts import build_scripts |
197 from distutils.command.build_scripts import build_scripts |
198 from distutils.command.install import install |
198 from distutils.command.install import install |
|
199 from distutils.command.install_data import install_data |
199 from distutils.command.install_lib import install_lib |
200 from distutils.command.install_lib import install_lib |
200 from distutils.command.install_scripts import install_scripts |
201 from distutils.command.install_scripts import install_scripts |
201 from distutils import log |
202 from distutils import log |
202 from distutils.spawn import spawn, find_executable |
203 from distutils.spawn import spawn, find_executable |
203 from distutils import file_util |
204 from distutils import file_util |
209 from distutils.sysconfig import get_python_inc, get_config_var |
210 from distutils.sysconfig import get_python_inc, get_config_var |
210 from distutils.version import StrictVersion |
211 from distutils.version import StrictVersion |
211 |
212 |
212 # Explain to distutils.StrictVersion how our release candidates are versionned |
213 # Explain to distutils.StrictVersion how our release candidates are versionned |
213 StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') |
214 StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') |
|
215 |
|
216 # Can we build the documentation? |
|
217 try: |
|
218 import docutils |
|
219 except ImportError: |
|
220 docutils = None |
214 |
221 |
215 |
222 |
216 def write_if_changed(path, content): |
223 def write_if_changed(path, content): |
217 """Write content to a file iff the content hasn't changed.""" |
224 """Write content to a file iff the content hasn't changed.""" |
218 if os.path.exists(path): |
225 if os.path.exists(path): |
469 class hgbuild(build): |
476 class hgbuild(build): |
470 # Insert hgbuildmo first so that files in mercurial/locale/ are found |
477 # Insert hgbuildmo first so that files in mercurial/locale/ are found |
471 # when build_py is run next. |
478 # when build_py is run next. |
472 sub_commands = [('build_mo', None)] + build.sub_commands |
479 sub_commands = [('build_mo', None)] + build.sub_commands |
473 |
480 |
|
481 def run(self): |
|
482 if os.name == 'nt': |
|
483 pass |
|
484 elif docutils is None: |
|
485 log.warn('not building optional documentation') |
|
486 else: |
|
487 self.run_command('build_doc') |
|
488 |
474 |
489 |
475 class hgbuildmo(build): |
490 class hgbuildmo(build): |
476 |
491 |
477 description = "build translations (.mo files)" |
492 description = "build translations (.mo files)" |
478 |
493 |
1038 genman(root) |
1053 genman(root) |
1039 if self.html: |
1054 if self.html: |
1040 genhtml(root) |
1055 genhtml(root) |
1041 |
1056 |
1042 |
1057 |
|
1058 class hginstalldata(install_data): |
|
1059 user_options = install_data.user_options + [ |
|
1060 ( |
|
1061 'install-man=', |
|
1062 None, |
|
1063 'installation directory for manual pages [share/man]', |
|
1064 ), |
|
1065 ] |
|
1066 |
|
1067 install_man = None |
|
1068 |
|
1069 def finalize_options(self): |
|
1070 install_data.finalize_options(self) |
|
1071 |
|
1072 self.set_undefined_options('install', ('install_man', 'install_man')) |
|
1073 |
|
1074 if self.install_man is None: |
|
1075 self.install_man = os.path.join('share', 'man') |
|
1076 |
|
1077 if os.name == 'nt': |
|
1078 pass |
|
1079 elif docutils is None: |
|
1080 log.warn('not installing manual pages') |
|
1081 else: |
|
1082 manpages = [ |
|
1083 f for f in os.listdir('doc') if re.search(r'\.[0-9]$', f) |
|
1084 ] |
|
1085 |
|
1086 self.data_files += [ |
|
1087 ( |
|
1088 os.path.join(self.install_man, 'man' + ext[1:]), |
|
1089 ['doc/' + f for f in manpages if f.endswith(ext)], |
|
1090 ) |
|
1091 for ext in set(os.path.splitext(f)[1] for f in manpages) |
|
1092 ] |
|
1093 |
|
1094 |
1043 class hginstall(install): |
1095 class hginstall(install): |
1044 |
1096 |
1045 user_options = install.user_options + [ |
1097 user_options = install.user_options + [ |
1046 ( |
1098 ( |
1047 'old-and-unmanageable', |
1099 'old-and-unmanageable', |
1051 ( |
1103 ( |
1052 'single-version-externally-managed', |
1104 'single-version-externally-managed', |
1053 None, |
1105 None, |
1054 'noop, present for eggless setuptools compat', |
1106 'noop, present for eggless setuptools compat', |
1055 ), |
1107 ), |
|
1108 ( |
|
1109 'install-man=', |
|
1110 None, |
|
1111 'installation directory for manual pages [share/man]', |
|
1112 ), |
1056 ] |
1113 ] |
1057 |
1114 |
1058 # Also helps setuptools not be sad while we refuse to create eggs. |
1115 # Also helps setuptools not be sad while we refuse to create eggs. |
1059 single_version_externally_managed = True |
1116 single_version_externally_managed = True |
1060 |
1117 |
|
1118 install_man = None |
|
1119 |
1061 def get_sub_commands(self): |
1120 def get_sub_commands(self): |
|
1121 subcommands = install.get_sub_commands(self) |
|
1122 subcommands.append('install_data') |
1062 # Screen out egg related commands to prevent egg generation. But allow |
1123 # Screen out egg related commands to prevent egg generation. But allow |
1063 # mercurial.egg-info generation, since that is part of modern |
1124 # mercurial.egg-info generation, since that is part of modern |
1064 # packaging. |
1125 # packaging. |
1065 excl = {'bdist_egg'} |
1126 excl = {'bdist_egg'} |
1066 return filter(lambda x: x not in excl, install.get_sub_commands(self)) |
1127 return filter(lambda x: x not in excl, subcommands) |
1067 |
1128 |
1068 |
1129 |
1069 class hginstalllib(install_lib): |
1130 class hginstalllib(install_lib): |
1070 """ |
1131 """ |
1071 This is a specialization of install_lib that replaces the copy_file used |
1132 This is a specialization of install_lib that replaces the copy_file used |
1263 'build_py': hgbuildpy, |
1324 'build_py': hgbuildpy, |
1264 'build_scripts': hgbuildscripts, |
1325 'build_scripts': hgbuildscripts, |
1265 'build_hgextindex': buildhgextindex, |
1326 'build_hgextindex': buildhgextindex, |
1266 'install': hginstall, |
1327 'install': hginstall, |
1267 'install_lib': hginstalllib, |
1328 'install_lib': hginstalllib, |
|
1329 'install_data': hginstalldata, |
1268 'install_scripts': hginstallscripts, |
1330 'install_scripts': hginstallscripts, |
1269 'build_hgexe': buildhgexe, |
1331 'build_hgexe': buildhgexe, |
1270 } |
1332 } |
1271 |
1333 |
1272 if py2exehacked: |
1334 if py2exehacked: |