aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-12-13 11:07:42 -0500
committerMatti Picus <matti.picus@gmail.com>2022-12-13 11:07:42 -0500
commit74edfc92b5f3f760b789a953c3051dc7f1f54472 (patch)
treeb9c27a7a5703fb28ef6773a245c2e4ba353a3e83 /rpython
parenttry to make the test work on 32bit (diff)
downloadpypy-74edfc92b5f3f760b789a953c3051dc7f1f54472.tar.gz
pypy-74edfc92b5f3f760b789a953c3051dc7f1f54472.tar.bz2
pypy-74edfc92b5f3f760b789a953c3051dc7f1f54472.zip
slightly improve version detection with git, for bettern udir creation
Diffstat (limited to 'rpython')
-rw-r--r--rpython/tool/ansi_mandelbrot.py11
-rw-r--r--rpython/tool/version.py16
2 files changed, 19 insertions, 8 deletions
diff --git a/rpython/tool/ansi_mandelbrot.py b/rpython/tool/ansi_mandelbrot.py
index ad4d747804..064d8881af 100644
--- a/rpython/tool/ansi_mandelbrot.py
+++ b/rpython/tool/ansi_mandelbrot.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import sys
from py.io import ansi_print, get_terminal_width
@@ -120,7 +121,7 @@ class Driver(object):
def restart(self):
""" Restarts the current generator. """
- print >>sys.stderr
+ print('', file=sys.stderr)
self.init()
def dot(self):
@@ -134,7 +135,7 @@ class Driver(object):
self.init()
except StopIteration:
if DEBUG and self.interesting_coordinates:
- print >>sys.stderr, "Interesting coordinates:", self.interesting_coordinates
+ print("Interesting coordinates:", self.interesting_coordinates, file=sys.stderr)
self.interesting_coordinates = []
kwargs = self.kwargs
self.zoom_location += 1
@@ -144,7 +145,7 @@ class Driver(object):
self.max_colour = loc[3]
if DEBUG:
# Only used for debugging new locations:
- print "Colour range", self.colour_range
+ print("Colour range", self.colour_range)
self.colour_range = None
self.restart()
return
@@ -152,7 +153,7 @@ class Driver(object):
self.interesting_coordinates.append(dict(x=(x, self.mandelbrot.x_range[x]),
y=(y, self.mandelbrot.y_range[y])))
if x == self.width - 1:
- print >>sys.stderr
+ print('', file=sys.stderr)
def print_pixel(self, colour, invert=1):
chars = [".", ".", "+", "*", "%", "#"]
@@ -183,4 +184,4 @@ if __name__ == '__main__':
if 0 and random.random() < 0.01:
string = "WARNING! " * 3
d.jump(len(string))
- print string,
+ print(string, end='')
diff --git a/rpython/tool/version.py b/rpython/tool/version.py
index f13d26fc9a..c8850d67ee 100644
--- a/rpython/tool/version.py
+++ b/rpython/tool/version.py
@@ -33,8 +33,16 @@ def get_repo_version_info(hgexe=None, root=rpythonroot):
def _get_repo_version_info(hgexe, root):
# Try to see if we can get info from Git if hgexe is not specified.
if not hgexe:
- if os.path.isdir(os.path.join(root, '.git')):
+ gitfile = os.path.join(root, '.git')
+ if os.path.isdir(gitfile):
return _get_git_version(root)
+ elif os.path.exists(gitfile):
+ # Can be a file with a relative path like
+ # gitdir: ../.git/modules/pypy
+ with open(gitfile) as fid:
+ contents = fid.read()
+ if contents.startswith('gitdir:'):
+ return _get_git_version(root)
# Fallback to trying Mercurial.
if hgexe is None:
@@ -129,13 +137,15 @@ def _get_git_version(root):
)
if p.wait() != 0:
maywarn(p.stderr.read(), 'Git')
- return '?', revision_id
+ return 'pypy-HEAD', revision_id
branch = '?'
for line in p.stdout.read().strip().split('\n'):
if line.startswith('* '):
branch = line[1:].strip()
if branch == '(no branch)':
- branch = '?'
+ branch = 'pypy-HEAD'
+ if branch.startswith("(HEAD detached"):
+ branch = 'pypy-HEAD'
break
return branch, revision_id
return p.stdout.read().strip(), revision_id