##// END OF EJS Templates
setup: configure py2exe config via environment variables...
Gregory Szorc -
r42082:260305e8 default
parent child Browse files
Show More
@@ -20,6 +20,14 b' from .util import ('
20 20 )
21 21
22 22
23 EXTRA_PACKAGES = {
24 'dulwich',
25 'keyring',
26 'pygments',
27 'win32ctypes',
28 }
29
30
23 31 def build(source_dir: pathlib.Path, build_dir: pathlib.Path,
24 32 python_exe: pathlib.Path, iscc_exe: pathlib.Path,
25 33 version=None):
@@ -40,7 +48,7 b' def build(source_dir: pathlib.Path, buil'
40 48 'inno' / 'requirements.txt')
41 49
42 50 build_py2exe(source_dir, build_dir, python_exe, 'inno',
43 requirements_txt)
51 requirements_txt, extra_packages=EXTRA_PACKAGES)
44 52
45 53 # hg.exe depends on VC9 runtime DLLs. Copy those into place.
46 54 for f in find_vc_runtime_files(vc_x64):
@@ -23,7 +23,9 b' from .util import ('
23 23
24 24 def build_py2exe(source_dir: pathlib.Path, build_dir: pathlib.Path,
25 25 python_exe: pathlib.Path, build_name: str,
26 venv_requirements_txt: pathlib.Path):
26 venv_requirements_txt: pathlib.Path,
27 extra_packages=None, extra_excludes=None,
28 extra_dll_excludes=None):
27 29 """Build Mercurial with py2exe.
28 30
29 31 Build files will be placed in ``build_dir``.
@@ -103,6 +105,14 b' def build_py2exe(source_dir: pathlib.Pat'
103 105 env['DISTUTILS_USE_SDK'] = '1'
104 106 env['MSSdk'] = '1'
105 107
108 if extra_packages:
109 env['HG_PY2EXE_EXTRA_PACKAGES'] = ' '.join(sorted(extra_packages))
110 if extra_excludes:
111 env['HG_PY2EXE_EXTRA_EXCLUDES'] = ' '.join(sorted(extra_excludes))
112 if extra_dll_excludes:
113 env['HG_PY2EXE_EXTRA_DLL_EXCLUDES'] = ' '.join(
114 sorted(extra_dll_excludes))
115
106 116 py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe'
107 117 if not py2exe_py_path.exists():
108 118 print('building py2exe')
@@ -1251,6 +1251,9 b' py2exepackages = ['
1251 1251 'mercurial.pure',
1252 1252 ]
1253 1253
1254 py2exeexcludes = []
1255 py2exedllexcludes = []
1256
1254 1257 if issetuptools:
1255 1258 extra['python_requires'] = supportedpy
1256 1259
@@ -1264,33 +1267,20 b' if py2exeloaded:'
1264 1267 # put dlls in sub directory so that they won't pollute PATH
1265 1268 extra['zipfile'] = 'lib/library.zip'
1266 1269
1267 try:
1268 import dulwich
1269 dulwich.__version__
1270 py2exepackages.append('dulwich')
1271 except ImportError:
1272 pass
1273
1274 try:
1275 import keyring
1276 keyring.util
1277 py2exepackages.append('keyring')
1278 except ImportError:
1279 pass
1270 # We allow some configuration to be supplemented via environment
1271 # variables. This is better than setup.cfg files because it allows
1272 # supplementing configs instead of replacing them.
1273 extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES')
1274 if extrapackages:
1275 py2exepackages.extend(extrapackages.split(' '))
1280 1276
1281 try:
1282 import pygments
1283 pygments.__version__
1284 py2exepackages.append('pygments')
1285 except ImportError:
1286 pass
1277 excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES')
1278 if excludes:
1279 py2exeexcludes.extend(excludes.split(' '))
1287 1280
1288 try:
1289 import win32ctypes
1290 win32ctypes.__version__
1291 py2exepackages.append('win32ctypes')
1292 except ImportError:
1293 pass
1281 dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES')
1282 if dllexcludes:
1283 py2exedllexcludes.extend(dllexcludes.split(' '))
1294 1284
1295 1285 if os.name == 'nt':
1296 1286 # Windows binary file versions for exe/dll files must have the
@@ -1371,6 +1361,8 b" setup(name='mercurial',"
1371 1361 distclass=hgdist,
1372 1362 options={
1373 1363 'py2exe': {
1364 'dll_excludes': py2exedllexcludes,
1365 'excludes': py2exeexcludes,
1374 1366 'packages': py2exepackages,
1375 1367 },
1376 1368 'bdist_mpkg': {
General Comments 0
You need to be logged in to leave comments. Login now