Skip to content
6 changes: 3 additions & 3 deletions src/frequenz/repo/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
nox.configure(RepositoryType.LIB)
```

Again, make sure to pick the correct project typedefault configuration based on the type of your
project (`actor_config`, `api_config`, `app_config`, `lib_config`, `model_config`).
Again, make sure to pick the correct project default configuration based on the type of
your project (`actor_config`, `api_config`, `app_config`, `lib_config`, `model_config`).

If you need to use some custom configuration, you can start from the default settings in
the [`frequenz.repo.config.nox.default`][] module,
Expand Down Expand Up @@ -312,7 +312,7 @@
typed.

3. Exclude the `src/conftest.py` file from the distribution package, as it shouldn't be
shipped with the code, it is only for delelopment purposes. To do so, add the
shipped with the code, it is only for development purposes. To do so, add the
following line to the `MANIFEST.in` file:

```
Expand Down
11 changes: 7 additions & 4 deletions src/frequenz/repo/config/mkdocs/mike.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def build_mike_version(repo_info: RepoVersionInfo) -> MikeVersionInfo:
)


_is_version_re = re.compile(r"^v(\d+).(\d+)(-dev|-pre)?$")
_stable_to_semver_re = re.compile(r"^v(\d+).(\d+)$")
_pre_to_semver_re = re.compile(r"^v(\d+).(\d+)-pre$")
_dev_to_semver_re = re.compile(r"^v(\d+).(\d+)-dev$")
_is_version_re = re.compile(r"^v(\d+)\.(\d+)(?:-dev|-pre)?$")
_stable_to_semver_re = re.compile(r"^v(\d+)\.(\d+)$")
_pre_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-pre$")
_dev_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-dev$")


def _to_fake_sortable_semver(version: str) -> str:
Expand Down Expand Up @@ -207,6 +207,9 @@ def compare_mike_version(version1: str, version2: str) -> int:
if is_version_v2: # version1 is not a version
return 1

if version1 == version2:
return 0

return -1 if version1 < version2 else 1


Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/repo/config/nox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
nox.configure(RepositoryType.LIB)
```

Again, make sure to pick the correct project typedefault configuration based on the type
Again, make sure to pick the correct project default configuration based on the type
of your project (`actor_config`, `api_config`, `app_config`, `lib_config`,
`model_config`).

Expand Down
21 changes: 16 additions & 5 deletions src/frequenz/repo/config/setuptools/grpc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import pathlib as _pathlib
import subprocess as _subprocess
import sys as _sys
from typing import cast
from collections.abc import Iterable
from typing import assert_never, cast

import setuptools as _setuptools
import setuptools.command.build as _build_command
Expand All @@ -30,8 +31,8 @@ class CompileProto(_setuptools.Command):
proto_glob: str
"""The glob pattern to use to find the protobuf files."""

include_paths: str
"""Comma-separated list of paths to include when compiling the protobuf files."""
include_paths: str | Iterable[str]
"""Iterable or comma-separated list of paths to include when compiling the protobuf files."""

py_path: str
"""The path of the root directory where the Python files will be generated."""
Expand Down Expand Up @@ -72,15 +73,25 @@ def initialize_options(self) -> None:

self.proto_path = config.proto_path
self.proto_glob = config.proto_glob
self.include_paths = ",".join(config.include_paths)
self.include_paths = config.include_paths
self.py_path = config.py_path

def finalize_options(self) -> None:
"""Finalize options."""

def run(self) -> None:
"""Compile the Python protobuf files."""
include_paths = self.include_paths.split(",")
include_paths: Iterable[str]
match self.include_paths:
case str() as str_paths:
# If it comes as a comma-separated string, split it into a list,
# stripping whitespace and ignoring empty strings.
include_paths = filter(len, map(str.strip, str_paths.split(",")))
case Iterable() as paths_it:
include_paths = paths_it
case unexpected:
assert_never(unexpected)

proto_files = [
str(p) for p in _pathlib.Path(self.proto_path).rglob(self.proto_glob)
]
Expand Down
2 changes: 2 additions & 0 deletions tests/mkdocs/test_mike.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ def test_build_mike_version(
("v2.0-pre", "v1.0-pre", 1),
("v2.0", "v1.0-pre", 1),
("blah", "v1.0-dev", 1),
("blah", "blah", 0),
("v1x0-dev", "v1.0-dev", 1),
("alpha", "beta", -1),
],
)
Expand Down
Loading