From 596c4a1f87b46e1858c7d3630802eec741d1cc28 Mon Sep 17 00:00:00 2001 From: Zach White Date: Sun, 29 Aug 2021 16:50:22 -0700 Subject: [PATCH] Remove bin/qmk (#14231) * Remove the bin/qmk script * remove bin/qmk from workflows --- .github/labeler.yml | 1 - .github/workflows/cli.yml | 1 - Makefile | 6 +- bin/qmk | 58 ------------------- docs/contributing.md | 2 +- docs/de/cli.md | 19 ------ docs/fr-fr/cli.md | 19 ------ .../dz65rgb/keymaps/jumper149/readme.md | 4 +- lib/python/qmk/cli/doctor/check.py | 1 - lib/python/qmk/cli/format/python.py | 6 +- lib/python/qmk/cli/pytest.py | 2 +- lib/python/qmk/commands.py | 2 +- lib/python/qmk/tests/test_cli_commands.py | 2 +- shell.nix | 2 +- 14 files changed, 11 insertions(+), 114 deletions(-) delete mode 100755 bin/qmk diff --git a/.github/labeler.yml b/.github/labeler.yml index 53921f7f959..41b2475f678 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -22,7 +22,6 @@ keymap: via: - keyboards/**/keymaps/via/* cli: - - bin/qmk - requirements.txt - lib/python/**/* python: diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 7a8dc8540fa..3bf9741ac7b 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -8,7 +8,6 @@ on: pull_request: paths: - 'lib/python/**' - - 'bin/qmk' - 'requirements.txt' - '.github/workflows/cli.yml' diff --git a/Makefile b/Makefile index bb2201e8522..269be720c2f 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,7 @@ endif endif # Determine which qmk cli to use -ifeq (,$(shell which qmk)) - QMK_BIN = bin/qmk -else - QMK_BIN = qmk -endif +QMK_BIN := qmk # avoid 'Entering|Leaving directory' messages MAKEFLAGS += --no-print-directory diff --git a/bin/qmk b/bin/qmk deleted file mode 100755 index 617f9928264..00000000000 --- a/bin/qmk +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -"""CLI wrapper for running QMK commands. -""" -import os -import sys -from pathlib import Path - -# Add the QMK python libs to our path -script_dir = Path(os.path.realpath(__file__)).parent -qmk_dir = script_dir.parent -python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve() -sys.path.append(str(python_lib_dir)) - -# Setup the CLI -import milc # noqa - -milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' - - -@milc.cli.entrypoint('QMK Helper Script') -def qmk_main(cli): - """The function that gets run when no subcommand is provided. - """ - cli.print_help() - - -def main(): - """Setup our environment and then call the CLI entrypoint. - """ - # Change to the root of our checkout - os.environ['ORIG_CWD'] = os.getcwd() - os.environ['DEPRECATED_BIN_QMK'] = '1' - os.chdir(qmk_dir) - - print('Warning: The bin/qmk script is being deprecated. Please install the QMK CLI: python3 -m pip install qmk', file=sys.stderr) - - # Import the subcommands - import milc.subcommand.config # noqa - import qmk.cli # noqa - - # Execute - return_code = milc.cli() - - if return_code is False: - exit(1) - - elif return_code is not True and isinstance(return_code, int): - if return_code < 0 or return_code > 255: - milc.cli.log.error('Invalid return_code: %d', return_code) - exit(255) - - exit(return_code) - - exit(0) - - -if __name__ == '__main__': - main() diff --git a/docs/contributing.md b/docs/contributing.md index 1d68d22d9f0..eb033d167fd 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -105,7 +105,7 @@ enum my_keycodes { Before opening a pull request, you can preview your changes if you have set up the development environment by running this command from the `qmk_firmware/` folder: - ./bin/qmk docs + qmk docs or if you only have Python 3 installed: diff --git a/docs/de/cli.md b/docs/de/cli.md index 7dc02d505b6..259aeecf754 100644 --- a/docs/de/cli.md +++ b/docs/de/cli.md @@ -51,25 +51,6 @@ Wir suchen nach Freiwilligen, die ein `qmk`-Package für weitere Betriebssysteme * Installiere mit einem [virtualenv](https://virtualenv.pypa.io/en/latest/). * Weise den User an, die Umgebungs-Variable `QMK_HOME` zu setzen, um die Firmware-Quelle anders einzustellen als `~/qmk_firmware`. -# Lokale CLI - -Wenn Du die globale CLI nicht verwenden möchtest, beinhaltet `qmk_firmware` auch eine lokale CLI. Du kannst sie hier finden: `qmk_firmware/bin/qmk`. Du kannst den `qmk`-Befehl aus irgendeinem Datei-Verzeichnis ausführen und es wird immer auf dieser Kopie von `qmk_firmware` arbeiten. - -**Beispiel**: - -``` -$ ~/qmk_firmware/bin/qmk hello -Ψ Hello, World! -``` - -## Einschränkungen der lokalen CLI - -Hier ein Vergleich mit der globalen CLI: - -* Die lokale CLI unterstützt kein `qmk setup` oder `qmk clone`. -* Die lokale CLI arbeitet immer innerhalb der selben `qmk_firmware`-Verzeichnisstruktur, auch wenn Du mehrere Repositories geklont hast. -* Die lokale CLI läuft nicht in einer virtualenv. Daher ist es möglich, dass Abhängigkeiten (dependencies) miteinander in Konflikt kommen/stehen. - # CLI-Befehle ## `qmk compile` diff --git a/docs/fr-fr/cli.md b/docs/fr-fr/cli.md index bfa060f2add..917a9315bc2 100644 --- a/docs/fr-fr/cli.md +++ b/docs/fr-fr/cli.md @@ -48,25 +48,6 @@ Nous recherchons des gens pour créer et maintenir un paquet `qmk` pour plus de * Installez en utilisant un virtualenv * Expliquez à l'utilisateur de définir la variable d'environnement `QMK_Home` pour "check out" les sources du firmware à un autre endroit que `~/qmk_firmware`. -# CLI locale - -Si vous ne voulez pas utiliser la CLI globale, il y a une CLI locale empaquetée avec `qmk_firmware`. Vous pouvez le trouver dans `qmk_firmware/bin/qmk`. Vous pouvez lancer la commande `qmk` depuis n'importe quel répertoire et elle fonctionnera toujours sur cette copie de `qmk_firmware`. - -**Exemple**: - -``` -$ ~/qmk_firmware/bin/qmk hello -Ψ Hello, World! -``` - -## Limitations de la CLI locale - -Il y a quelques limitations à la CLI locale comparé à la globale: - -* La CLI locale ne supporte pas `qmk setup` ou `qmk clone` -* La CLI locale n'opère pas sur le même arbre `qmk_firmware`, même si vous avez plusieurs dépôts clonés. -* La CLI locale ne s'exécute pas dans un virtualenv, donc il y a des risques que des dépendances seront en conflit - # Les commandes CLI ## `qmk compile` diff --git a/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md b/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md index d872587317d..9de86be2d12 100644 --- a/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md +++ b/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md @@ -3,13 +3,13 @@ Run commands in the root directory of this repository. ``` -./bin/qmk compile && sudo dfu-programmer atmega32u4 erase && sudo dfu-programmer atmega32u4 flash ./dztech_dz65rgb_v2_jumper149.hex && sudo dfu-programmer atmega32u4 reset +qmk compile && sudo dfu-programmer atmega32u4 erase && sudo dfu-programmer atmega32u4 flash ./dztech_dz65rgb_v2_jumper149.hex && sudo dfu-programmer atmega32u4 reset ``` ## build ``` -./bin/qmk compile +qmk compile ``` ## flash diff --git a/lib/python/qmk/cli/doctor/check.py b/lib/python/qmk/cli/doctor/check.py index 0807f415185..2d691b64b05 100644 --- a/lib/python/qmk/cli/doctor/check.py +++ b/lib/python/qmk/cli/doctor/check.py @@ -26,7 +26,6 @@ ESSENTIAL_BINARIES = { 'arm-none-eabi-gcc': { 'version_arg': '-dumpversion' }, - 'bin/qmk': {}, } diff --git a/lib/python/qmk/cli/format/python.py b/lib/python/qmk/cli/format/python.py index 00612f97ecd..b32a7264019 100755 --- a/lib/python/qmk/cli/format/python.py +++ b/lib/python/qmk/cli/format/python.py @@ -11,15 +11,15 @@ def format_python(cli): """Format python code according to QMK's style. """ edit = '--diff' if cli.args.dry_run else '--in-place' - yapf_cmd = ['yapf', '-vv', '--recursive', edit, 'bin/qmk', 'lib/python'] + yapf_cmd = ['yapf', '-vv', '--recursive', edit, 'lib/python'] try: cli.run(yapf_cmd, check=True, capture_output=False, stdin=DEVNULL) - cli.log.info('Python code in `bin/qmk` and `lib/python` is correctly formatted.') + cli.log.info('Python code in `lib/python` is correctly formatted.') return True except CalledProcessError: if cli.args.dry_run: - cli.log.error('Python code in `bin/qmk` and `lib/python` incorrectly formatted!') + cli.log.error('Python code in `lib/python` is incorrectly formatted!') else: cli.log.error('Error formatting python code!') diff --git a/lib/python/qmk/cli/pytest.py b/lib/python/qmk/cli/pytest.py index bdb336b9a70..a7f01a872aa 100644 --- a/lib/python/qmk/cli/pytest.py +++ b/lib/python/qmk/cli/pytest.py @@ -12,6 +12,6 @@ def pytest(cli): """Run several linting/testing commands. """ nose2 = cli.run(['nose2', '-v'], capture_output=False, stdin=DEVNULL) - flake8 = cli.run(['flake8', 'lib/python', 'bin/qmk'], capture_output=False, stdin=DEVNULL) + flake8 = cli.run(['flake8', 'lib/python'], capture_output=False, stdin=DEVNULL) return flake8.returncode | nose2.returncode diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 421453d8377..01c23b26121 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -233,7 +233,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va f'VERBOSE={verbose}', f'COLOR={color}', 'SILENT=false', - f'QMK_BIN={"bin/qmk" if "DEPRECATED_BIN_QMK" in os.environ else "qmk"}', + 'QMK_BIN="qmk"', ]) return make_command diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index b39fe5e46da..e4eaef899ae 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -83,7 +83,7 @@ def test_hello(): def test_format_python(): result = check_subcommand('format-python', '--dry-run') check_returncode(result) - assert 'Python code in `bin/qmk` and `lib/python` is correctly formatted.' in result.stdout + assert 'Python code in `lib/python` is correctly formatted.' in result.stdout def test_list_keyboards(): diff --git a/shell.nix b/shell.nix index c36df032de4..5023a3b0f71 100644 --- a/shell.nix +++ b/shell.nix @@ -14,7 +14,7 @@ let projectDir = ./util/nix; overrides = poetry2nix.overrides.withDefaults (self: super: { qmk = super.qmk.overridePythonAttrs(old: { - # Allow QMK CLI to run "bin/qmk" as a subprocess (the wrapper changes + # Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes # $PATH and breaks these invocations). dontWrapPythonPrograms = true; });