```PS C:\Users\John Sirois\dev\pantsbuild\jsirois-...
# random
e
Copy code
PS C:\Users\John Sirois\dev\pantsbuild\jsirois-pex> rm -Recurse 'C:\Users\John Sirois\.pex\'
PS C:\Users\John Sirois\dev\pantsbuild\jsirois-pex> py -V
Python 3.10.6
PS C:\Users\John Sirois\dev\pantsbuild\jsirois-pex> py -mpex . -cpex -o'pex.pyz'
PS C:\Users\John Sirois\dev\pantsbuild\jsirois-pex> .\pex cowsay -ccowsay -o'cowsay.pyz' --pip-version 22.2.2
PS C:\Users\John Sirois\dev\pantsbuild\jsirois-pex> .\cowsay Moo!
  ____
| Moo! |
  ====
    \
     \
       ^__^
       (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||
🐮 6
4
🪟 1
w
very cool!
b
CC @late-crowd-50237
e
The path in question exists:
Copy code
pid 19072 -> C:\Users\John Sirois\.pex\venvs\35b8ad2b75870fe545c3564572a6aa4f17b301b0\2be107bd32db9a78b7a68a623864e2d7ac41f196\Scripts\python.exe -sE C:\Users\John Sirois\.pex\venvs\35b8ad2b75870fe545c3564572a6aa4f17b301b0\2be107bd32db9a78b7a68a623864e2d7ac41f196\pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -vvv --cache-dir C:\Users\John Sirois\.pex\pip_cache install --no-deps --no-index --only-binary :all: --no-warn-script-location --force-reinstall --ignore-installed --ignore-requires-python --prefix C:\Users\John Sirois\.pex\installed_wheels\fee837e2d4aeb720f000ab429ca5f0e4190904caa3aab8ae23bf76a13d404309\project_has_python_full_version_marker-0.1.0-py2.py3-none-any.whl.318b3feeaada46b9952304e8cc543937 --no-compile c:\Users\John Sirois\.pex\downloads\resolver_download.uc4e2m\.users.john sirois.dev.pantsbuild.jsirois-pex..tox.py27-integration.scripts.python.exe\project_has_python_full_version_marker-0.1.0-py2.py3-none-any.whl exited with 1 and STDERR:
ERROR: Could not install packages due to an EnvironmentError.
Traceback (most recent call last):
  File "C:\Users\John Sirois\.pex\venvs\35b8ad2b75870fe545c3564572a6aa4f17b301b0\2be107bd32db9a78b7a68a623864e2d7ac41f196\lib\site-packages\pip\_internal\commands\install.py", line 404, in run
...
  File "C:\Users\John Sirois\.pex\venvs\35b8ad2b75870fe545c3564572a6aa4f17b301b0\2be107bd32db9a78b7a68a623864e2d7ac41f196\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
WindowsError: [Error 3] The system cannot find the path specified: u'C:\\Users\\John Sirois\\.pex\\installed_wheels\\fee837e2d4aeb720f000ab429ca5f0e4190904caa3aab8ae23bf76a13d404309\\project_has_python_full_version_marker-0.1.0-py2.py3-none-any.whl.318b3feeaada46b9952304e8cc543937\\Lib\\site-packages\\project_has_python_full_version_marker'
Debug, debug...:
Copy code
diff --git a/pex/pip/tool.py b/pex/pip/tool.py
index f5e4755..94b2327 100644
--- a/pex/pip/tool.py
+++ b/pex/pip/tool.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function

 import os
 import re
+import shutil
 import subprocess
 import sys
 from collections import deque
@@ -620,6 +621,7 @@ class Pip(object):
                     "platform.".format(wheel, interpreter)
                 )

+        tmp_install = safe_mkdtemp()
         install_cmd = [
             "install",
             "--no-deps",
@@ -642,7 +644,7 @@ class Pip(object):
             # install below).
             "--ignore-requires-python",
             "--prefix",
-            install_dir,
+            tmp_install,
         ]

         # The `--prefix` scheme causes Pip to refuse to install foreign wheels. It assumes those
@@ -665,11 +667,12 @@ class Pip(object):
             if returncode != 0:
                 return
             record = Record.from_prefix_install(
-                prefix_dir=install_dir,
+                prefix_dir=tmp_install,
                 project_name=project_name_and_version.project_name,
                 version=project_name_and_version.version,
             )
             record.fixup_install(interpreter=interpreter)
+            shutil.move(tmp_install, install_dir)

         return self._spawn_pip_isolated_job(
             args=install_cmd,
Ok...:
Copy code
...
[Error 206] The filename or extension is too long: 'C:\\\\Users
...
Python, not Perl:
Copy code
diff --git a/pex/pip/tool.py b/pex/pip/tool.py
index 94b2327..897d819 100644
--- a/pex/pip/tool.py
+++ b/pex/pip/tool.py
@@ -672,7 +672,7 @@ class Pip(object):
                 version=project_name_and_version.version,
             )
             record.fixup_install(interpreter=interpreter)
-            shutil.move(tmp_install, install_dir)
+            shutil.move(tmp_install, "\\\\?\\" + install_dir)

         return self._spawn_pip_isolated_job(
             args=install_cmd,
And there is your Windows trivia for the day: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces
Copy code
tests/integration/test_issue_1597.py::test_platform_complete PASSED