mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-29 06:30:17 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
fb05b491e7
@ -156,6 +156,18 @@ def _broken_module_imports(requirements):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _yesno(*args):
|
||||||
|
"""Wrapper to only prompt if interactive
|
||||||
|
"""
|
||||||
|
return sys.stdout.isatty() and yesno(*args)
|
||||||
|
|
||||||
|
|
||||||
|
def _eprint(errmsg):
|
||||||
|
"""Wrapper to print to stderr
|
||||||
|
"""
|
||||||
|
print(errmsg, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
# Make sure our python is new enough
|
# Make sure our python is new enough
|
||||||
#
|
#
|
||||||
# Supported version information
|
# Supported version information
|
||||||
@ -177,7 +189,7 @@ def _broken_module_imports(requirements):
|
|||||||
# void: 3.9
|
# void: 3.9
|
||||||
|
|
||||||
if sys.version_info[0] != 3 or sys.version_info[1] < 7:
|
if sys.version_info[0] != 3 or sys.version_info[1] < 7:
|
||||||
print('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
|
_eprint('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
|
||||||
exit(127)
|
exit(127)
|
||||||
|
|
||||||
milc_version = __VERSION__.split('.')
|
milc_version = __VERSION__.split('.')
|
||||||
@ -185,7 +197,7 @@ milc_version = __VERSION__.split('.')
|
|||||||
if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
|
if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
|
||||||
requirements = Path('requirements.txt').resolve()
|
requirements = Path('requirements.txt').resolve()
|
||||||
|
|
||||||
print(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
|
_eprint(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
|
||||||
exit(127)
|
exit(127)
|
||||||
|
|
||||||
# Make sure we can run binaries in the same directory as our Python interpreter
|
# Make sure we can run binaries in the same directory as our Python interpreter
|
||||||
@ -195,7 +207,7 @@ if python_dir not in os.environ['PATH'].split(':'):
|
|||||||
os.environ['PATH'] = ":".join((python_dir, os.environ['PATH']))
|
os.environ['PATH'] = ":".join((python_dir, os.environ['PATH']))
|
||||||
|
|
||||||
# Check to make sure we have all our dependencies
|
# Check to make sure we have all our dependencies
|
||||||
msg_install = f'Please run `{sys.executable} -m pip install -r %s` to install required python dependencies.'
|
msg_install = f'\nPlease run `{sys.executable} -m pip install -r %s` to install required python dependencies.'
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
while args and args[0][0] == '-':
|
while args and args[0][0] == '-':
|
||||||
del args[0]
|
del args[0]
|
||||||
@ -204,24 +216,20 @@ safe_command = args and args[0] in safe_commands
|
|||||||
|
|
||||||
if not safe_command:
|
if not safe_command:
|
||||||
if _broken_module_imports('requirements.txt'):
|
if _broken_module_imports('requirements.txt'):
|
||||||
if yesno('Would you like to install the required Python modules?'):
|
if _yesno('Would you like to install the required Python modules?'):
|
||||||
_install_deps('requirements.txt')
|
_install_deps('requirements.txt')
|
||||||
else:
|
else:
|
||||||
print()
|
_eprint(msg_install % (str(Path('requirements.txt').resolve()),))
|
||||||
print(msg_install % (str(Path('requirements.txt').resolve()),))
|
|
||||||
print()
|
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if cli.config.user.developer and _broken_module_imports('requirements-dev.txt'):
|
if cli.config.user.developer and _broken_module_imports('requirements-dev.txt'):
|
||||||
if yesno('Would you like to install the required developer Python modules?'):
|
if _yesno('Would you like to install the required developer Python modules?'):
|
||||||
_install_deps('requirements-dev.txt')
|
_install_deps('requirements-dev.txt')
|
||||||
elif yesno('Would you like to disable developer mode?'):
|
elif _yesno('Would you like to disable developer mode?'):
|
||||||
_run_cmd(sys.argv[0], 'config', 'user.developer=None')
|
_run_cmd(sys.argv[0], 'config', 'user.developer=None')
|
||||||
else:
|
else:
|
||||||
print()
|
_eprint(msg_install % (str(Path('requirements-dev.txt').resolve()),))
|
||||||
print(msg_install % (str(Path('requirements-dev.txt').resolve()),))
|
_eprint('You can also turn off developer mode: qmk config user.developer=None')
|
||||||
print('You can also turn off developer mode: qmk config user.developer=None')
|
|
||||||
print()
|
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Import our subcommands
|
# Import our subcommands
|
||||||
@ -231,6 +239,6 @@ for subcommand in subcommands:
|
|||||||
|
|
||||||
except (ImportError, ModuleNotFoundError) as e:
|
except (ImportError, ModuleNotFoundError) as e:
|
||||||
if safe_command:
|
if safe_command:
|
||||||
print(f'Warning: Could not import {subcommand}: {e.__class__.__name__}, {e}')
|
_eprint(f'Warning: Could not import {subcommand}: {e.__class__.__name__}, {e}')
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user