swc-windows-installer.py: Rework install paths to use ~/.swc
authorW. Trevor King <wking@tremily.us>
Mon, 21 Oct 2013 16:41:49 +0000 (09:41 -0700)
committerW. Trevor King <wking@tremily.us>
Mon, 21 Oct 2013 17:17:51 +0000 (10:17 -0700)
Instead of cluttering the user's home directory with multiple
SWC-installed directories, reduce clutter and improve namespacing by
dumping everything inside ~/.swc.  Think of it as a SWC-specific
~/.local.  We avoid actually using ~/.local because users might
already be using that for other purposes.

Use os.makedirs to create the nano install directory if it does not
already exist, because ZipFile.extract uses os.mkdir internally, and
mkdir will not recursively create directories.

setup/swc-windows-installer.py

index 88d5c75fbbee20fd511efa8e7f9ac6136163baae..401659774fe81301a94bf183cff3cfe8dbd43428 100755 (executable)
@@ -23,7 +23,7 @@ try:  # Python 3
     from io import BytesIO as _BytesIO
 except ImportError:  # Python 2
     from StringIO import StringIO as _BytesIO
-import os.path
+import os
 try:  # Python 3
     from urllib.request import urlopen as _urlopen
 except ImportError:  # Python 2
@@ -39,6 +39,7 @@ def install_nano(install_directory):
     nano_zip = zipfile.ZipFile(nano_zip_content)
     nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll',
                   'cygiconv-2.dll', 'cyggcc_s-1.dll']
+    os.makedirs(install_directory)
     for file_name in nano_files:
         nano_zip.extract(file_name, install_directory)
 
@@ -69,11 +70,10 @@ def make_posix_path(windows_path):
 
 
 def main():
-    home_dir = os.path.expanduser('~')
-    nano_dir = os.path.join(home_dir, '.nano')
-    bin_dir = os.path.join(home_dir, '.swc-bin')
+    swc_dir = os.path.join(os.path.expanduser('~'), '.swc')
+    nano_dir = os.path.join(swc_dir, 'lib', 'nano')
     install_nano(installation_directory=nano_dir)
-    update_bash_profile(extra_paths=(bin_dir, nano_dir))
+    update_bash_profile(extra_paths=(nano_dir,))
 
 
 if __name__ == '__main__':