Skip to content

Commit bdd0bfd

Browse files
authored
Merge pull request #9 from ccpgames/feature/pyi-and-includes
Version 5.3.1 - Extra CLI flags
2 parents 5e2a1bd + cef56f8 commit bdd0bfd

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## [5.3.1] - 2024-10-15
10+
11+
### Added
12+
13+
- The `-i`/`--pyi` option to the CLI to include building `*.pyi` files for the generated `*_pb2.py` files
14+
- The ability to include multiple additional proto paths with `-I <path>`/`--include <path>` flags in the CLI
15+
16+
917
## [5.3.0] - 2024-09-24
1018

1119
### Added

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,24 @@ The first line in the file should be the semantic version number `x.y.z.a`
6161
## More stuff
6262

6363
```
64-
usage: neobuild [-h] [-m | -p] [-b [BUILDROOT]] [-v] package [protopath]
64+
usage: neobuilder.py [-h] [-m | -p] [-b [BUILDROOT]] [-v] [-i] [-I INCLUDE] package [protopath]
6565
6666
Builds neobuf packages with protoplasm.
6767
6868
positional arguments:
6969
package Package name
7070
protopath Path to the root of the protobuf files (default="./proto")
7171
72-
options:
72+
optional arguments:
7373
-h, --help show this help message and exit
7474
-m, --major Bump the major version number instead of the minor
7575
-p, --patch Bump the patch version number instead of the minor
7676
-b [BUILDROOT], --buildroot [BUILDROOT]
7777
Path to the root of the output build files (default="./build")
7878
-v, --verbose Spits out DEBUG level logs
79+
-i, --pyi Builds *.pyi for the pb2 files as well (default=False)
80+
-I INCLUDE, --include INCLUDE
81+
Optional additional proto paths to include (can be used multiple times)
82+
83+
Neobuilder v5.3.1 - Protoplasm v5.2.0
7984
```

neobuilder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '5.3.0'
1+
__version__ = '5.3.1'
22

33
__author__ = 'Thordur Matthiasson <thordurm@ccpgames.com>'
44
__license__ = 'MIT License'

neobuilder/cli/neobuilder.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ def main():
1919
default='./build', nargs='?')
2020
parser.add_argument('-v', '--verbose', action="store_true",
2121
help='Spits out DEBUG level logs')
22+
parser.add_argument('-i', '--pyi', action="store_true",
23+
help='Builds *.pyi for the pb2 files as well (default=False)')
24+
parser.add_argument('-I', '--include', action='append', help="Optional additional proto paths to include (can be used multiple times)", default=[])
2225

2326
args = parser.parse_args()
2427

@@ -29,6 +32,8 @@ def main():
2932
major=args.major,
3033
patch=args.patch,
3134
verbose=args.verbose,
35+
include_pyi=args.pyi,
36+
extra_includes=args.include,
3237
)
3338
n.build()
3439

neobuilder/neobuilder/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ def __init__(self,
3535
build_root: str = './build',
3636
major: bool = False,
3737
patch: bool = False,
38-
verbose: bool = False):
38+
verbose: bool = False,
39+
include_pyi: bool = False,
40+
extra_includes: Optional[List[str]] = None):
3941

4042
self.package = package
4143

4244
self.protopath = protopath.replace('\\', '/')
4345
self.build_root = build_root.replace('\\', '/')
46+
self.extra_includes = [i.replace('\\', '/') for i in (extra_includes or [])]
47+
self.include_pyi = include_pyi
4448

4549
self.major = major
4650
self.patch = patch
@@ -51,8 +55,13 @@ def __init__(self,
5155
self.proto_include = self._get_basic_proto_path()
5256
self.proto_build_args = ['protoc', f'-I{self.protopath}/']
5357
if self.proto_include:
54-
self.proto_build_args.append('-I{}'.format(self.proto_include))
58+
self.proto_build_args.append(f'-I{self.proto_include}')
59+
if self.extra_includes:
60+
for i in self.extra_includes:
61+
self.proto_build_args.append(f'-I{i}')
5562
self.proto_build_args.append(f'--python_out={self.build_root}')
63+
if self.include_pyi:
64+
self.proto_build_args.append(f'--pyi_out={self.build_root}')
5665

5766
self.last_version = None
5867
self._next_version = None

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
protoplasm >=5.2, <6
1+
protoplasm >=5.3, <6
22
ccptools >=1.1, <2
33
Jinja2 >=3.1, <4
44
semver >= 3.0.2, <4

0 commit comments

Comments
 (0)