Permalink
Browse files

include_server python(3) ready

  • Loading branch information...
1 parent 50e5b66 commit 7dfb29db81c7a07bfaefd148258c6a897e8bac1b @paranormal paranormal committed Apr 14, 2016
View
@@ -29,6 +29,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@ ${DIR_DEFS} \
-Isrc -I"$(srcdir)/src" -I"$(srcdir)/lzo" $(POPT_INCLUDES)
+PYTHON = @PYTHON@
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
builddir = @builddir@
@@ -72,14 +74,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
-# We use python for two tasks in distcc: running the unittests, and
-# running the include-server. The latter requires python 2.4 or
-# higher, while the former only requires python 2.2. So it's possible
-# a particular machine will be able to run one but not the other.
-# Thus we have two variables.
-TEST_PYTHON = @TEST_PYTHON@
-INCLUDESERVER_PYTHON = @INCLUDESERVER_PYTHON@
-
# RESTRICTED_PATH is a colon separated list of directory names. It
# contains the locations of 'make', 'sh', 'gcc', and 'python' for use
# in installation tests. This path is used to avoid confusion caused
@@ -578,15 +572,16 @@ distccmon-gnome@EXEEXT@: $(mon_obj) $(gnome_obj)
# the distcc version, the source location, the CPP flags (for location of the
# includes), and the build location.
include-server:
- if test -z "$(INCLUDESERVER_PYTHON)"; then \
+ if test -z "$(PYTHON)"; then \
+ echo "$(PYTHON)" \
echo "Not building $@: No suitable python found"; \
else \
mkdir -p "$(include_server_builddir)" && \
DISTCC_VERSION="$(VERSION)" \
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
build \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)"; \
@@ -711,17 +706,17 @@ TESTDISTCC_OPTS =
# satisfied w/o actually building an include server (or rather the C extension);
# this logic needs to be verified or amended.
maintainer-check-no-set-path:
- @if ! $(TEST_PYTHON) -c 'import sys; print sys.version'; then \
+ @if ! $(PYTHON) -c 'import sys; print(sys.version)'; then \
echo "WARNING: python not found; tests skipped"; \
else \
- if ! gcc --version 2>/dev/null; then \
- echo "Could not find gcc on the restricted path used to avoid"; \
+ if ! $(CC) --version 2>/dev/null; then \
+ echo "Could not find CC on the restricted path used to avoid"; \
echo "confusion caused by distcc masquerades on the normal path."; \
echo "PATH is currently '$$PATH'."; \
echo "Please change RESTRICTED_PATH to change this PATH value."; \
exit 1; \
fi; \
- $(TEST_PYTHON) "$(srcdir)/test/testdistcc.py" $(TESTDISTCC_OPTS); \
+ $(PYTHON) "$(srcdir)/test/testdistcc.py" $(TESTDISTCC_OPTS); \
fi
distcc-maintainer-check: check_programs
@@ -744,8 +739,8 @@ include-server-maintainer-check: include-server
for p in $(check_include_server_PY); do \
p_base=`basename "$$p"`; \
echo "Running:" \
- "PYTHONPATH=$$CURDIR/$$include_server_loc:$$PYTHONPATH $(INCLUDESERVER_PYTHON) $$p_base"; \
- if PYTHONPATH="$$CURDIR/$$include_server_loc:$$PYTHONPATH" $(INCLUDESERVER_PYTHON) "$$p_base" \
+ "PYTHONPATH=$$CURDIR/$$include_server_loc:$$PYTHONPATH $(PYTHON) $$p_base"; \
+ if PYTHONPATH="$$CURDIR/$$include_server_loc:$$PYTHONPATH" $(PYTHON) "$$p_base" \
> "$$CURDIR/$(tempdir)/$$p_base.out" 2>&1; then \
echo "PASS"; \
rm "$$CURDIR/$(tempdir)/$$p_base.out"; \
@@ -773,9 +768,9 @@ maintainer-check: distcc-maintainer-check include-server-maintainer-check \
pump-maintainer-check
check:
- @if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ @if test -n "$(PYTHON)"; then \
$(MAKE) maintainer-check; \
- elif test -n "$(TEST_PYTHON)"; then \
+ elif test -n "$(PYTHON)"; then \
echo "WARNING: pump-mode not being tested"; \
$(MAKE) distcc-maintainer-check; \
else \
@@ -798,7 +793,7 @@ valgrind-check:
TESTNAME = NoDetachDaemon_Case # Override this with the desired test.
single-test: check_programs
PATH="`pwd`:$(RESTRICTED_PATH)" \
- $(TEST_PYTHON) "$(srcdir)/test/onetest.py" $(TESTDISTCC_OPTS) $(TESTNAME)
+ $(PYTHON) "$(srcdir)/test/onetest.py" $(TESTDISTCC_OPTS) $(TESTNAME)
# Run a single test in pump-mode.
pump-single-test: pump include-server check_programs
@@ -861,9 +856,9 @@ maintainer-installcheck: verify-binaries-installcheck distcc-installcheck \
pump-installcheck
installcheck:
- @if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ @if test -n "$(PYTHON)"; then \
$(MAKE) maintainer-installcheck; \
- elif test -n "$(TEST_PYTHON)"; then \
+ elif test -n "$(PYTHON)"; then \
echo "WARNING: pump-mode not being tested"; \
$(MAKE) distcc-maintainer-installcheck; \
else \
@@ -913,7 +908,7 @@ benchmark:
@echo "Pass BENCH_ARGS to make to specify which benchmarks to run."
@echo
@sleep 5
- cd bench && $(TEST_PYTHON) benchmark.py $(BENCH_ARGS)
+ cd bench && $(PYTHON) benchmark.py $(BENCH_ARGS)
######################################################################
@@ -943,12 +938,12 @@ clean-lzo:
clean-include-server:
- if test -n "$(INCLUDESERVER_PYTHON)"; then \
+ if test -n "$(PYTHON)"; then \
DISTCC_VERSION="$(VERSION)" \
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
clean \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)"; \
@@ -1062,7 +1057,7 @@ install-programs: $(bin_PROGRAMS)
# line endings), so we need to convert it from DOS text file format to
# Unix text file format (LF line endings); we use sed for that too.
install-include-server: include-server pump
- if test -z "$(INCLUDESERVER_PYTHON)"; then \
+ if test -z "$(PYTHON)"; then \
echo "Not building $@: No suitable python found"; \
else \
mkdir -p "$(include_server_builddir)" && \
@@ -1071,7 +1066,7 @@ install-include-server: include-server pump
SRCDIR="$(srcdir)" \
CFLAGS="$(CFLAGS) $(PYTHON_CFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" \
- $(INCLUDESERVER_PYTHON) "$(srcdir)/include_server/setup.py" \
+ $(PYTHON) "$(srcdir)/include_server/setup.py" \
build \
--build-base="$(include_server_builddir)" \
--build-temp="$(include_server_builddir)" \
View
@@ -239,35 +239,12 @@ CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_PROG_MAKE_SET
AC_PROG_INSTALL
-# We prefer to use the latest Python, but try to find an explicit
-# version to make sure we don't get a really old one.
-#
-# The include server requires python 2.4 or later, but the 'make test'
-# routines only require python 2.2. Thus we have two separate
-# variables. Each variable is the empty string if the python that we
-# haven't isn't recent enough for that use, or the path to a python
-# executable if it is recent enough.
+# We prefer to use the latest Python
#
# NB: Cannot use AC_CONFIG_LIBOBJ_DIR here, because it's not present
# in autoconf 2.53.
-AC_PATH_PROGS(PYTHON, [python2.7 python-2.7 python2.6 python-2.6 python2.5 python-2.5 python2.4 python-2.4 python])
+AM_PATH_PYTHON([3.1],,[:])
AC_ARG_VAR(PYTHON, [Python interpreter])
-# Python 1 doesn't even support -V
-if ! "$PYTHON" -V 2>&1 | grep "^Python" >/dev/null; then
- TEST_PYTHON=""
- INCLUDESERVER_PYTHON=""
-elif "$PYTHON" -V 2>&1 | grep "^Python 2.1" >/dev/null; then
- TEST_PYTHON=""
- INCLUDESERVER_PYTHON=""
-elif "$PYTHON" -V 2>&1 | grep "^Python 2.[[23]]" >/dev/null; then
- TEST_PYTHON="$PYTHON"
- INCLUDESERVER_PYTHON=""
-else
- TEST_PYTHON="$PYTHON"
- INCLUDESERVER_PYTHON="$PYTHON"
-fi
-AC_SUBST(TEST_PYTHON)
-AC_SUBST(INCLUDESERVER_PYTHON)
AC_SUBST(PYTHON_RELATIVE_LIB)
AC_C_INLINE
AC_C_BIGENDIAN
No changes.
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/env python3
#
# Copyright 2007 Google Inc.
#
@@ -56,7 +56,7 @@ class ClientRootKeeper(object):
invariant. Some client roots are padded with '/padding' to satisfy the
invariant.
"""
-
+
# This constant is embedded in names of client root directories.
INCLUDE_SERVER_NAME = 'include_server'
@@ -84,7 +84,7 @@ def Glob(self, pid_expr):
return glob.glob('%s/*.%s-%s-*'
% (self.client_tmp, self.INCLUDE_SERVER_NAME,
pid_expr))
-
+
def ClientRootMakedir(self, generation):
"""Make a new client directory for a generation of compressed files.
@@ -104,7 +104,7 @@ def ClientRootMakedir(self, generation):
+ '/padding' * self.number_missing_levels)
if not os.path.isdir(self.client_root):
os.makedirs(self.client_root)
- except (IOError, OSError), why:
+ except (IOError, OSError) as why:
sys.exit('Could not create client root directory %s: %s' %
(self.client_root, why))
@@ -204,7 +204,7 @@ def CleanOutOthers(self):
# tested on a very large application, where include server time CPU time drops
# from 151s to 118s (best times out of 10 runs). There was no seeming changes to
# memory usage. Trying with 100,000 did not speed up the application further.
-GC_THRESHOLD = 10000
+GC_THRESHOLD = 10000
# FLAGS FOR COMMAND LINE OPTIONS
@@ -287,15 +287,15 @@ def Debug(trigger_pattern, message, *params):
i = 1
for unused_j in range(DEBUG_NUM_BITS):
if i & DEBUG_WARNING & triggered:
- print >> sys.stderr, 'WARNING include server:', message % params
+ print('WARNING include server:', message % params, file=sys.stderr)
if i & DEBUG_TRACE & triggered:
- print >> sys.stderr, 'TRACE:', message % params
+ print('TRACE:', message % params, file=sys.stderr)
elif i & DEBUG_TRACE1 & triggered:
- print >> sys.stderr, 'TRACE1:', message % params
+ print(sys.stderr, 'TRACE1:', message % params, file=sys.stderr)
elif i & DEBUG_TRACE2 & triggered:
- print >> sys.stderr, 'TRACE2:', message % params
+ print('TRACE2:', message % params, file=sys.stderr)
elif i & DEBUG_DATA & triggered:
- print >> sys.stderr, 'DATA:', message % params
+ print('DATA:', message % params, file=sys.stderr)
i *= 2
sys.stderr.flush()
@@ -342,7 +342,7 @@ def __init__(self, message,
% (source_file, line_number, message))
else:
message = """File: '%s': %s""" % (source_file, message)
- # Message, a string, becomes self.args[0]
+ # Message, a string, becomes self.args[0]
Error.__init__(self, message)
@@ -390,8 +390,8 @@ def Cancel(self):
sys.stdout.flush()
signal.alarm(0)
signal.signal(signal.SIGALRM, self.old)
-
-
+
+
class SignalSIGTERM(Error):
pass
@@ -415,7 +415,7 @@ def SafeNormPath(path):
Returns:
a string
-
+
Python's os.path.normpath is an unsafe operation; the result may not point to
the same file as the argument. Instead, this function just removes
initial './'s and a final '/'s if present.
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.4
+#! /usr/bin/env python3
# Copyright 2007 Google Inc.
#
@@ -46,7 +46,7 @@ def test_ClientRootKeeper(self):
os_makedirs = os.makedirs
def Mock_tempfile_mkdtemp(pat, dir):
- self.assert_((pat, dir)
+ self.assertTrue((pat, dir)
in
[('.%s-%s-%d' %
(basics.ClientRootKeeper.INCLUDE_SERVER_NAME,
@@ -56,15 +56,15 @@ def Mock_tempfile_mkdtemp(pat, dir):
[(1,'/to/be'), (2, '/to')]])
return (dir == '/to/be' and '/to/be/xxxxxx'
or dir == '/to' and '/to/xxxxxxx')
-
+
def Mock_os_makedirs(f, *unused_args):
if not f.startswith('/to/'):
- raise Exception, f
-
+ raise Exception(f)
+
tempfile.mkdtemp = Mock_tempfile_mkdtemp
os.makedirs = Mock_os_makedirs
-
+
os.environ['DISTCC_CLIENT_TMP'] = '/to/be'
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(1)
@@ -91,28 +91,28 @@ def test_ClientRootKeeper_Deletions(self):
os.environ['DISTCC_CLIENT_TMP'] = '/tmp'
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(117)
- self.assert_(os.path.isdir(client_root_keeper._client_root_before_padding))
- self.assert_(os.path.isdir(client_root_keeper.client_root))
- self.assert_(client_root_keeper.client_root.endswith('/padding'))
+ self.assertTrue(os.path.isdir(client_root_keeper._client_root_before_padding))
+ self.assertTrue(os.path.isdir(client_root_keeper.client_root))
+ self.assertTrue(client_root_keeper.client_root.endswith('/padding'))
client_root_keeper.ClientRootMakedir(118)
client_root_keeper.CleanOutClientRoots()
# Directories must be gone now!
- self.assert_(not os.path.isdir(
+ self.assertTrue(not os.path.isdir(
client_root_keeper._client_root_before_padding))
# Test with a two-level value of DISTCC_CLIENT_TMP.
try:
os.environ['DISTCC_CLIENT_TMP'] = tempfile.mkdtemp('basics_test',
dir='/tmp')
client_root_keeper = basics.ClientRootKeeper()
client_root_keeper.ClientRootMakedir(117)
- self.assert_(os.path.isdir(
+ self.assertTrue(os.path.isdir(
client_root_keeper._client_root_before_padding))
- self.assert_(os.path.isdir(client_root_keeper.client_root))
+ self.assertTrue(os.path.isdir(client_root_keeper.client_root))
client_root_keeper.ClientRootMakedir(118)
client_root_keeper.CleanOutClientRoots()
- self.assert_(os.path.isdir,
+ self.assertTrue(os.path.isdir,
client_root_keeper._client_root_before_padding)
finally:
os.rmdir(os.environ['DISTCC_CLIENT_TMP'])
-unittest.main()
+unittest.main()
Oops, something went wrong.

0 comments on commit 7dfb29d

Please sign in to comment.