def install_python_version(): if env.launched(): return if not env.python_version: env.set_python_version('.'.join(sys.version_info)) print(ansi.warning() + ' %s does not exist. Creating with %s' % (env.version_path, env.python_version)) with open(env.version_path, 'w', encoding='utf-8') as f: f.write(env.python_version + os.linesep) if not env.pyenv: sys.exit(ansi.error() + ' pyenv is not installed. Lore is broken. try:\n' ' $ pip uninstall lore && pip install lore\n') versions = subprocess.check_output( (env.bin_pyenv, 'versions', '--bare')).decode('utf-8').split(os.linesep) if env.python_version not in versions: print(ansi.success('INSTALL') + ' python %s' % env.python_version) if platform.system() == 'Darwin': install_xcode() subprocess.check_call(('git', '-C', env.pyenv, 'pull')) subprocess.check_call((env.bin_pyenv, 'install', env.python_version)) subprocess.check_call((env.bin_pyenv, 'rehash'))
def install_pyenv(): virtualenv = os.path.join(env.PYENV, 'plugins', 'pyenv-virtualenv') if os.path.exists(env.BIN_PYENV) and os.path.exists(virtualenv): return if os.path.exists(env.PYENV) and not os.path.isfile(env.BIN_PYENV): print(ansi.warning() + ' pyenv executable is not present at %s' % env.BIN_PYENV) while True: answer = input( 'Would you like to blow away ~/.pyenv and rebuild from scratch? [Y/n] ' ) if answer in ['', 'y', 'Y']: shutil.rmtree(lore.env.PYENV) break elif answer in ['n', 'N']: sys.exit(ansi.error() + ' please fix pyenv before continuing') else: print('please enter Y or N') if not os.path.exists(env.PYENV): print(ansi.success('INSTALLING') + ' pyenv') subprocess.check_call( ('git', 'clone', 'https://github.com/pyenv/pyenv.git', env.PYENV)) else: print(ansi.success('CHECK') + ' existing pyenv installation') env.set_python_version(env.PYTHON_VERSION) if not os.path.exists(virtualenv): print(ansi.success('INSTALLING') + ' pyenv virtualenv') subprocess.check_call( ('git', 'clone', 'https://github.com/pyenv/pyenv-virtualenv.git', virtualenv)) else: print(ansi.success('CHECK') + ' existing virtualenv installation')
def install_python_version(): if env.launched(): return if not env.PYTHON_VERSION: env.set_python_version('.'.join(sys.version_info)) print(ansi.warning() + ' %s does not exist. Creating with %s' % (env.VERSION_PATH, env.PYTHON_VERSION)) with open(env.VERSION_PATH, 'w', encoding='utf-8') as f: f.write(env.PYTHON_VERSION + os.linesep) if platform.system() == 'Windows': print(ansi.warning() + ' Lore only uses the installed python version on Windows.') else: if not env.PYENV: sys.exit( ansi.error() + ' pyenv is not installed. Lore is broken. try:\n' ' $ pip uninstall lore && pip install lore\n' ) versions = subprocess.check_output( (env.BIN_PYENV, 'versions', '--bare') ).decode('utf-8').split(os.linesep) if env.PYTHON_VERSION not in versions: print(ansi.success('INSTALL') + ' python %s' % env.PYTHON_VERSION) if platform.system() == 'Darwin': install_xcode() subprocess.check_call(('git', '-C', env.PYENV, 'pull')) subprocess.check_call((env.BIN_PYENV, 'install', env.PYTHON_VERSION)) subprocess.check_call((env.BIN_PYENV, 'rehash'))
def install_pyenv(): home = os.environ.get('HOME') if not home: return pyenv = os.path.join(home, '.pyenv') bin_pyenv = os.path.join(pyenv, 'bin', 'pyenv') virtualenv = os.path.join(pyenv, 'plugins', 'pyenv-virtualenv') if os.path.exists(bin_pyenv) and os.path.exists(virtualenv): return if os.path.exists(pyenv) and not os.path.isfile(bin_pyenv): print(ansi.warning() + ' pyenv executable is not present at %s' % bin_pyenv) while True: answer = input('Would you like to blow away ~/.pyenv and rebuild from scratch? [Y/n] ') if answer in ['', 'y', 'Y']: shutil.rmtree(pyenv) break elif answer in ['n', 'N']: sys.exit(ansi.error() + ' please fix pyenv before continuing') else: print('please enter Y or N') if not os.path.exists(pyenv): print(ansi.success('INSTALLING') + ' pyenv') subprocess.check_call(( 'git', 'clone', 'https://github.com/pyenv/pyenv.git', pyenv )) else: print(ansi.success('CHECK') + ' existing pyenv installation') env.pyenv = pyenv env.bin_pyenv = bin_pyenv env.set_python_version(env.python_version) if not os.path.exists(virtualenv): print(ansi.success('INSTALLING') + ' pyenv virtualenv') subprocess.check_call(( 'git', 'clone', 'https://github.com/pyenv/pyenv-virtualenv.git', virtualenv )) else: print(ansi.success('CHECK') + ' existing virtualenv installation')