Expand Windows environment setup

- Write required environment variables to a batch file.
- Fix virtualenv bin path.
- Temporarily disable host_build and cargo steps on Windows.
- Update the python runner to work on Windows.
- Remove script_exectuable from the .gn file as it was added before
  Pigweed had an env_setup and was used to point to the correct system
  Python.

Change-Id: Ie4d0d0c5deb752c79ee5059dd812175775eae10c
diff --git a/.gitignore b/.gitignore
index 30aeb32..b9b2f70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,5 +43,6 @@
 
 # Env Setup
 env_setup/.setup.sh
+env_setup/.env_setup.bat
 .cipd
 .cargo
diff --git a/.gn b/.gn
index de099cc..60ce6bd 100644
--- a/.gn
+++ b/.gn
@@ -1,4 +1,4 @@
-# Copyright 2019 The Pigweed Authors
+# Copyright 2020 The Pigweed Authors
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
 # use this file except in compliance with the License. You may obtain a copy of
@@ -13,4 +13,3 @@
 # the License.
 
 buildconfig = "//BUILDCONFIG.gn"
-script_executable = "python3"
diff --git a/env_setup/env_setup.bat b/env_setup/env_setup.bat
index f8cb603..d53a74b 100644
--- a/env_setup/env_setup.bat
+++ b/env_setup/env_setup.bat
@@ -19,4 +19,10 @@
 :: exports it as an environment variable.
 for /F "usebackq tokens=1" %%i in (`powershell %%~dp0..\..\env_setup\env_setup.ps1`) do set PW_ROOT=%%i
 
-call python %PW_ROOT%\env_setup\env_setup.py --pw-root %PW_ROOT% --shell-file "%PW_ROOT%\env_setup\.env_setup.bat"
+set shell_file="%PW_ROOT%\env_setup\.env_setup.bat"
+
+if not exist %shell_file% (
+  call python %PW_ROOT%\env_setup\env_setup.py --pw-root %PW_ROOT% --shell-file %shell_file%
+)
+
+call %shell_file%
diff --git a/env_setup/env_setup.py b/env_setup/env_setup.py
index 707daca..aba8d37 100755
--- a/env_setup/env_setup.py
+++ b/env_setup/env_setup.py
@@ -194,10 +194,14 @@
         steps = [
             ('cipd', self.cipd),
             ('python', self.virtualenv),
-            ('host_tools', self.host_build),
-            ('cargo', self.cargo),
         ]
 
+        if os.name != 'nt':
+            # TODO(pwbug/97): Fix the boostrap host build in Windows.
+            steps.append(('host_tools', self.host_build))
+            # TODO(pwbug/63): Add a Windows version of cargo to CIPD.
+            steps.append(('cargo', self.cargo))
+
         for name, step in steps:
             print('Setting up {}...\n'.format(name), file=sys.stdout)
             step()
diff --git a/env_setup/virtualenv/init.py b/env_setup/virtualenv/init.py
index d3a84c5..ab6328e 100644
--- a/env_setup/virtualenv/init.py
+++ b/env_setup/virtualenv/init.py
@@ -148,7 +148,7 @@
 
     if env:
         env.set('VIRTUAL_ENV', venv_path)
-        env.prepend('PATH', os.path.join(venv_path, 'bin'))
+        env.prepend('PATH', os.path.join(venv_path, venv_bin))
         env.clear('PYTHONHOME')
 
 
diff --git a/pw_build/py/python_runner.py b/pw_build/py/python_runner.py
index f804688..0621fd7 100755
--- a/pw_build/py/python_runner.py
+++ b/pw_build/py/python_runner.py
@@ -129,6 +129,9 @@
     command = [sys.executable] + resolved_command
     _LOG.debug('RUN %s', shlex.join(command))
 
+    if os.name == 'nt':
+        command = ['call', '/c'] + command
+
     if args.capture_output:
         completed_process = subprocess.run(
             command,