From cef56f8a658137d7ffefd23a8e2a78ac0b51cc98 Mon Sep 17 00:00:00 2001 From: ccp_zeulix Date: Tue, 15 Oct 2024 12:23:51 +0000 Subject: [PATCH] Version 5.3.1 - Extra CLI flags ### Added - The `-i`/`--pyi` option to the CLI to include building `*.pyi` files for the generated `*_pb2.py` files - The ability to include multiple additional proto paths with `-I `/`--include ` flags in the CLI --- CHANGELOG.md | 8 ++++++++ README.md | 9 +++++++-- neobuilder/__init__.py | 2 +- neobuilder/cli/neobuilder.py | 5 +++++ neobuilder/neobuilder/__init__.py | 13 +++++++++++-- requirements.txt | 2 +- 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc6b6cd..ef6fd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.3.1] - 2024-10-15 + +### Added + +- The `-i`/`--pyi` option to the CLI to include building `*.pyi` files for the generated `*_pb2.py` files +- The ability to include multiple additional proto paths with `-I `/`--include ` flags in the CLI + + ## [5.3.0] - 2024-09-24 ### Added diff --git a/README.md b/README.md index 618c712..b739d0a 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The first line in the file should be the semantic version number `x.y.z.a` ## More stuff ``` -usage: neobuild [-h] [-m | -p] [-b [BUILDROOT]] [-v] package [protopath] +usage: neobuilder.py [-h] [-m | -p] [-b [BUILDROOT]] [-v] [-i] [-I INCLUDE] package [protopath] Builds neobuf packages with protoplasm. @@ -69,11 +69,16 @@ positional arguments: package Package name protopath Path to the root of the protobuf files (default="./proto") -options: +optional arguments: -h, --help show this help message and exit -m, --major Bump the major version number instead of the minor -p, --patch Bump the patch version number instead of the minor -b [BUILDROOT], --buildroot [BUILDROOT] Path to the root of the output build files (default="./build") -v, --verbose Spits out DEBUG level logs + -i, --pyi Builds *.pyi for the pb2 files as well (default=False) + -I INCLUDE, --include INCLUDE + Optional additional proto paths to include (can be used multiple times) + +Neobuilder v5.3.1 - Protoplasm v5.2.0 ``` \ No newline at end of file diff --git a/neobuilder/__init__.py b/neobuilder/__init__.py index 38a5c87..60bef0a 100644 --- a/neobuilder/__init__.py +++ b/neobuilder/__init__.py @@ -1,4 +1,4 @@ -__version__ = '5.3.0' +__version__ = '5.3.1' __author__ = 'Thordur Matthiasson ' __license__ = 'MIT License' diff --git a/neobuilder/cli/neobuilder.py b/neobuilder/cli/neobuilder.py index 05e0956..963a469 100644 --- a/neobuilder/cli/neobuilder.py +++ b/neobuilder/cli/neobuilder.py @@ -19,6 +19,9 @@ def main(): default='./build', nargs='?') parser.add_argument('-v', '--verbose', action="store_true", help='Spits out DEBUG level logs') + parser.add_argument('-i', '--pyi', action="store_true", + help='Builds *.pyi for the pb2 files as well (default=False)') + parser.add_argument('-I', '--include', action='append', help="Optional additional proto paths to include (can be used multiple times)", default=[]) args = parser.parse_args() @@ -29,6 +32,8 @@ def main(): major=args.major, patch=args.patch, verbose=args.verbose, + include_pyi=args.pyi, + extra_includes=args.include, ) n.build() diff --git a/neobuilder/neobuilder/__init__.py b/neobuilder/neobuilder/__init__.py index 84dfaa7..dce6706 100644 --- a/neobuilder/neobuilder/__init__.py +++ b/neobuilder/neobuilder/__init__.py @@ -35,12 +35,16 @@ def __init__(self, build_root: str = './build', major: bool = False, patch: bool = False, - verbose: bool = False): + verbose: bool = False, + include_pyi: bool = False, + extra_includes: Optional[List[str]] = None): self.package = package self.protopath = protopath.replace('\\', '/') self.build_root = build_root.replace('\\', '/') + self.extra_includes = [i.replace('\\', '/') for i in (extra_includes or [])] + self.include_pyi = include_pyi self.major = major self.patch = patch @@ -51,8 +55,13 @@ def __init__(self, self.proto_include = self._get_basic_proto_path() self.proto_build_args = ['protoc', f'-I{self.protopath}/'] if self.proto_include: - self.proto_build_args.append('-I{}'.format(self.proto_include)) + self.proto_build_args.append(f'-I{self.proto_include}') + if self.extra_includes: + for i in self.extra_includes: + self.proto_build_args.append(f'-I{i}') self.proto_build_args.append(f'--python_out={self.build_root}') + if self.include_pyi: + self.proto_build_args.append(f'--pyi_out={self.build_root}') self.last_version = None self._next_version = None diff --git a/requirements.txt b/requirements.txt index 2a8277a..43eb0dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -protoplasm >=5.2, <6 +protoplasm >=5.3, <6 ccptools >=1.1, <2 Jinja2 >=3.1, <4 semver >= 3.0.2, <4