[PATCH 2 of 3] modulepolicy: create a module for the modulepolicy
Yuya Nishihara
yuya at tcha.org
Thu Mar 10 09:52:50 EST 2016
On Wed, 09 Mar 2016 10:19:10 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1457538421 0
> # Wed Mar 09 15:47:01 2016 +0000
> # Node ID 71cb80801ec4e3b6aa519da48b4601c3c7a41615
> # Parent f9363da1d708516fbf365d41c9075018b2ce020c
> modulepolicy: create a module for the modulepolicy
>
> Instead of rewriting __init__ to define the modulepolicy,
> write out a __modulepolicy__.py file like __version__.py
Dropped the previous version and pushed this series, thanks!
> --- a/Makefile
> +++ b/Makefile
> @@ -63,7 +63,7 @@
> \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
> rm -f $(addprefix mercurial/,$(notdir $(wildcard mercurial/pure/[a-z]*.py)))
> rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
> - if test -d .hg; then rm -f mercurial/__version__.py; fi
> + if test -d .hg; then rm -f mercurial/__modulepolicy__.py mercurial/__version__.py; fi
Moved mercurial/__modulepolicy__.py out of "if test -d .hg". __modulepolicy__
can be generated without .hg tree.
> --- a/setup.py
> +++ b/setup.py
> @@ -334,28 +334,17 @@
> build_py.finalize_options(self)
>
> if self.distribution.pure:
> + modulepolicy = 'py'
> self.distribution.ext_modules = []
> else:
> + modulepolicy = 'c'
> h = os.path.join(get_python_inc(), 'Python.h')
> if not os.path.exists(h):
> raise SystemExit('Python headers are required to build '
> 'Mercurial but weren\'t found in %s' % h)
> -
> - def copy_file(self, *args, **kwargs):
> - dst, copied = build_py.copy_file(self, *args, **kwargs)
> -
> - if copied and dst.endswith('__init__.py'):
> - if self.distribution.pure:
> - modulepolicy = 'py'
> - else:
> - modulepolicy = 'c'
> - content = open(dst, 'rb').read()
> - content = content.replace(b'@MODULELOADPOLICY@',
> - modulepolicy.encode(libdir_escape))
> - with open(dst, 'wb') as fh:
> - fh.write(content)
> -
> - return dst, copied
> + with open("mercurial/__modulepolicy__.py", "w") as f:
> + f.write('# this file is autogenerated by setup.py\n')
> + f.write('modulepolicy = "%s"\n' % modulepolicy)
Doing it in finalize_options() seems wrong. I've changed it to wrap run().
More information about the Mercurial-devel
mailing list