Skip to content

Commit

Permalink
Merge pull request #9 from ccpgames/feature/pyi-and-includes
Browse files Browse the repository at this point in the history
Version 5.3.1 - Extra CLI flags
  • Loading branch information
CCP-Zeulix authored Oct 15, 2024
2 parents 5e2a1bd + cef56f8 commit bdd0bfd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>`/`--include <path>` flags in the CLI


## [5.3.0] - 2024-09-24

### Added
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,24 @@ 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.
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
```
2 changes: 1 addition & 1 deletion neobuilder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '5.3.0'
__version__ = '5.3.1'

__author__ = 'Thordur Matthiasson <[email protected]>'
__license__ = 'MIT License'
Expand Down
5 changes: 5 additions & 0 deletions neobuilder/cli/neobuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand Down
13 changes: 11 additions & 2 deletions neobuilder/neobuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bdd0bfd

Please sign in to comment.