Skip to content

Commit

Permalink
Version 5.0.0 - Going live
Browse files Browse the repository at this point in the history
- Migrated over
  • Loading branch information
CCP-Zeulix committed Apr 15, 2024
1 parent 41fad93 commit 538a94d
Show file tree
Hide file tree
Showing 134 changed files with 9,253 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Virtual environments
venv*/
.venv*/

# IDEA Stuff
.idea/

# Local stuff
/proto/
/build/
/tests/res/build/
!/tests/res/build/empty.txt
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

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.0.0] - 2024-04-15

### Changed

- Moved this entire project over to Github
- Bumped the version in order to not confuse older stuff that doesn't expect
protoplasm to exist in Pypi.org (if we end up migriting this there and
just open-sourcing the whole thing)
- Also in case something changes in the API while migrating, cause I tend
to fiddle with the code and tidy up and refactor when moving stuff
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-2024 CCP Games

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
# neobuilder
# NeoBuilder

Builds Neobuf Packages from Protobuf files using Protoplasm! :D

## Useful info

Installing this package creates a command line executable called `neobuild` (or
`neobuild.exe` in Windows) in Python's `Scripts` folder so you just run the
`neobuild` command from a console.

## Usage

Assuming you've got a package called `sandbox` and you're storing your protobuf
files in a directory called `proto` and you want to spit out the build into the
directory `build` just go:

```
neobuild sandbox
```

## Versioning Your Package

If you place a plain text file called `VERSION` in the root of your proto
package (e.g. `/proto/sandbox/VERSION` from the example above) and skip any
versioning parameters (the `--major`, `-m`, `--patch` and `-p` guys) Neobuilder
will use that file for versioning.

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]
Builds neobuf packages with protoplasm.
positional arguments:
package Package name
protopath Path to the root of the protobuf files (default="./proto")
options:
-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
```
1 change: 1 addition & 0 deletions neobuilder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '5.0.0-beta.1'
Empty file added neobuilder/cli/__init__.py
Empty file.
37 changes: 37 additions & 0 deletions neobuilder/cli/neobuilder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse

from neobuilder.neobuilder import NeoBuilder


def main():
parser = argparse.ArgumentParser(description='Builds neobuf packages with protoplasm.',
epilog=(f'Neobuilder v{NeoBuilder.neobuilder_version()} - '
f'Protoplasm v{NeoBuilder.protoplasm_version()}'))
version_group = parser.add_mutually_exclusive_group()
version_group.add_argument('-m', '--major', action="store_true",
help='Bump the major version number instead of the minor')
version_group.add_argument('-p', '--patch', action="store_true",
help='Bump the patch version number instead of the minor')
parser.add_argument('package', help='Package name')
parser.add_argument('protopath', help='Path to the root of the protobuf files (default="./proto")',
default='./proto', nargs='?')
parser.add_argument('-b', '--buildroot', help='Path to the root of the output build files (default="./build")',
default='./build', nargs='?')
parser.add_argument('-v', '--verbose', action="store_true",
help='Spits out DEBUG level logs')

args = parser.parse_args()

n = NeoBuilder(
package=args.package,
protopath=args.protopath,
build_root=args.buildroot,
major=args.major,
patch=args.patch,
verbose=args.verbose,
)
n.build()


if __name__ == '__main__':
main()
12 changes: 12 additions & 0 deletions neobuilder/data/templates/dataclass.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% from 'macros/indentclude.jinja2' import indentclude with context %}
@dataclasses.dataclass
class {{ class_name }}(bases.DataclassBase):
__proto_cls__ = pb2.{{ proto_cls_name }}

{{ indentclude('parts/_nested_messages.jinja2', 4) }}

{{ indentclude('parts/_enum_map.jinja2', 4) }}

{% for pf in field_map %}
{{ pf }}
{% endfor %}
34 changes: 34 additions & 0 deletions neobuilder/data/templates/dataclass_module.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Auto-Generated file - DO NOT EDIT!
# Source module: {{ module_full_name }}
# Generated at: {{ iso_timestamp }}
from __future__ import annotations
__all__ = [
{% for a in all_list %}
'{{ a }}',
{% endfor %}
]
import dataclasses
import datetime
import enum
from typing import *
from protoplasm.casting import dictators
from protoplasm import plasm
{{ imports }}
{{ proto_import }}

import logging
log = logging.getLogger(__name__)


{% if enum_list %}
{% for enum in enum_list %}
{{ enum }}

{% endfor %}
{% endif %}
{% if message_list %}
{% for msg in message_list %}
{{ msg }}

{% endfor -%}
{%- endif -%}
19 changes: 19 additions & 0 deletions neobuilder/data/templates/grpc_receiver.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Auto-Generated file - DO NOT EDIT!
# Source module: {{ module_full_name }}
# Generated at: {{ iso_timestamp }}
__all__ = [
{% for a in all_list %}
'{{ a }}',
{% endfor %}
]
from typing import *
from protoplasm import plasm
{{ imports }}
if TYPE_CHECKING:
from grpc import ServicerContext

import logging
log = logging.getLogger(__name__)


{{ services }}
20 changes: 20 additions & 0 deletions neobuilder/data/templates/grpc_sender.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Auto-Generated file - DO NOT EDIT!
# Source module: {{ module_full_name }}
# Generated at: {{ iso_timestamp }}
from __future__ import annotations
__all__ = [
{% for a in all_list %}
'{{ a }}',
{% endfor %}
]
from typing import *
from protoplasm import plasm
{{ imports }}
if TYPE_CHECKING:
from grpc import ChannelCredentials

import logging
log = logging.getLogger(__name__)


{{ services }}
Empty file.
22 changes: 22 additions & 0 deletions neobuilder/data/templates/interface.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% from 'macros/indentclude.jinja2' import indentclude with context %}
# Auto-Generated file - DO NOT EDIT!
# Source module: {{ module_full_name }}
# Generated at: {{ iso_timestamp }}
__all__ = [
{% for a in all_clause %}
'{{ a }}',
{% endfor %}
]
import datetime
from typing import *
from protoplasm import plasm

{% for import_line in import_lines %}
{{ import_line }}
{% endfor %}

import logging
log = logging.getLogger(__name__)


{{ services }}
2 changes: 2 additions & 0 deletions neobuilder/data/templates/macros/indentclude.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- macro _inc(file_name, this) -%}{% include file_name with context %}{% endmacro %}
{%- macro indentclude(file_name, spaces=4, this={}) -%}{{ _inc(file_name, this)|indent(spaces) }}{%- endmacro -%}
1 change: 1 addition & 0 deletions neobuilder/data/templates/parts/_enum_map.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# ENUMS GO HERE...
2 changes: 2 additions & 0 deletions neobuilder/data/templates/parts/_interface_method.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def {{ this.method_under_name }}(self{{ this.input_params }}) -> {{ this.return_type_hint }}:
raise plasm.Unimplemented()
6 changes: 6 additions & 0 deletions neobuilder/data/templates/parts/_interface_service.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% from 'macros/indentclude.jinja2' import indentclude with context %}
class {{ service_name }}Interface:
{% for method in method_list %}
{{ indentclude('parts/_interface_method.jinja2', (indent_spaces + 4), method) }}

{% endfor %}
1 change: 1 addition & 0 deletions neobuilder/data/templates/parts/_nested_messages.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# NESTED MESSAGES GO HERE...
7 changes: 7 additions & 0 deletions neobuilder/data/templates/root_init.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__version__ = '{{ version }}'{% if version == '' %} # NO VERSION NUMBERS FOUND?!? :({% endif +%}
__protoplasm_version__ = '{{ protoplasm_version }}'
__neobuilder_version__ = '{{ neobuilder_version }}'


def load_symbols():
from {{ package_name }} import __everything__
2 changes: 2 additions & 0 deletions neobuilder/descwrap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ._field import *
from ._method import *
Loading

0 comments on commit 538a94d

Please sign in to comment.