Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Merge branch 'python' for release 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwhite committed Aug 2, 2014
2 parents 315e7a8 + 10682b9 commit 38857cf
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions swc-windows-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
import zipfile


__version__ = '0.1'

LOG = logging.getLogger('swc-windows-installer')
LOG.addHandler(logging.StreamHandler())
LOG.setLevel(logging.ERROR)
LOG.setLevel(logging.INFO)


if sys.version_info >= (3, 0): # Python 3
Expand Down Expand Up @@ -197,15 +199,19 @@ def create_nosetests_entry_point(python_scripts_directory):
def get_r_bin_directory():
"""Locate the R bin directory (if R is installed
"""
pf = os.environ.get('ProgramFiles', r'c:\ProgramFiles')
bin_glob = os.path.join(pf, 'R', 'R-[0-9]*.[0-9]*.[0-9]*', 'bin')
version_re = re.compile('^R-(\d+)[.](\d+)[.](\d+)$')
paths = {}
for path in glob.glob(bin_glob):
version_dir = os.path.basename(os.path.dirname(path))
version_match = version_re.match(version_dir)
if version_match:
paths[version_match.groups()] = path
for pf in [
os.environ.get('ProgramW6432', r'c:\Program Files'),
os.environ.get('ProgramFiles', r'c:\Program Files'),
os.environ.get('ProgramFiles(x86)', r'c:\Program Files(x86)'),
]:
bin_glob = os.path.join(pf, 'R', 'R-[0-9]*.[0-9]*.[0-9]*', 'bin')
for path in glob.glob(bin_glob):
version_dir = os.path.basename(os.path.dirname(path))
version_match = version_re.match(version_dir)
if version_match and version_match.groups() not in paths:
paths[version_match.groups()] = path
if not paths:
LOG.info('no R installation found under {}'.format(pf))
return
Expand Down Expand Up @@ -274,8 +280,13 @@ def main():
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'-v', '--verbose', choices=['info', 'debug'],
help='Verbosity')
'-v', '--verbose',
choices=['critical', 'error', 'warning', 'info', 'debug'],
help='Verbosity (defaults to {!r})'.format(
logging.getLevelName(LOG.level).lower()))
parser.add_argument(
'--version', action='version',
version='%(prog)s {}'.format(__version__))

args = parser.parse_args()

Expand All @@ -284,5 +295,6 @@ def main():
LOG.setLevel(level)

LOG.info('Preparing your Software Carpentry awesomeness!')
LOG.info('installer version {}'.format(__version__))
main()
LOG.info('Installation complete.')

0 comments on commit 38857cf

Please sign in to comment.