Explorar o código

Warn when we can't find the cache directory on Windows

Closes gh-109
Thomas Kluyver %!s(int64=8) %!d(string=hai) anos
pai
achega
5e2b4ce2d9
Modificáronse 2 ficheiros con 8 adicións e 0 borrados
  1. 1 0
      doc/releasenotes.rst
  2. 7 0
      nsist/util.py

+ 1 - 0
doc/releasenotes.rst

@@ -14,6 +14,7 @@ Version 1.10
   added to the 64-bit view of the registry.
   added to the 64-bit view of the registry.
 * Fixed an error when using wheels which install files into the same package,
 * Fixed an error when using wheels which install files into the same package,
   such as ``PyQt5`` and ``PyQtChart``.
   such as ``PyQt5`` and ``PyQtChart``.
+* Issue a warning when we can't find the cache directory on Windows.
 
 
 Version 1.9
 Version 1.9
 -----------
 -----------

+ 7 - 0
nsist/util.py

@@ -1,9 +1,12 @@
 import os
 import os
 import errno
 import errno
+import logging
 from pathlib import Path
 from pathlib import Path
 import requests
 import requests
 import sys
 import sys
 
 
+logger = logging.getLogger(__name__)
+
 PY3 = sys.version_info[0] >= 3
 PY3 = sys.version_info[0] >= 3
 
 
 if PY3:
 if PY3:
@@ -43,6 +46,10 @@ def get_cache_dir(ensure_existence=False):
     else:
     else:
         # Windows (hopefully)
         # Windows (hopefully)
         local = os.environ.get('LOCALAPPDATA', None) or (os.path.expanduser('~\\AppData\\Local'))
         local = os.environ.get('LOCALAPPDATA', None) or (os.path.expanduser('~\\AppData\\Local'))
+        if local.startswith('~'):
+            logger.warning("Could not find cache directory. Please set any of "
+                           "these environment variables: "
+                           "LOCALAPPDATA, HOME, USERPROFILE or HOMEPATH")
         p = Path(local, 'pynsist')
         p = Path(local, 'pynsist')
 
 
     if ensure_existence:
     if ensure_existence: