Merge remote-tracking branch 'upstream/develop' into xap
This commit is contained in:
commit
3c66b9b0ec
7256 changed files with 77233 additions and 46094 deletions
|
@ -35,7 +35,6 @@ subcommands = [
|
|||
'qmk.cli.chibios.confmigrate',
|
||||
'qmk.cli.clean',
|
||||
'qmk.cli.compile',
|
||||
'qmk.cli.console',
|
||||
'qmk.cli.docs',
|
||||
'qmk.cli.doctor',
|
||||
'qmk.cli.fileformat',
|
||||
|
@ -72,6 +71,26 @@ subcommands = [
|
|||
]
|
||||
|
||||
|
||||
def _install_deps(requirements):
|
||||
"""Perform the installation of missing requirements.
|
||||
|
||||
If we detect that we are running in a virtualenv we can't write into we'll use sudo to perform the pip install.
|
||||
"""
|
||||
command = [sys.executable, '-m', 'pip', 'install']
|
||||
|
||||
if sys.prefix != sys.base_prefix:
|
||||
# We are in a virtualenv, check to see if we need to use sudo to write to it
|
||||
if not os.access(sys.prefix, os.W_OK):
|
||||
print('Notice: Using sudo to install modules to location owned by root:', sys.prefix)
|
||||
command.insert(0, 'sudo')
|
||||
|
||||
elif not os.access(sys.prefix, os.W_OK):
|
||||
# We can't write to sys.prefix, attempt to install locally
|
||||
command.append('--local')
|
||||
|
||||
return _run_cmd(*command, '-r', requirements)
|
||||
|
||||
|
||||
def _run_cmd(*command):
|
||||
"""Run a command in a subshell.
|
||||
"""
|
||||
|
@ -164,8 +183,14 @@ if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
|
|||
print(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')
|
||||
exit(127)
|
||||
|
||||
# Make sure we can run binaries in the same directory as our Python interpreter
|
||||
python_dir = os.path.dirname(sys.executable)
|
||||
|
||||
if python_dir not in os.environ['PATH'].split(':'):
|
||||
os.environ['PATH'] = ":".join((python_dir, os.environ['PATH']))
|
||||
|
||||
# Check to make sure we have all our dependencies
|
||||
msg_install = 'Please run `python3 -m pip install -r %s` to install required python dependencies.'
|
||||
msg_install = f'Please run `{sys.executable} -m pip install -r %s` to install required python dependencies.'
|
||||
args = sys.argv[1:]
|
||||
while args and args[0][0] == '-':
|
||||
del args[0]
|
||||
|
@ -175,7 +200,7 @@ safe_command = args and args[0] in safe_commands
|
|||
if not safe_command:
|
||||
if _broken_module_imports('requirements.txt'):
|
||||
if yesno('Would you like to install the required Python modules?'):
|
||||
_run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt')
|
||||
_install_deps('requirements.txt')
|
||||
else:
|
||||
print()
|
||||
print(msg_install % (str(Path('requirements.txt').resolve()),))
|
||||
|
@ -184,7 +209,7 @@ if not safe_command:
|
|||
|
||||
if cli.config.user.developer and _broken_module_imports('requirements-dev.txt'):
|
||||
if yesno('Would you like to install the required developer Python modules?'):
|
||||
_run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements-dev.txt')
|
||||
_install_deps('requirements-dev.txt')
|
||||
elif yesno('Would you like to disable developer mode?'):
|
||||
_run_cmd(sys.argv[0], 'config', 'user.developer=None')
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue