ICU-20479 don’t leave junk in source directory on configure or make check

- see also ICU-20062
- add a `-B` option to the two python invocations on Windows
- set PYTHONDONTWRITEBYTECODE in configure.ac and icudefs.mk.in

Co-authored-by: Fredrik Roubert <roubert@google.com>
diff --git a/icu4c/source/configure b/icu4c/source/configure
index 7d704b0..f36fe0a 100755
--- a/icu4c/source/configure
+++ b/icu4c/source/configure
@@ -2603,6 +2603,10 @@
 
 
 
+# Instruct Python to never write any byte code to the ICU source tree.
+PYTHONDONTWRITEBYTECODE=1
+export PYTHONDONTWRITEBYTECODE
+
 
 
 
diff --git a/icu4c/source/configure.ac b/icu4c/source/configure.ac
index 6c4cb06..c8aef74 100644
--- a/icu4c/source/configure.ac
+++ b/icu4c/source/configure.ac
@@ -16,6 +16,10 @@
         [International Components for Unicode],
         [http://icu-project.org])
 
+# Instruct Python to never write any byte code to the ICU source tree.
+PYTHONDONTWRITEBYTECODE=1
+export PYTHONDONTWRITEBYTECODE
+
 AC_CONFIG_MACRO_DIR([config/m4])
 AC_CONFIG_SRCDIR([common/unicode/utypes.h])
 
diff --git a/icu4c/source/data/makedata.mak b/icu4c/source/data/makedata.mak
index 9991d06..1f42124 100644
--- a/icu4c/source/data/makedata.mak
+++ b/icu4c/source/data/makedata.mak
@@ -233,7 +233,7 @@
 
 $(COREDATA_TS):
 	@cd "$(ICUSRCDATA)"
-	py -3 -m buildtool \
+	py -3 -B -m buildtool \
 		--mode windows-exec \
 		--src_dir "$(ICUSRCDATA)" \
 		--tool_dir "$(ICUTOOLS)" \
diff --git a/icu4c/source/icudefs.mk.in b/icu4c/source/icudefs.mk.in
index 9abb872..59d8205 100644
--- a/icu4c/source/icudefs.mk.in
+++ b/icu4c/source/icudefs.mk.in
@@ -17,6 +17,9 @@
 
 SHELL = @SHELL@
 
+# Instruct Python to never write any byte code to the ICU source tree.
+export PYTHONDONTWRITEBYTECODE = 1
+
 # Standard directories
 
 prefix = @prefix@
diff --git a/icu4c/source/test/testdata/testdata.mak b/icu4c/source/test/testdata/testdata.mak
index a74ba08..879af99 100644
--- a/icu4c/source/test/testdata/testdata.mak
+++ b/icu4c/source/test/testdata/testdata.mak
@@ -35,7 +35,7 @@
 "$(TESTDATAOUT)\testdata.dat" :
 	@echo Building test data
 	set PYTHONPATH=$(ICUSRCDATA);%PYTHONPATH%
-	py -3 -m buildtool \
+	py -3 -B -m buildtool \
 		--mode windows-exec \
 		--tool_dir "$(ICUTOOLS)" \
 		--tool_cfg "$(CFG)" \