Show More
@@ -136,6 +136,18 b' from distutils.errors import (' | |||
|
136 | 136 | from distutils.sysconfig import get_python_inc, get_config_var |
|
137 | 137 | from distutils.version import StrictVersion |
|
138 | 138 | |
|
139 | def write_if_changed(path, content): | |
|
140 | """Write content to a file iff the content hasn't changed.""" | |
|
141 | if os.path.exists(path): | |
|
142 | with open(path, 'rb') as fh: | |
|
143 | current = fh.read() | |
|
144 | else: | |
|
145 | current = b'' | |
|
146 | ||
|
147 | if current != content: | |
|
148 | with open(path, 'wb') as fh: | |
|
149 | fh.write(content) | |
|
150 | ||
|
139 | 151 | scripts = ['hg'] |
|
140 | 152 | if os.name == 'nt': |
|
141 | 153 | # We remove hg.bat if we are able to build hg.exe. |
@@ -317,9 +329,14 b" elif os.path.exists('.hg_archival.txt'):" | |||
|
317 | 329 | version = kw.get('node', '')[:12] |
|
318 | 330 | |
|
319 | 331 | if version: |
|
320 | with open("mercurial/__version__.py", "w") as f: | |
|
321 | f.write('# this file is autogenerated by setup.py\n') | |
|
322 | f.write('version = "%s"\n' % version) | |
|
332 | versionb = version | |
|
333 | if not isinstance(versionb, bytes): | |
|
334 | versionb = versionb.encode('ascii') | |
|
335 | ||
|
336 | write_if_changed('mercurial/__version__.py', b''.join([ | |
|
337 | b'# this file is autogenerated by setup.py\n' | |
|
338 | b'version = "%s"\n' % versionb, | |
|
339 | ])) | |
|
323 | 340 | |
|
324 | 341 | try: |
|
325 | 342 | oldpolicy = os.environ.get('HGMODULEPOLICY', None) |
@@ -478,9 +495,13 b' class hgbuildpy(build_py):' | |||
|
478 | 495 | modulepolicy = 'allow' |
|
479 | 496 | else: |
|
480 | 497 | modulepolicy = 'c' |
|
481 | with open(os.path.join(basepath, '__modulepolicy__.py'), "w") as f: | |
|
482 | f.write('# this file is autogenerated by setup.py\n') | |
|
483 | f.write('modulepolicy = b"%s"\n' % modulepolicy) | |
|
498 | ||
|
499 | content = b''.join([ | |
|
500 | b'# this file is autogenerated by setup.py\n', | |
|
501 | b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'), | |
|
502 | ]) | |
|
503 | write_if_changed(os.path.join(basepath, '__modulepolicy__.py'), | |
|
504 | content) | |
|
484 | 505 | |
|
485 | 506 | build_py.run(self) |
|
486 | 507 |
General Comments 0
You need to be logged in to leave comments.
Login now