aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorZach White <skullydazed@gmail.com>2021-05-10 12:00:52 -0700
committerGitHub <noreply@github.com>2021-05-10 12:00:52 -0700
commitbc38c38f8c25dcbe759bc4d9d707a0069b3c6c59 (patch)
tree57cf7b2c3a9953a52ac333819d934687290d4f4b /bin
parenta3e7f3e7c58ee98596ead5c213f3a9ed8340cd80 (diff)
downloadqmk_firmware-bc38c38f8c25dcbe759bc4d9d707a0069b3c6c59.tar.gz
qmk_firmware-bc38c38f8c25dcbe759bc4d9d707a0069b3c6c59.zip
Move the module checking and updating to lib/python (#12416)
* move the module checking and updating to lib/python * make flake8 happy * Update lib/python/qmk/cli/__init__.py Co-authored-by: Erovia <Erovia@users.noreply.github.com> * prompt the user to disable developer mode * pyformat * flake8 Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/qmk44
1 files changed, 0 insertions, 44 deletions
diff --git a/bin/qmk b/bin/qmk
index a3c1be328..47b50f83b 100755
--- a/bin/qmk
+++ b/bin/qmk
@@ -3,7 +3,6 @@
3""" 3"""
4import os 4import os
5import sys 5import sys
6from importlib.util import find_spec
7from pathlib import Path 6from pathlib import Path
8 7
9# Add the QMK python libs to our path 8# Add the QMK python libs to our path
@@ -12,52 +11,9 @@ qmk_dir = script_dir.parent
12python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve() 11python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve()
13sys.path.append(str(python_lib_dir)) 12sys.path.append(str(python_lib_dir))
14 13
15
16def _check_modules(requirements):
17 """ Check if the modules in the given requirements.txt are available.
18 """
19 with Path(qmk_dir / requirements).open() as fd:
20 for line in fd.readlines():
21 line = line.strip().replace('<', '=').replace('>', '=')
22
23 if len(line) == 0 or line[0] == '#' or line.startswith('-r'):
24 continue
25
26 if '#' in line:
27 line = line.split('#')[0]
28
29 module = dict()
30 module['name'] = line.split('=')[0] if '=' in line else line
31 module['import'] = module['name'].replace('-', '_')
32
33 # Not every module is importable by its own name.
34 if module['name'] == "pep8-naming":
35 module['import'] = "pep8ext_naming"
36
37 if not find_spec(module['import']):
38 print('Could not find module %s!' % module['name'])
39 print('Please run `python3 -m pip install -r %s` to install required python dependencies.' % (qmk_dir / requirements,))
40 if developer:
41 print('You can also turn off developer mode: qmk config user.developer=None')
42 print()
43 exit(255)
44
45
46developer = False
47# Make sure our modules have been setup
48_check_modules('requirements.txt')
49
50# Setup the CLI 14# Setup the CLI
51import milc # noqa 15import milc # noqa
52 16
53# For developers additional modules are needed
54if milc.cli.config.user.developer:
55 # Do not run the check for 'config',
56 # so users can turn off developer mode
57 if len(sys.argv) == 1 or (len(sys.argv) > 1 and 'config' != sys.argv[1]):
58 developer = True
59 _check_modules('requirements-dev.txt')
60
61milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' 17milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
62 18
63 19