Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
[wip] packaging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
shaldengeki committed Feb 14, 2024
1 parent 0f8d56d commit 283f76e
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 95 deletions.
5 changes: 5 additions & 0 deletions build-and-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

python -m build --wheel
python -m build --sdist
twine upload --config-file .pypirc --skip-existing dist/*
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
license_files = LICENSE
38 changes: 38 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from setuptools import setup, find_packages
import pathlib

here = pathlib.Path(__file__).parent.resolve()

long_description = (here / "README.md").read_text(encoding="utf-8")

setup(
name="py_proto_parser",
version="0.0.1",
description="A Python protobuf parser library.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/shaldengeki/py_proto",
author="Charles OuGuo",
author_email="[email protected]",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
],
keywords="protobuf, protocol, buffers",
package_dir={"": "src"},

packages=find_packages(where="src"),
python_requires=">=3.10, <4",
install_requires=[],
entry_points={
"console_scripts": [
"parser=parser:main",
"compatibility_checker=compatibility_checker:main",
],
},
)
24 changes: 24 additions & 0 deletions src/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_python//python:packaging.bzl", "py_wheel")


py_library(
name = "proto_node",
Expand Down Expand Up @@ -257,3 +259,25 @@ py_library(
":proto_syntax",
],
)

py_wheel(
name = "py_proto_wheel",
distribution = "py_proto",
python_tag = "py3",
version = "0.0.1",
author = "Charles OuGuo",
author_email = "[email protected]",
entry_points = {
'console_scripts': ['parser = src.util.parser:main', 'compatibility_checker = src.util.compatibility_checker:main']
},
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: MIT License"
],
strip_path_prefixes = ["src"],
homepage = "https://github.com/shaldengeki/py_proto",
visibility = ["//visibility:public"],
deps = [
"//src/util:all_package"
],
)
4 changes: 2 additions & 2 deletions src/proto_bool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from src.proto_identifier import ProtoFullIdentifier
from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_identifier import ProtoFullIdentifier
from .proto_node import ParsedProtoNode, ProtoNode


class ParsedProtoBoolNode(ParsedProtoNode):
Expand Down
2 changes: 1 addition & 1 deletion src/proto_comment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
from typing import Optional

from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_node import ParsedProtoNode, ProtoNode


class ParsedProtoCommentNode(ParsedProtoNode):
Expand Down
12 changes: 6 additions & 6 deletions src/proto_constant.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

from src.proto_bool import ProtoBool
from src.proto_float import ProtoFloat, ProtoFloatSign
from src.proto_identifier import ProtoFullIdentifier
from src.proto_int import ProtoInt, ProtoIntSign
from src.proto_node import ParsedProtoNode, ProtoNode
from src.proto_string_literal import ProtoStringLiteral
from .proto_bool import ProtoBool
from .proto_float import ProtoFloat, ProtoFloatSign
from .proto_identifier import ProtoFullIdentifier
from .proto_int import ProtoInt, ProtoIntSign
from .proto_node import ParsedProtoNode, ProtoNode
from .proto_string_literal import ProtoStringLiteral

ProtoConstantTypes = (
ProtoFullIdentifier | ProtoStringLiteral | ProtoInt | ProtoFloat | ProtoBool
Expand Down
12 changes: 6 additions & 6 deletions src/proto_enum.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import Optional, Sequence

from src.proto_comment import (
from .proto_comment import (
ProtoComment,
ProtoMultiLineComment,
ProtoSingleLineComment,
)
from src.proto_identifier import ProtoIdentifier
from src.proto_int import ProtoInt, ProtoIntSign
from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from src.proto_option import ParsedProtoOptionNode, ProtoOption, ProtoOptionDiff
from src.proto_reserved import ProtoReserved
from .proto_identifier import ProtoIdentifier
from .proto_int import ProtoInt, ProtoIntSign
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_option import ParsedProtoOptionNode, ProtoOption, ProtoOptionDiff
from .proto_reserved import ProtoReserved


class ParsedProtoEnumValueOptionNode(ParsedProtoOptionNode):
Expand Down
8 changes: 4 additions & 4 deletions src/proto_extend.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Optional

from src.proto_comment import (
from .proto_comment import (
ProtoComment,
ProtoMultiLineComment,
ProtoSingleLineComment,
)
from src.proto_identifier import ProtoEnumOrMessageIdentifier
from src.proto_message_field import ProtoMessageField
from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_identifier import ProtoEnumOrMessageIdentifier
from .proto_message_field import ProtoMessageField
from .proto_node import ParsedProtoNode, ProtoNode


class ProtoExtend(ProtoNode):
Expand Down
6 changes: 3 additions & 3 deletions src/proto_extensions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional

from src.proto_identifier import ProtoIdentifier
from src.proto_node import ParsedProtoNode, ProtoNode
from src.proto_range import ProtoRange
from .proto_identifier import ProtoIdentifier
from .proto_node import ParsedProtoNode, ProtoNode
from .proto_range import ProtoRange


class ProtoExtensions(ProtoNode):
Expand Down
14 changes: 7 additions & 7 deletions src/proto_file.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Optional, Sequence

from src.proto_enum import ProtoEnum
from src.proto_import import ProtoImport
from src.proto_message import ProtoMessage
from src.proto_node import ProtoNode, ProtoNodeDiff
from src.proto_option import ProtoOption
from src.proto_package import ProtoPackage
from src.proto_syntax import ProtoSyntax
from .proto_enum import ProtoEnum
from .proto_import import ProtoImport
from .proto_message import ProtoMessage
from .proto_node import ProtoNode, ProtoNodeDiff
from .proto_option import ProtoOption
from .proto_package import ProtoPackage
from .proto_syntax import ProtoSyntax


class ProtoFile:
Expand Down
6 changes: 3 additions & 3 deletions src/proto_float.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional

from src.proto_identifier import ProtoIdentifier
from src.proto_int import ProtoInt
from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_identifier import ProtoIdentifier
from .proto_int import ProtoInt
from .proto_node import ParsedProtoNode, ProtoNode


class ProtoFloatSign(Enum):
Expand Down
2 changes: 1 addition & 1 deletion src/proto_identifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_node import ParsedProtoNode, ProtoNode


class ParsedProtoIdentifierNode(ParsedProtoNode):
Expand Down
4 changes: 2 additions & 2 deletions src/proto_import.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from src.proto_string_literal import ProtoStringLiteral
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_string_literal import ProtoStringLiteral


class ProtoImport(ProtoNode):
Expand Down
4 changes: 2 additions & 2 deletions src/proto_int.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from typing import Optional

from src.proto_identifier import ProtoFullIdentifier
from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_identifier import ProtoFullIdentifier
from .proto_node import ParsedProtoNode, ProtoNode


class ProtoIntSign(Enum):
Expand Down
8 changes: 4 additions & 4 deletions src/proto_map.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enum import Enum
from typing import Optional, Sequence

from src.proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from src.proto_int import ProtoInt
from src.proto_message_field import ProtoMessageFieldOption, ProtoMessageFieldTypesEnum
from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from .proto_int import ProtoInt
from .proto_message_field import ProtoMessageFieldOption, ProtoMessageFieldTypesEnum
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff


class ProtoMapKeyTypesEnum(Enum):
Expand Down
22 changes: 11 additions & 11 deletions src/proto_message.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from typing import Optional, Sequence

from src.proto_comment import (
from .proto_comment import (
ProtoComment,
ProtoMultiLineComment,
ProtoSingleLineComment,
)
from src.proto_enum import ProtoEnum
from src.proto_extend import ProtoExtend
from src.proto_extensions import ProtoExtensions
from src.proto_identifier import ProtoIdentifier
from src.proto_map import ProtoMap
from src.proto_message_field import ProtoMessageField
from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from src.proto_oneof import ProtoOneOf
from src.proto_option import ProtoOption
from src.proto_reserved import ProtoReserved
from .proto_enum import ProtoEnum
from .proto_extend import ProtoExtend
from .proto_extensions import ProtoExtensions
from .proto_identifier import ProtoIdentifier
from .proto_map import ProtoMap
from .proto_message_field import ProtoMessageField
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_oneof import ProtoOneOf
from .proto_option import ProtoOption
from .proto_reserved import ProtoReserved


class ProtoMessage(ProtoNode):
Expand Down
8 changes: 4 additions & 4 deletions src/proto_message_field.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enum import Enum
from typing import Optional, Sequence

from src.proto_enum import ParsedProtoEnumValueOptionNode, ProtoEnumValueOption
from src.proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from src.proto_int import ProtoInt
from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_enum import ParsedProtoEnumValueOptionNode, ProtoEnumValueOption
from .proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from .proto_int import ProtoInt
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff


class ParsedProtoMessageFieldOptionNode(ParsedProtoEnumValueOptionNode):
Expand Down
12 changes: 6 additions & 6 deletions src/proto_oneof.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from typing import Optional, Sequence

from src.proto_comment import (
from .proto_comment import (
ParsedProtoMultiLineCommentNode,
ParsedProtoSingleLineCommentNode,
ProtoComment,
ProtoMultiLineComment,
ProtoSingleLineComment,
)
from src.proto_identifier import ProtoIdentifier
from src.proto_map import ProtoMap
from src.proto_message_field import ParsedProtoMessageFieldNode, ProtoMessageField
from src.proto_node import ParsedProtoNode, ProtoNode
from src.proto_option import ParsedProtoOptionNode, ProtoOption
from .proto_identifier import ProtoIdentifier
from .proto_map import ProtoMap
from .proto_message_field import ParsedProtoMessageFieldNode, ProtoMessageField
from .proto_node import ParsedProtoNode, ProtoNode
from .proto_option import ParsedProtoOptionNode, ProtoOption

ProtoOneOfNodeTypes = (
ProtoOption | ProtoMessageField | ProtoSingleLineComment | ProtoMultiLineComment
Expand Down
6 changes: 3 additions & 3 deletions src/proto_option.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Optional, Sequence

from src.proto_constant import ProtoConstant
from src.proto_identifier import (
from .proto_constant import ProtoConstant
from .proto_identifier import (
ProtoEnumOrMessageIdentifier,
ProtoFullIdentifier,
ProtoIdentifier,
)
from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff


class ParsedProtoOptionNode(ParsedProtoNode):
Expand Down
2 changes: 1 addition & 1 deletion src/proto_package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from src.proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff
from .proto_node import ParsedProtoNode, ProtoNode, ProtoNodeDiff


class ProtoPackage(ProtoNode):
Expand Down
4 changes: 2 additions & 2 deletions src/proto_range.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from typing import Optional

from src.proto_int import ProtoInt, ProtoIntSign
from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_int import ProtoInt, ProtoIntSign
from .proto_node import ParsedProtoNode, ProtoNode


class ParsedProtoRangeNode(ParsedProtoNode):
Expand Down
6 changes: 3 additions & 3 deletions src/proto_reserved.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional

from src.proto_identifier import ProtoIdentifier
from src.proto_node import ParsedProtoNode, ProtoNode
from src.proto_range import ProtoRange
from .proto_identifier import ProtoIdentifier
from .proto_node import ParsedProtoNode, ProtoNode
from .proto_range import ProtoRange


class ProtoReservedFieldQuoteEnum(Enum):
Expand Down
8 changes: 4 additions & 4 deletions src/proto_service.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Optional

from src.proto_comment import (
from .proto_comment import (
ProtoComment,
ProtoMultiLineComment,
ProtoSingleLineComment,
)
from src.proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from src.proto_node import ParsedProtoNode, ProtoNode
from src.proto_option import ProtoOption
from .proto_identifier import ProtoEnumOrMessageIdentifier, ProtoIdentifier
from .proto_node import ParsedProtoNode, ProtoNode
from .proto_option import ProtoOption


class ProtoServiceRPC(ProtoNode):
Expand Down
2 changes: 1 addition & 1 deletion src/proto_string_literal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from src.proto_node import ParsedProtoNode, ProtoNode
from .proto_node import ParsedProtoNode, ProtoNode


class ParsedProtoStringLiteralNode(ParsedProtoNode):
Expand Down
Loading

0 comments on commit 283f76e

Please sign in to comment.