From: W. Trevor King Date: Mon, 21 Oct 2013 16:41:49 +0000 (-0700) Subject: swc-windows-installer.py: Rework install paths to use ~/.swc X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=806fedff21660e67f1a392317aee218233bf71f5;p=swc-workshop.git swc-windows-installer.py: Rework install paths to use ~/.swc 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. --- diff --git a/setup/swc-windows-installer.py b/setup/swc-windows-installer.py index 88d5c75..4016597 100755 --- a/setup/swc-windows-installer.py +++ b/setup/swc-windows-installer.py @@ -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__':