Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/setup.py Thu Mar 07 15:43:54 2019 -0800 +++ b/setup.py Thu Mar 07 12:15:32 2019 -0800 @@ -1251,6 +1251,9 @@ 'mercurial.pure', ] +py2exeexcludes = [] +py2exedllexcludes = [] + if issetuptools: extra['python_requires'] = supportedpy @@ -1264,33 +1267,20 @@ # put dlls in sub directory so that they won't pollute PATH extra['zipfile'] = 'lib/library.zip' - try: - import dulwich - dulwich.__version__ - py2exepackages.append('dulwich') - except ImportError: - pass - - try: - import keyring - keyring.util - py2exepackages.append('keyring') - except ImportError: - pass + # We allow some configuration to be supplemented via environment + # variables. This is better than setup.cfg files because it allows + # supplementing configs instead of replacing them. + extrapackages = os.environ.get('HG_PY2EXE_EXTRA_PACKAGES') + if extrapackages: + py2exepackages.extend(extrapackages.split(' ')) - try: - import pygments - pygments.__version__ - py2exepackages.append('pygments') - except ImportError: - pass + excludes = os.environ.get('HG_PY2EXE_EXTRA_EXCLUDES') + if excludes: + py2exeexcludes.extend(excludes.split(' ')) - try: - import win32ctypes - win32ctypes.__version__ - py2exepackages.append('win32ctypes') - except ImportError: - pass + dllexcludes = os.environ.get('HG_PY2EXE_EXTRA_DLL_EXCLUDES') + if dllexcludes: + py2exedllexcludes.extend(dllexcludes.split(' ')) if os.name == 'nt': # Windows binary file versions for exe/dll files must have the @@ -1371,6 +1361,8 @@ distclass=hgdist, options={ 'py2exe': { + 'dll_excludes': py2exedllexcludes, + 'excludes': py2exeexcludes, 'packages': py2exepackages, }, 'bdist_mpkg': {