##// END OF EJS Templates
setup: create a module for the modulepolicy...
timeless -
r28430:17b85d73 default
parent child Browse files
Show More
@@ -40,6 +40,7 b' doc/*.[0-9].{x,ht}ml'
40 MANIFEST
40 MANIFEST
41 MANIFEST.in
41 MANIFEST.in
42 patches
42 patches
43 mercurial/__modulepolicy__.py
43 mercurial/__version__.py
44 mercurial/__version__.py
44 mercurial/hgpythonlib.h
45 mercurial/hgpythonlib.h
45 mercurial.egg-info
46 mercurial.egg-info
@@ -63,6 +63,7 b' clean:'
63 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
63 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
64 rm -f $(addprefix mercurial/,$(notdir $(wildcard mercurial/pure/[a-z]*.py)))
64 rm -f $(addprefix mercurial/,$(notdir $(wildcard mercurial/pure/[a-z]*.py)))
65 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
65 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
66 rm -f mercurial/__modulepolicy__.py
66 if test -d .hg; then rm -f mercurial/__version__.py; fi
67 if test -d .hg; then rm -f mercurial/__version__.py; fi
67 rm -rf build mercurial/locale
68 rm -rf build mercurial/locale
68 $(MAKE) -C doc clean
69 $(MAKE) -C doc clean
@@ -19,11 +19,14 b' import zipimport'
19 # c - require C extensions
19 # c - require C extensions
20 # allow - allow pure Python implementation when C loading fails
20 # allow - allow pure Python implementation when C loading fails
21 # py - only load pure Python modules
21 # py - only load pure Python modules
22 modulepolicy = '@MODULELOADPOLICY@'
22 #
23
24 # By default, require the C extensions for performance reasons.
23 # By default, require the C extensions for performance reasons.
25 if modulepolicy == '@' 'MODULELOADPOLICY' '@':
24 modulepolicy = 'c'
26 modulepolicy = 'c'
25 try:
26 from . import __modulepolicy__
27 modulepolicy = __modulepolicy__.modulepolicy
28 except ImportError:
29 pass
27
30
28 # PyPy doesn't load C extensions.
31 # PyPy doesn't load C extensions.
29 #
32 #
@@ -314,21 +314,16 b' class hgbuildpy(build_py):'
314 raise SystemExit('Python headers are required to build '
314 raise SystemExit('Python headers are required to build '
315 'Mercurial but weren\'t found in %s' % h)
315 'Mercurial but weren\'t found in %s' % h)
316
316
317 def copy_file(self, *args, **kwargs):
317 def run(self):
318 dst, copied = build_py.copy_file(self, *args, **kwargs)
318 if self.distribution.pure:
319 modulepolicy = 'py'
320 else:
321 modulepolicy = 'c'
322 with open("mercurial/__modulepolicy__.py", "w") as f:
323 f.write('# this file is autogenerated by setup.py\n')
324 f.write('modulepolicy = "%s"\n' % modulepolicy)
319
325
320 if copied and dst.endswith('__init__.py'):
326 build_py.run(self)
321 if self.distribution.pure:
322 modulepolicy = 'py'
323 else:
324 modulepolicy = 'c'
325 content = open(dst, 'rb').read()
326 content = content.replace(b'@MODULELOADPOLICY@',
327 modulepolicy.encode(libdir_escape))
328 with open(dst, 'wb') as fh:
329 fh.write(content)
330
331 return dst, copied
332
327
333 class buildhgextindex(Command):
328 class buildhgextindex(Command):
334 description = 'generate prebuilt index of hgext (for frozen package)'
329 description = 'generate prebuilt index of hgext (for frozen package)'
General Comments 0
You need to be logged in to leave comments. Login now