diff options
Diffstat (limited to 'bin/qmk')
| -rwxr-xr-x | bin/qmk | 44 |
1 files changed, 0 insertions, 44 deletions
| @@ -3,7 +3,6 @@ | |||
| 3 | """ | 3 | """ |
| 4 | import os | 4 | import os |
| 5 | import sys | 5 | import sys |
| 6 | from importlib.util import find_spec | ||
| 7 | from pathlib import Path | 6 | from 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 | |||
| 12 | python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve() | 11 | python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve() |
| 13 | sys.path.append(str(python_lib_dir)) | 12 | sys.path.append(str(python_lib_dir)) |
| 14 | 13 | ||
| 15 | |||
| 16 | def _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 | |||
| 46 | developer = False | ||
| 47 | # Make sure our modules have been setup | ||
| 48 | _check_modules('requirements.txt') | ||
| 49 | |||
| 50 | # Setup the CLI | 14 | # Setup the CLI |
| 51 | import milc # noqa | 15 | import milc # noqa |
| 52 | 16 | ||
| 53 | # For developers additional modules are needed | ||
| 54 | if 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 | |||
| 61 | milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' | 17 | milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' |
| 62 | 18 | ||
| 63 | 19 | ||
