[PATCH 4 of 6 import-refactor V2] setup: refactor handling of modules with C/Python implementations
Yuya Nishihara
yuya at tcha.org
Sun Nov 29 00:02:20 CST 2015
On Tue, 24 Nov 2015 23:31:48 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1448428391 28800
> # Tue Nov 24 21:13:11 2015 -0800
> # Node ID f6f18cd052e20dc517a4bce358e3d633897bc584
> # Parent 0dc3217bc6dd586230a900ea0b1b3f24b9c29e71
> setup: refactor handling of modules with C/Python implementations
> --- a/setup.py
> +++ b/setup.py
> @@ -395,20 +381,33 @@ class hginstalllib(install_lib):
> system has a umask of something like 027, preserving the permissions when
> copying will lead to a broken install.
>
> Note that just passing keep_permissions=False to copy_file would be
> insufficient, as it might still be applying a umask.
> '''
>
> def run(self):
> + if self.distribution.pure:
> + modulepolicy = 'py'
> + else:
> + modulepolicy = 'c'
> +
> realcopyfile = file_util.copy_file
> def copyfileandsetmode(*args, **kwargs):
> src, dst = args[0], args[1]
> dst, copied = realcopyfile(*args, **kwargs)
> +
> + if dst.endswith('__init__.py'):
> + content = open(dst, 'rb').read()
> + content = content.replace(b'@MODULELOADPOLICY@',
> + modulepolicy.encode(libdir_escape))
> + with open(dst, 'wb') as fh:
> + fh.write(content)
Can this be moved to the build_py phase? The install phase could be too late
to modify module sources. py2exe doesn't see this change.
More information about the Mercurial-devel
mailing list