Пример #1
0
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'))
Пример #2
0
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'))
Пример #3
0
        ansi.foreground(ansi.YELLOW, 'Python ' + env.PYTHON_VERSION),
        ansi.foreground(ansi.YELLOW, 'Lore ' + __version__)
    )


lore_no_env = False
if hasattr(sys, 'lore_no_env'):
    lore_no_env = sys.lore_no_env


no_env_commands = ['--version', 'install', 'init', 'server']
if len(sys.argv) > 1 and os.path.basename(sys.argv[0]) in ['lore', 'lore.exe'] and sys.argv[1] in no_env_commands:
    lore_no_env = True

if '--no-env' in sys.argv:
    lore_no_env = True
    
if not lore_no_env:
    # everyone else gets validated and launched on import
    env.validate()
    env.launch()

if env.launched():
    print(banner())
    logger.info(banner())
    logger.debug('python environment: %s' % env.PREFIX)

    if not lore_no_env:
        with timer('check requirements', logging.DEBUG):
            env.check_requirements()