comparison setup.py @ 41916:260305e8ddbd

setup: configure py2exe config via environment variables The Inno Setup and WiX installers ship a different set of packages with py2exe builds. And there are multiple WiX installer variants (e.g. TortoiseHG). Since there are multiple variants of py2exe configs and they can be defined by entities not in our repository, let's provide a mechanism for setup.py to supplement behavior via environment variables. This is slighly less hacky than a setup.cfg file IMO since the caller doesn't need to worry about mutating global state of the source directory. Differential Revision: https://phab.mercurial-scm.org/D6092
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 07 Mar 2019 12:15:32 -0800
parents 7a1433e90482
children ac32e04e887f
comparison
equal deleted inserted replaced
41915:a2e191a937a9 41916:260305e8ddbd
1249 'mercurial.cext', 1249 'mercurial.cext',
1250 #'mercurial.cffi', 1250 #'mercurial.cffi',
1251 'mercurial.pure', 1251 'mercurial.pure',
1252 ] 1252 ]
1253 1253
1254 py2exeexcludes = []
1255 py2exedllexcludes = []
1256
1254 if issetuptools: 1257 if issetuptools:
1255 extra['python_requires'] = supportedpy 1258 extra['python_requires'] = supportedpy
1256 1259
1257 if py2exeloaded: 1260 if py2exeloaded:
1258 extra['console'] = [ 1261 extra['console'] = [
1262 # sub command of 'build' because 'py2exe' does not handle sub_commands 1265 # sub command of 'build' because 'py2exe' does not handle sub_commands
1263 build.sub_commands.insert(0, ('build_hgextindex', None)) 1266 build.sub_commands.insert(0, ('build_hgextindex', None))
1264 # put dlls in sub directory so that they won't pollute PATH 1267 # put dlls in sub directory so that they won't pollute PATH
1265 extra['zipfile'] = 'lib/library.zip' 1268 extra['zipfile'] = 'lib/library.zip'
1266 1269
1267 try: 1270 # We allow some configuration to be supplemented via environment
1268 import dulwich 1271 # variables. This is better than setup.cfg files because it allows
1269 dulwich.__version__ 1272 # supplementing configs instead of replacing them.
1270 py2exepackages.append('dulwich') 1273 extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES')
1271 except ImportError: 1274 if extrapackages:
1272 pass 1275 py2exepackages.extend(extrapackages.split(' '))
1273 1276
1274 try: 1277 excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES')
1275 import keyring 1278 if excludes:
1276 keyring.util 1279 py2exeexcludes.extend(excludes.split(' '))
1277 py2exepackages.append('keyring') 1280
1278 except ImportError: 1281 dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES')
1279 pass 1282 if dllexcludes:
1280 1283 py2exedllexcludes.extend(dllexcludes.split(' '))
1281 try:
1282 import pygments
1283 pygments.__version__
1284 py2exepackages.append('pygments')
1285 except ImportError:
1286 pass
1287
1288 try:
1289 import win32ctypes
1290 win32ctypes.__version__
1291 py2exepackages.append('win32ctypes')
1292 except ImportError:
1293 pass
1294 1284
1295 if os.name == 'nt': 1285 if os.name == 'nt':
1296 # Windows binary file versions for exe/dll files must have the 1286 # Windows binary file versions for exe/dll files must have the
1297 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 1287 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535
1298 setupversion = setupversion.split(r'+', 1)[0] 1288 setupversion = setupversion.split(r'+', 1)[0]
1369 package_data=packagedata, 1359 package_data=packagedata,
1370 cmdclass=cmdclass, 1360 cmdclass=cmdclass,
1371 distclass=hgdist, 1361 distclass=hgdist,
1372 options={ 1362 options={
1373 'py2exe': { 1363 'py2exe': {
1364 'dll_excludes': py2exedllexcludes,
1365 'excludes': py2exeexcludes,
1374 'packages': py2exepackages, 1366 'packages': py2exepackages,
1375 }, 1367 },
1376 'bdist_mpkg': { 1368 'bdist_mpkg': {
1377 'zipdist': False, 1369 'zipdist': False,
1378 'license': 'COPYING', 1370 'license': 'COPYING',