pw_build: Avoid importing pty on Windows

The pw-wrap-ninja command relies on pty for intercepting and parsing
Ninja output. This doesn't work on Windows, so on Windows the script
simply runs Ninja without any wrapper.

As it turns out, the 'pty' module, while existing on Windows, breaks if
you attempt to actually import it. Since this module isn't used in the
script when it runs on Windows anyways, this commit guards its import
behind a platform check.

Change-Id: I73f58911f6e665b6a46d32a3acf600ee29760585
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126941
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Eli Lipsitz <elipsitz@google.com>
diff --git a/pw_build/py/pw_build/wrap_ninja.py b/pw_build/py/pw_build/wrap_ninja.py
index 4233bd7..fd82a35 100644
--- a/pw_build/py/pw_build/wrap_ninja.py
+++ b/pw_build/py/pw_build/wrap_ninja.py
@@ -19,7 +19,6 @@
 import enum
 import json
 import os
-import pty
 import re
 import signal
 import subprocess
@@ -28,6 +27,9 @@
 import time
 from typing import Any, Dict, IO, List, Tuple, Optional
 
+if sys.platform != 'win32':
+    import pty
+
 # The status formatting string for Ninja to use. Includes a sentinel prefix.
 _NINJA_STATUS = '@@!!@@%s,%f,%t>'
 
@@ -241,7 +243,8 @@
         self.lock = threading.Lock()
 
         # Launch ninja and configure pseudo-tty.
-        ptty_parent, ptty_child = pty.openpty()  # pylint: disable=no-member
+        # pylint: disable-next=no-member,undefined-variable
+        ptty_parent, ptty_child = pty.openpty()  # type: ignore
         ptty_file = os.fdopen(ptty_parent, 'r')
         env = dict(os.environ)
         env['NINJA_STATUS'] = _NINJA_STATUS