Repository: pypa/pip

Issue:
Invalid "exe is not on PATH" error from pip 10.0.0b2
OS: Windows 7, 64-bit
Python: 3.6.2 (64-bit)
pip: 10.0.0b2

I got a warning that I was not installing to a location on `PATH`:

```
>pip install --force-reinstall wheel
Collecting wheel
  Using cached wheel-0.31.0-py2.py3-none-any.whl
Installing collected packages: wheel
  Found existing installation: wheel 0.31.0
    Uninstalling wheel-0.31.0:
      Successfully uninstalled wheel-0.31.0
  The script wheel.exe is installed in 'c:\users\uk03306\appdata\local\programs\python\python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.                                                                         
```

However, `C:\Users\UK03306\AppData\Local\Programs\Python\Python36\Scripts` *is* on `PATH`:

```
>$env:PATH -split ';'
C:\Program Files\ConEmu\ConEmu\Scripts
C:\Program Files\ConEmu
C:\Program Files\ConEmu\ConEmu
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\ProgramData\Oracle\Java\javapath
C:\Utils\Gnuwin64
C:\Utils\Vim
C:\Utils\Misc
C:\Utils\SysInternals
C:\Program Files\TortoiseHg\
C:\Oracle\XE\app\oracle\product\11.2.0\server\bin
C:\Apps\Vagrant\bin
C:\Apps\Go\bin
C:\ProgramData\chocolatey\bin
C:\Users\UK03306\.dnx\bin
C:\Program Files\Microsoft DNX\Dnvm\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\nodejs\
C:\Users\UK03306\AppData\Local\Programs\Git\cmd
C:\PostgreSQL\pg96\bin
C:\Program Files (x86)\Plantronics\Spokes3G\
C:\Program Files\dotnet\
C:\Users\UK03306\.cargo\bin
C:\Users\UK03306\.local\bin
C:\Users\UK03306\AppData\Local\Programs\Python\Python36\Scripts\
C:\Users\UK03306\AppData\Local\Programs\Python\Python36\
C:\Users\UK03306\AppData\Local\Programs\Git\cmd
C:\Users\UK03306\AppData\Roaming\npm
C:\Program Files\Docker Toolbox
C:\Program Files\Heroku\bin
C:\Program Files\Microsoft VS Code\bin
```

and the wheel command works fine:

```
>wheel version
wheel 0.31.0
```

I know the reported path doesn't match in case with the one on `PATH`, so this may be a case sensitivity issue. But I had a previous run (with the dev version of pip) fail with a reported path that matched the entry in `PATH` with the same case, so the problem may be deeper than that.


Discussion:
I'm gonna say we're missing an os.path.normcase somewhere. I think this is a release blocker, windows only though. I'll look into fixing it tonight or tomorrow morning. 
I agree, it's likely something like that. I was going to take a look over the weekend, so if you don't get time I'll pick it up.

Not sure it's a release blocker - it's only cosmetic. But with luck that isn't a decision I'll need to make :-) So leave it that way for now, I can drop the tag later if needs be.

Resolving patch:
diff --git a/src/pip/_internal/wheel.py b/src/pip/_internal/wheel.py
--- a/src/pip/_internal/wheel.py
+++ b/src/pip/_internal/wheel.py
@@ -163,13 +163,15 @@ def message_about_scripts_not_on_PATH(scripts):
         grouped_by_dir[parent_dir].add(script_name)
 
     # We don't want to warn for directories that are on PATH.
-    not_warn_dirs = os.environ["PATH"].split(os.pathsep)
+    not_warn_dirs = [
+        os.path.normcase(i) for i in os.environ["PATH"].split(os.pathsep)
+    ]
     # If an executable sits with sys.executable, we don't warn for it.
     #     This covers the case of venv invocations without activating the venv.
-    not_warn_dirs.append(os.path.dirname(sys.executable))
+    not_warn_dirs.append(os.path.normcase(os.path.dirname(sys.executable)))
     warn_for = {
         parent_dir: scripts for parent_dir, scripts in grouped_by_dir.items()
-        if parent_dir not in not_warn_dirs
+        if os.path.normcase(parent_dir) not in not_warn_dirs
     }
     if not warn_for:
         return None


Test patch:
diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py
--- a/tests/unit/test_wheel.py
+++ b/tests/unit/test_wheel.py
@@ -453,3 +453,13 @@ def test_single_script__single_dir_on_PATH(self):
             scripts=['/a/b/foo']
         )
         assert retval is None
+
+    def test_PATH_check_case_insensitive_on_windows(self):
+        retval = self._template(
+            paths=['C:\\A\\b'],
+            scripts=['c:\\a\\b\\c', 'C:/A/b/d']
+        )
+        if WINDOWS:
+            assert retval is None
+        else:
+            assert retval is not None