Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"

- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
python-version: ">=3.10"
cache: "pip"
enable-cache: true

- name: Install dependencies
run: |
pip install .
pip install pylint
run: uv sync --locked --all-extras --dev

- name: pre-commit
uses: pre-commit/actions@v3.0.1
- name: prek
uses: j178/prek-action@v1

- name: pyright
uses: jakebailey/pyright-action@v2

- name: pylint
run: pylint zmk
uses: jakebailey/pyright-action@v3
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ">=3.10"
python-version-file: "pyproject.toml"
- name: Install pypa/build
run: python3 -m pip install build --user
- name: Build wheel and source tarball
run: python3 -m build
- name: Store distribution packages
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
Expand All @@ -37,7 +37,7 @@ jobs:

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
Expand All @@ -61,7 +61,7 @@ jobs:
name: python-package-distributions
path: dist/
- name: Sign artifacts
uses: sigstore/gh-action-sigstore-python@v3.0.0
uses: sigstore/gh-action-sigstore-python@v3.2.0
with:
inputs: >-
./dist/*.tar.gz
Expand Down
20 changes: 6 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
fail_fast: false
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.2
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/pycqa/isort
rev: "7.0.0"
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: "25.12.0"
hooks:
- id: black
- id: ruff-check
- id: ruff-format
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
rev: v1.5.6
hooks:
- id: remove-tabs
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -26,7 +18,7 @@ repos:
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v0.7.14
rev: v0.7.32
hooks:
- id: tombi-format
- id: tombi-lint
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.python"
]
"recommendations": ["charliermarsh.ruff", "ms-python.python"]
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
"source.organizeImports": "explicit"
}
},
"[markdown][yaml]": {
Expand All @@ -20,8 +20,8 @@
"**/templates/shield/**": "mako",
"**/templates/common/**": "mako"
},
"isort.check": true,
"isort.args": ["--settings-path", "${workspaceFolder}"],
"pylint.enabled": false,
"ruff.enabled": true,
"python.analysis.importFormat": "relative",
"python.analysis.typeCheckingMode": "standard",
"python-envs.pythonProjects": []
Expand Down
126 changes: 39 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,100 +8,30 @@ The instructions below contain commands that need to be run in a terminal progra

# Installation

## Install Git

Install Git from https://git-scm.com/downloads.

If you have Windows 11, you can instead open a terminal and run:

```sh
winget install git.git -i
```

The Windows installer will give you lots of options. You can leave all of them as their defaults, but when you get to the "choosing the default editor used by Git" screen, you may want to select a different text editor to use when writing Git commit messages.

## Install Python

ZMK CLI requires Python 3.10 or newer.

### On Windows and macOS

Install the latest version of Python from https://www.python.org/downloads/.

If you have Windows 11, you can instead open a terminal and run:

```sh
winget install python3
```

### On Linux

Most Linux distributions come with Python already installed. Open a terminal and run the following command to check its version:

```sh
python3 --version
```

If Python is not installed, install `python3` with your package manager.

If the version is older than 3.10, you will need to find and install a package for a newer version of Python. On Ubuntu 20.04 and older, you can get Python 3.10 from the deadsnakes PPA with the following commands:

```sh
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10
```

You will then need to replace `python3` with `python3.10` in the rest of the installation instructions.

## Install pipx
This readme will provide brief instructions for installing ZMK CLI. For instructions in more detail, see the [ZMK Documentation](https://zmk.dev/docs/user-setup).

ZMK CLI can be installed with pip, but using [pipx](https://github.com/pypa/pipx) is recommended to avoid conflicts between Python packages.

### On Windows and Linux

Open a terminal and run:

```sh
python3 -m pip install --user pipx
python3 -m pipx ensurepath
```

Some Linux distributions may disallow installing packages with pip. If this gives you an error, see the [install instructions](https://github.com/pypa/pipx?tab=readme-ov-file#on-linux) specific to your distribution.

Close and reopen your terminal, then run the following command. It should print a version number if everything is installed correctly:
## Install Git

```sh
pipx --version
```
Install Git from https://git-scm.com/downloads or your OS's package manager.

### On macOS
You will also need a [GitHub account](https://github.com/signup).

Open Terminal and run:
## Install uv

```
brew install pipx
pipx ensurepath
```
Install uv from https://docs.astral.sh/uv/getting-started/installation/.

## Install ZMK CLI

Next, run the following commands:
Run the following command to install ZMK CLI:

```sh
pipx install zmk
zmk --help
uv tool install zmk
```

It should print a help message if everything installed correctly.

On Linux, you may get an error saying you need to install another package such as `python3.10-venv`. If so, follow the instructions in the error message, then try the above commands again.

## Update ZMK CLI

If you have already installed ZMK CLI, you can update to the latest version with the following command:

```sh
pipx upgrade zmk
uv tool upgrade zmk
```

# Usage
Expand Down Expand Up @@ -272,22 +202,44 @@ zmk config user.home ~/Documents/zmk-config

# Development

If you would like to help improve ZMK CLI, you can clone this repo and install it in editable mode so your changes to the code apply when you run `zmk`. First, open a terminal to the root directory of the repository.
If you would like to help improve ZMK CLI, you can clone this repo and install it into a virtual environment where you can modify it. First, open a terminal to the root directory of the repository. Then, create a virtual environment and install the project's dependencies:

```sh
# Create virtual environment and install dependencies
uv sync
# Install pre-commit hooks
uv run prek install
```

To run the development version of the program, either prefix commands with `uv run`...

```sh
uv run zmk <args...>
```

...or [activate the virtual environment](https://docs.astral.sh/uv/pip/environments/#using-a-virtual-environment) first, and then you can use just `zmk`.

If you want `zmk` to run the development version even when you are not inside the virtual environment, you can install it globally in editable mode:

```sh
uv tool install -e .
```

You may optionally run the following commands inside a [virtual environment](https://docs.python.org/3/library/venv.html) if you don't want to install ZMK CLI's dependencies globally or if your OS disallows doing this.
## Linting

To install ZMK CLI in editable mode, run:
After running `uv run prek install`, linting and code formatting will be run automatically when you make a commit. You can also run these tools manually:

```sh
pip install -e ".[dev]"
pre-commit install
# lint codebase
uv run ruff check
# format files
uv run ruff format
```

After running `pre-commit install`, your code will be checked when you make a commit, but there are some slower checks that do not run automatically. To run these additional checks, run these commands:
Type checking is slower and difficult to configure to run as a Git commit hook, so this needs to be run manually.

```sh
pyright .
pylint zmk
uv run pyright .
```

GitHub will also run these checks and report any errors when you make a pull request.
Loading