From f9fa1184a054a7aaad45b291b9c2e22b17ecd35e Mon Sep 17 00:00:00 2001 From: tzijnge Date: Sun, 13 Oct 2024 21:03:04 +0200 Subject: [PATCH 1/7] #24 Use PyProject.toml * Migrated from setup.py to pyproject.toml --- package/pyproject.toml | 77 ++++++++++++++++++++++++++++++++++++++++++ package/setup.py | 25 -------------- pyproject.toml | 27 --------------- 3 files changed, 77 insertions(+), 52 deletions(-) create mode 100644 package/pyproject.toml delete mode 100644 package/setup.py delete mode 100644 pyproject.toml diff --git a/package/pyproject.toml b/package/pyproject.toml new file mode 100644 index 0000000..43dc287 --- /dev/null +++ b/package/pyproject.toml @@ -0,0 +1,77 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "lrpc" +version = "0.1.0" +description = "A code generator for remote procedure calls on embedded systems" +readme = "README.md" +requires-python = ">=3.9" +license = { text = "MIT" } +authors = [{ name = "T Zijnge", email = "tzijnge@example.com" }] +keywords = ["code generation", "embedded systems", "rpc"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Embedded Systems", +] +dependencies = [ + "code-generation==2.3.0", + "pyyaml==6.0.2", + "jsonschema==4.23.0", + "click==8.1.7", +] + +[project.urls] +homepage = "https://github.com/tzijnge/LotusRpc" +"Bug Tracker" = "https://github.com/tzijnge/LotusRpc/issues" +"Documentation" = "https://github.com/tzijnge/LotusRpc/wiki" +"Source Code" = "https://github.com/tzijnge/LotusRpc" + +[project.optional-dependencies] +serial = ["pyserial==3.5"] + +[project.scripts] +lotusrpc = "lrpc.lotusrpc:generate" +lrpcc = "lrpc.lrpcc:run_cli" + +[tool.setuptools.package-data] +"lrpc.schema" = ["lotusrpc-schema.json"] + +[tool.setuptools] +include-package-data = true + +[tool.black] +line-length = 120 + +[tool.pylint] +disable = [ + "missing-class-docstring", + "missing-function-docstring", + "missing-module-docstring", +] + +[tool.pylint.format] +# line length is handled by black. Any remaining long lines cannot be formatted properly +disable = ["line-too-long"] +allow-reexport-from-package = true + +[tool.mypy] +exclude = "external" +strict = true +# Increase strictness of checks +disallow_any_decorated = true +strict_optional = true +warn_no_return = true +warn_unreachable = true + +# Display statistics after running +# dump_type_stats = true +# dump_inference_stats = true diff --git a/package/setup.py b/package/setup.py deleted file mode 100644 index 81415c5..0000000 --- a/package/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -from setuptools import setup, find_packages - -with open("README", mode="r", encoding="utf-8") as f: - long_description = f.read() - -setup( - python_requires=">3.9", - name="lrpc", - version="0.1.0", - description="A code generator for remote procedure calls on embedded systems", - license="MIT", - long_description=long_description, - author="T Zijnge", - author_email="tzijnge@example.com", - url="https://github.com/tzijnge/LotusRpc", - packages=find_packages(), - package_data={"lrpc.schema": ["lotusrpc-schema.json"]}, - include_package_data=True, - install_requires=["click", "code-generation", "pyyaml", "jsonschema", "pyserial"], - entry_points=""" - [console_scripts] - lotusrpc=lrpc.lotusrpc:generate - lrpcc=lrpc.lrpcc:run_cli - """, -) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 3f8e4e7..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,27 +0,0 @@ -[tool.black] -line-length = 120 - -[tool.pylint] -disable = [ - "missing-class-docstring", - "missing-function-docstring", - "missing-module-docstring", -] - -[tool.pylint.format] -# line length is handled by black. Any remaining long lines cannot be formatted properly -disable = ["line-too-long"] -allow-reexport-from-package = true - -[tool.mypy] -exclude = "external" -strict = true -# Increase strictness of checks -disallow_any_decorated = true -strict_optional = true -warn_no_return = true -warn_unreachable = true - -# Display statistics after running -# dump_type_stats = true -# dump_inference_stats = true From fe62b16659bff00b3597a4000c6791b619e1517c Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 12:45:10 +0200 Subject: [PATCH 2/7] #24 Use PyProject.toml * Update pyproject.toml * renamed script lotuspc to lrpcg * Moved some files around --- {package/lrpc => lrpc}/__init__.py | 0 {package/lrpc => lrpc}/client/__init__.py | 0 .../client/client_cli_visitor.py | 0 {package/lrpc => lrpc}/client/decoder.py | 0 {package/lrpc => lrpc}/client/encoder.py | 0 {package/lrpc => lrpc}/client/lrpc_client.py | 0 {package/lrpc => lrpc}/codegen/__init__.py | 0 {package/lrpc => lrpc}/codegen/common.py | 0 {package/lrpc => lrpc}/codegen/constants.py | 0 {package/lrpc => lrpc}/codegen/enum.py | 0 .../lrpc => lrpc}/codegen/server_include.py | 0 .../lrpc => lrpc}/codegen/service_include.py | 0 .../lrpc => lrpc}/codegen/service_shim.py | 0 {package/lrpc => lrpc}/codegen/struct.py | 0 {package/lrpc => lrpc}/codegen/utils.py | 0 {package/lrpc => lrpc}/core/__init__.py | 0 {package/lrpc => lrpc}/core/constant.py | 0 {package/lrpc => lrpc}/core/definition.py | 0 {package/lrpc => lrpc}/core/enum.py | 0 {package/lrpc => lrpc}/core/function.py | 0 {package/lrpc => lrpc}/core/service.py | 0 {package/lrpc => lrpc}/core/struct.py | 0 {package/lrpc => lrpc}/core/var.py | 0 {package/lrpc => lrpc}/lrpcc.py | 0 package/lrpc/lotusrpc.py => lrpc/lrpcg.py | 4 +-- {package/lrpc => lrpc}/schema/__init__.py | 0 {package/lrpc => lrpc}/schema/load.py | 2 +- .../lrpc => lrpc}/schema/lotusrpc-schema.json | 0 {package/lrpc => lrpc}/utils/__init__.py | 0 .../lrpc => lrpc}/utils/load_definition.py | 0 {package/lrpc => lrpc}/validation/__init__.py | 0 .../lrpc => lrpc}/validation/custom_types.py | 0 {package/lrpc => lrpc}/validation/enum.py | 0 {package/lrpc => lrpc}/validation/function.py | 0 {package/lrpc => lrpc}/validation/names.py | 0 .../validation/semantic_analyzer.py | 0 {package/lrpc => lrpc}/validation/service.py | 0 .../lrpc => lrpc}/validation/validator.py | 0 {package/lrpc => lrpc}/visitors/__init__.py | 0 .../lrpc => lrpc}/visitors/lrpc_visitor.py | 0 .../lrpc => lrpc}/visitors/puml_visitor.py | 0 package/README | 1 - package/pyproject.toml => pyproject.toml | 18 +++++------ .../cpp/include/lrpc/EtlRwExtensions.hpp | 0 .../cpp/include/lrpc/Server.hpp | 0 .../cpp/include/lrpc/Service.hpp | 0 .../cpp/tests => tests/cpp}/CMakeLists.txt | 30 +++++++++---------- .../cpp}/TestEtlRwExtensions.cpp | 0 .../cpp/tests => tests/cpp}/TestServer1.cpp | 0 .../tests => tests/cpp}/TestServer2_s0.cpp | 0 .../tests => tests/cpp}/TestServer2_s1.cpp | 0 .../cpp/tests => tests/cpp}/TestServer3.cpp | 0 .../cpp/tests => tests/cpp}/TestServer4.cpp | 0 .../cpp/tests => tests/cpp}/etl_profile.h | 0 .../tests => tests/cpp}/ext_files/MyEnum2.hpp | 0 .../tests => tests/cpp}/ext_files/MyEnum3.hpp | 0 .../cpp}/ext_files/MyStruct1.hpp | 0 .../cpp}/ext_files/MyStruct2.hpp | 0 {package/tests => tests/python}/__init__.py | 0 .../python}/test_lrpc_client.py | 0 .../python}/test_lrpc_constant.py | 0 .../python}/test_lrpc_decode.py | 0 .../tests => tests/python}/test_lrpc_def.py | 0 .../python}/test_lrpc_encode.py | 0 .../python}/test_lrpc_encode_decode.lrpc.yaml | 0 .../python}/test_lrpc_encode_decode.py | 0 .../tests => tests/python}/test_lrpc_enum.py | 0 .../tests => tests/python}/test_lrpc_fun.py | 0 .../python}/test_lrpc_service.py | 0 .../python}/test_lrpc_struct.py | 0 .../tests => tests/python}/test_lrpc_var.py | 0 .../tests => tests/python}/test_schema.py | 0 .../testdata}/TestServer1.lrpc.yaml | 0 .../testdata}/TestServer2.lrpc.yaml | 0 .../testdata}/TestServer3.lrpc.yaml | 0 .../testdata}/TestServer4.lrpc.yaml | 0 76 files changed, 26 insertions(+), 29 deletions(-) rename {package/lrpc => lrpc}/__init__.py (100%) rename {package/lrpc => lrpc}/client/__init__.py (100%) rename {package/lrpc => lrpc}/client/client_cli_visitor.py (100%) rename {package/lrpc => lrpc}/client/decoder.py (100%) rename {package/lrpc => lrpc}/client/encoder.py (100%) rename {package/lrpc => lrpc}/client/lrpc_client.py (100%) rename {package/lrpc => lrpc}/codegen/__init__.py (100%) rename {package/lrpc => lrpc}/codegen/common.py (100%) rename {package/lrpc => lrpc}/codegen/constants.py (100%) rename {package/lrpc => lrpc}/codegen/enum.py (100%) rename {package/lrpc => lrpc}/codegen/server_include.py (100%) rename {package/lrpc => lrpc}/codegen/service_include.py (100%) rename {package/lrpc => lrpc}/codegen/service_shim.py (100%) rename {package/lrpc => lrpc}/codegen/struct.py (100%) rename {package/lrpc => lrpc}/codegen/utils.py (100%) rename {package/lrpc => lrpc}/core/__init__.py (100%) rename {package/lrpc => lrpc}/core/constant.py (100%) rename {package/lrpc => lrpc}/core/definition.py (100%) rename {package/lrpc => lrpc}/core/enum.py (100%) rename {package/lrpc => lrpc}/core/function.py (100%) rename {package/lrpc => lrpc}/core/service.py (100%) rename {package/lrpc => lrpc}/core/struct.py (100%) rename {package/lrpc => lrpc}/core/var.py (100%) rename {package/lrpc => lrpc}/lrpcc.py (100%) rename package/lrpc/lotusrpc.py => lrpc/lrpcg.py (92%) rename {package/lrpc => lrpc}/schema/__init__.py (100%) rename {package/lrpc => lrpc}/schema/load.py (83%) rename {package/lrpc => lrpc}/schema/lotusrpc-schema.json (100%) rename {package/lrpc => lrpc}/utils/__init__.py (100%) rename {package/lrpc => lrpc}/utils/load_definition.py (100%) rename {package/lrpc => lrpc}/validation/__init__.py (100%) rename {package/lrpc => lrpc}/validation/custom_types.py (100%) rename {package/lrpc => lrpc}/validation/enum.py (100%) rename {package/lrpc => lrpc}/validation/function.py (100%) rename {package/lrpc => lrpc}/validation/names.py (100%) rename {package/lrpc => lrpc}/validation/semantic_analyzer.py (100%) rename {package/lrpc => lrpc}/validation/service.py (100%) rename {package/lrpc => lrpc}/validation/validator.py (100%) rename {package/lrpc => lrpc}/visitors/__init__.py (100%) rename {package/lrpc => lrpc}/visitors/lrpc_visitor.py (100%) rename {package/lrpc => lrpc}/visitors/puml_visitor.py (100%) delete mode 100644 package/README rename package/pyproject.toml => pyproject.toml (83%) rename {language => resources}/cpp/include/lrpc/EtlRwExtensions.hpp (100%) rename {language => resources}/cpp/include/lrpc/Server.hpp (100%) rename {language => resources}/cpp/include/lrpc/Service.hpp (100%) rename {language/cpp/tests => tests/cpp}/CMakeLists.txt (56%) rename {language/cpp/tests => tests/cpp}/TestEtlRwExtensions.cpp (100%) rename {language/cpp/tests => tests/cpp}/TestServer1.cpp (100%) rename {language/cpp/tests => tests/cpp}/TestServer2_s0.cpp (100%) rename {language/cpp/tests => tests/cpp}/TestServer2_s1.cpp (100%) rename {language/cpp/tests => tests/cpp}/TestServer3.cpp (100%) rename {language/cpp/tests => tests/cpp}/TestServer4.cpp (100%) rename {language/cpp/tests => tests/cpp}/etl_profile.h (100%) rename {language/cpp/tests => tests/cpp}/ext_files/MyEnum2.hpp (100%) rename {language/cpp/tests => tests/cpp}/ext_files/MyEnum3.hpp (100%) rename {language/cpp/tests => tests/cpp}/ext_files/MyStruct1.hpp (100%) rename {language/cpp/tests => tests/cpp}/ext_files/MyStruct2.hpp (100%) rename {package/tests => tests/python}/__init__.py (100%) rename {package/tests => tests/python}/test_lrpc_client.py (100%) rename {package/tests => tests/python}/test_lrpc_constant.py (100%) rename {package/tests => tests/python}/test_lrpc_decode.py (100%) rename {package/tests => tests/python}/test_lrpc_def.py (100%) rename {package/tests => tests/python}/test_lrpc_encode.py (100%) rename {package/tests => tests/python}/test_lrpc_encode_decode.lrpc.yaml (100%) rename {package/tests => tests/python}/test_lrpc_encode_decode.py (100%) rename {package/tests => tests/python}/test_lrpc_enum.py (100%) rename {package/tests => tests/python}/test_lrpc_fun.py (100%) rename {package/tests => tests/python}/test_lrpc_service.py (100%) rename {package/tests => tests/python}/test_lrpc_struct.py (100%) rename {package/tests => tests/python}/test_lrpc_var.py (100%) rename {package/tests => tests/python}/test_schema.py (100%) rename {testdata => tests/testdata}/TestServer1.lrpc.yaml (100%) rename {testdata => tests/testdata}/TestServer2.lrpc.yaml (100%) rename {testdata => tests/testdata}/TestServer3.lrpc.yaml (100%) rename {testdata => tests/testdata}/TestServer4.lrpc.yaml (100%) diff --git a/package/lrpc/__init__.py b/lrpc/__init__.py similarity index 100% rename from package/lrpc/__init__.py rename to lrpc/__init__.py diff --git a/package/lrpc/client/__init__.py b/lrpc/client/__init__.py similarity index 100% rename from package/lrpc/client/__init__.py rename to lrpc/client/__init__.py diff --git a/package/lrpc/client/client_cli_visitor.py b/lrpc/client/client_cli_visitor.py similarity index 100% rename from package/lrpc/client/client_cli_visitor.py rename to lrpc/client/client_cli_visitor.py diff --git a/package/lrpc/client/decoder.py b/lrpc/client/decoder.py similarity index 100% rename from package/lrpc/client/decoder.py rename to lrpc/client/decoder.py diff --git a/package/lrpc/client/encoder.py b/lrpc/client/encoder.py similarity index 100% rename from package/lrpc/client/encoder.py rename to lrpc/client/encoder.py diff --git a/package/lrpc/client/lrpc_client.py b/lrpc/client/lrpc_client.py similarity index 100% rename from package/lrpc/client/lrpc_client.py rename to lrpc/client/lrpc_client.py diff --git a/package/lrpc/codegen/__init__.py b/lrpc/codegen/__init__.py similarity index 100% rename from package/lrpc/codegen/__init__.py rename to lrpc/codegen/__init__.py diff --git a/package/lrpc/codegen/common.py b/lrpc/codegen/common.py similarity index 100% rename from package/lrpc/codegen/common.py rename to lrpc/codegen/common.py diff --git a/package/lrpc/codegen/constants.py b/lrpc/codegen/constants.py similarity index 100% rename from package/lrpc/codegen/constants.py rename to lrpc/codegen/constants.py diff --git a/package/lrpc/codegen/enum.py b/lrpc/codegen/enum.py similarity index 100% rename from package/lrpc/codegen/enum.py rename to lrpc/codegen/enum.py diff --git a/package/lrpc/codegen/server_include.py b/lrpc/codegen/server_include.py similarity index 100% rename from package/lrpc/codegen/server_include.py rename to lrpc/codegen/server_include.py diff --git a/package/lrpc/codegen/service_include.py b/lrpc/codegen/service_include.py similarity index 100% rename from package/lrpc/codegen/service_include.py rename to lrpc/codegen/service_include.py diff --git a/package/lrpc/codegen/service_shim.py b/lrpc/codegen/service_shim.py similarity index 100% rename from package/lrpc/codegen/service_shim.py rename to lrpc/codegen/service_shim.py diff --git a/package/lrpc/codegen/struct.py b/lrpc/codegen/struct.py similarity index 100% rename from package/lrpc/codegen/struct.py rename to lrpc/codegen/struct.py diff --git a/package/lrpc/codegen/utils.py b/lrpc/codegen/utils.py similarity index 100% rename from package/lrpc/codegen/utils.py rename to lrpc/codegen/utils.py diff --git a/package/lrpc/core/__init__.py b/lrpc/core/__init__.py similarity index 100% rename from package/lrpc/core/__init__.py rename to lrpc/core/__init__.py diff --git a/package/lrpc/core/constant.py b/lrpc/core/constant.py similarity index 100% rename from package/lrpc/core/constant.py rename to lrpc/core/constant.py diff --git a/package/lrpc/core/definition.py b/lrpc/core/definition.py similarity index 100% rename from package/lrpc/core/definition.py rename to lrpc/core/definition.py diff --git a/package/lrpc/core/enum.py b/lrpc/core/enum.py similarity index 100% rename from package/lrpc/core/enum.py rename to lrpc/core/enum.py diff --git a/package/lrpc/core/function.py b/lrpc/core/function.py similarity index 100% rename from package/lrpc/core/function.py rename to lrpc/core/function.py diff --git a/package/lrpc/core/service.py b/lrpc/core/service.py similarity index 100% rename from package/lrpc/core/service.py rename to lrpc/core/service.py diff --git a/package/lrpc/core/struct.py b/lrpc/core/struct.py similarity index 100% rename from package/lrpc/core/struct.py rename to lrpc/core/struct.py diff --git a/package/lrpc/core/var.py b/lrpc/core/var.py similarity index 100% rename from package/lrpc/core/var.py rename to lrpc/core/var.py diff --git a/package/lrpc/lrpcc.py b/lrpc/lrpcc.py similarity index 100% rename from package/lrpc/lrpcc.py rename to lrpc/lrpcc.py diff --git a/package/lrpc/lotusrpc.py b/lrpc/lrpcg.py similarity index 92% rename from package/lrpc/lotusrpc.py rename to lrpc/lrpcg.py index ef84504..b64d5a8 100644 --- a/package/lrpc/lotusrpc.py +++ b/lrpc/lrpcg.py @@ -41,7 +41,7 @@ def generate_rpc(lrpc_def: LrpcDef, output: os.PathLike[str]) -> None: ) @click.option("-o", "--output", help="Path to put the generated files", required=False, default=".", type=click.Path()) @click.argument("input_file", type=click.File("r"), metavar="input") -def generate(warnings_as_errors: bool, output: os.PathLike[str], input_file: TextIO) -> None: +def run_cli(warnings_as_errors: bool, output: os.PathLike[str], input_file: TextIO) -> None: """Generate code for file INPUT""" try: @@ -59,4 +59,4 @@ def generate(warnings_as_errors: bool, output: os.PathLike[str], input_file: Tex if __name__ == "__main__": # parameters are inserted by Click # pylint: disable=no-value-for-parameter - generate() + run_cli() diff --git a/package/lrpc/schema/__init__.py b/lrpc/schema/__init__.py similarity index 100% rename from package/lrpc/schema/__init__.py rename to lrpc/schema/__init__.py diff --git a/package/lrpc/schema/load.py b/lrpc/schema/load.py similarity index 83% rename from package/lrpc/schema/load.py rename to lrpc/schema/load.py index 07733bb..01048f7 100644 --- a/package/lrpc/schema/load.py +++ b/lrpc/schema/load.py @@ -6,7 +6,7 @@ def load_lrpc_schema() -> dict[str, Any]: schema_file = resources.files(__package__).joinpath("lotusrpc-schema.json") - schema_text = schema_file.read_text() + schema_text = schema_file.read_text(encoding="utf-8") schema = yaml.safe_load(schema_text) if not isinstance(schema, dict): diff --git a/package/lrpc/schema/lotusrpc-schema.json b/lrpc/schema/lotusrpc-schema.json similarity index 100% rename from package/lrpc/schema/lotusrpc-schema.json rename to lrpc/schema/lotusrpc-schema.json diff --git a/package/lrpc/utils/__init__.py b/lrpc/utils/__init__.py similarity index 100% rename from package/lrpc/utils/__init__.py rename to lrpc/utils/__init__.py diff --git a/package/lrpc/utils/load_definition.py b/lrpc/utils/load_definition.py similarity index 100% rename from package/lrpc/utils/load_definition.py rename to lrpc/utils/load_definition.py diff --git a/package/lrpc/validation/__init__.py b/lrpc/validation/__init__.py similarity index 100% rename from package/lrpc/validation/__init__.py rename to lrpc/validation/__init__.py diff --git a/package/lrpc/validation/custom_types.py b/lrpc/validation/custom_types.py similarity index 100% rename from package/lrpc/validation/custom_types.py rename to lrpc/validation/custom_types.py diff --git a/package/lrpc/validation/enum.py b/lrpc/validation/enum.py similarity index 100% rename from package/lrpc/validation/enum.py rename to lrpc/validation/enum.py diff --git a/package/lrpc/validation/function.py b/lrpc/validation/function.py similarity index 100% rename from package/lrpc/validation/function.py rename to lrpc/validation/function.py diff --git a/package/lrpc/validation/names.py b/lrpc/validation/names.py similarity index 100% rename from package/lrpc/validation/names.py rename to lrpc/validation/names.py diff --git a/package/lrpc/validation/semantic_analyzer.py b/lrpc/validation/semantic_analyzer.py similarity index 100% rename from package/lrpc/validation/semantic_analyzer.py rename to lrpc/validation/semantic_analyzer.py diff --git a/package/lrpc/validation/service.py b/lrpc/validation/service.py similarity index 100% rename from package/lrpc/validation/service.py rename to lrpc/validation/service.py diff --git a/package/lrpc/validation/validator.py b/lrpc/validation/validator.py similarity index 100% rename from package/lrpc/validation/validator.py rename to lrpc/validation/validator.py diff --git a/package/lrpc/visitors/__init__.py b/lrpc/visitors/__init__.py similarity index 100% rename from package/lrpc/visitors/__init__.py rename to lrpc/visitors/__init__.py diff --git a/package/lrpc/visitors/lrpc_visitor.py b/lrpc/visitors/lrpc_visitor.py similarity index 100% rename from package/lrpc/visitors/lrpc_visitor.py rename to lrpc/visitors/lrpc_visitor.py diff --git a/package/lrpc/visitors/puml_visitor.py b/lrpc/visitors/puml_visitor.py similarity index 100% rename from package/lrpc/visitors/puml_visitor.py rename to lrpc/visitors/puml_visitor.py diff --git a/package/README b/package/README deleted file mode 100644 index 4202bfb..0000000 --- a/package/README +++ /dev/null @@ -1 +0,0 @@ -LotusRPC python package \ No newline at end of file diff --git a/package/pyproject.toml b/pyproject.toml similarity index 83% rename from package/pyproject.toml rename to pyproject.toml index 43dc287..7cb3b75 100644 --- a/package/pyproject.toml +++ b/pyproject.toml @@ -8,17 +8,16 @@ version = "0.1.0" description = "A code generator for remote procedure calls on embedded systems" readme = "README.md" requires-python = ">=3.9" -license = { text = "MIT" } -authors = [{ name = "T Zijnge", email = "tzijnge@example.com" }] +license = { file = "LICENSE" } +authors = [{ name = "T Zijnge" }] keywords = ["code generation", "embedded systems", "rpc"] classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", - "Programming Language :: Python", + "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", + "Programming Language :: C++", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Embedded Systems", ] @@ -29,17 +28,17 @@ dependencies = [ "click==8.1.7", ] +[project.optional-dependencies] +serial = ["pyserial==3.5"] + [project.urls] homepage = "https://github.com/tzijnge/LotusRpc" "Bug Tracker" = "https://github.com/tzijnge/LotusRpc/issues" "Documentation" = "https://github.com/tzijnge/LotusRpc/wiki" "Source Code" = "https://github.com/tzijnge/LotusRpc" -[project.optional-dependencies] -serial = ["pyserial==3.5"] - [project.scripts] -lotusrpc = "lrpc.lotusrpc:generate" +lrpcg = "lrpc.lrpcg:run_cli" lrpcc = "lrpc.lrpcc:run_cli" [tool.setuptools.package-data] @@ -64,7 +63,6 @@ disable = ["line-too-long"] allow-reexport-from-package = true [tool.mypy] -exclude = "external" strict = true # Increase strictness of checks disallow_any_decorated = true diff --git a/language/cpp/include/lrpc/EtlRwExtensions.hpp b/resources/cpp/include/lrpc/EtlRwExtensions.hpp similarity index 100% rename from language/cpp/include/lrpc/EtlRwExtensions.hpp rename to resources/cpp/include/lrpc/EtlRwExtensions.hpp diff --git a/language/cpp/include/lrpc/Server.hpp b/resources/cpp/include/lrpc/Server.hpp similarity index 100% rename from language/cpp/include/lrpc/Server.hpp rename to resources/cpp/include/lrpc/Server.hpp diff --git a/language/cpp/include/lrpc/Service.hpp b/resources/cpp/include/lrpc/Service.hpp similarity index 100% rename from language/cpp/include/lrpc/Service.hpp rename to resources/cpp/include/lrpc/Service.hpp diff --git a/language/cpp/tests/CMakeLists.txt b/tests/cpp/CMakeLists.txt similarity index 56% rename from language/cpp/tests/CMakeLists.txt rename to tests/cpp/CMakeLists.txt index d6dbc9a..a922350 100644 --- a/language/cpp/tests/CMakeLists.txt +++ b/tests/cpp/CMakeLists.txt @@ -12,31 +12,31 @@ mark_as_advanced( gtest_hide_internal_symbols ) -add_subdirectory(../../../external/gtest External/gtest EXCLUDE_FROM_ALL) +add_subdirectory(../../external/gtest External/gtest EXCLUDE_FROM_ALL) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server1/Server1.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/package + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generate TestServer1 LRPC files" - DEPENDS ${CMAKE_SOURCE_DIR}/testdata/TestServer1.lrpc.yaml - COMMAND python -m lrpc.lotusrpc -w ${CMAKE_SOURCE_DIR}/testdata/TestServer1.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server1) + DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer1.lrpc.yaml + COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer1.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server1) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server2/Server2.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/package + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generate TestServer2 LRPC files" - DEPENDS ${CMAKE_SOURCE_DIR}/testdata/TestServer2.lrpc.yaml - COMMAND python -m lrpc.lotusrpc -w ${CMAKE_SOURCE_DIR}/testdata/TestServer2.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server2) + DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer2.lrpc.yaml + COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer2.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server2) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server3/Server3.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/package + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generate TestServer3 LRPC files" - DEPENDS ${CMAKE_SOURCE_DIR}/testdata/TestServer3.lrpc.yaml - COMMAND python -m lrpc.lotusrpc -w ${CMAKE_SOURCE_DIR}/testdata/TestServer3.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server3) + DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer3.lrpc.yaml + COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer3.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server3) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4/Server4.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/package + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Generate TestServer4 LRPC files" - DEPENDS ${CMAKE_SOURCE_DIR}/testdata/TestServer4.lrpc.yaml - COMMAND python -m lrpc.lotusrpc -w ${CMAKE_SOURCE_DIR}/testdata/TestServer4.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4) + DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer4.lrpc.yaml + COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer4.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4) set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/generated) @@ -53,8 +53,8 @@ add_executable(UnitTests ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4/Server4.hpp) target_include_directories(UnitTests PRIVATE .) -target_include_directories(UnitTests PRIVATE ../include) -target_include_directories(UnitTests SYSTEM PRIVATE ../../../external/etl/include) +target_include_directories(UnitTests PRIVATE ${CMAKE_SOURCE_DIR}/resources/cpp/include) +target_include_directories(UnitTests SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/external/etl/include) if(MSVC) target_compile_options(UnitTests PRIVATE /W4) diff --git a/language/cpp/tests/TestEtlRwExtensions.cpp b/tests/cpp/TestEtlRwExtensions.cpp similarity index 100% rename from language/cpp/tests/TestEtlRwExtensions.cpp rename to tests/cpp/TestEtlRwExtensions.cpp diff --git a/language/cpp/tests/TestServer1.cpp b/tests/cpp/TestServer1.cpp similarity index 100% rename from language/cpp/tests/TestServer1.cpp rename to tests/cpp/TestServer1.cpp diff --git a/language/cpp/tests/TestServer2_s0.cpp b/tests/cpp/TestServer2_s0.cpp similarity index 100% rename from language/cpp/tests/TestServer2_s0.cpp rename to tests/cpp/TestServer2_s0.cpp diff --git a/language/cpp/tests/TestServer2_s1.cpp b/tests/cpp/TestServer2_s1.cpp similarity index 100% rename from language/cpp/tests/TestServer2_s1.cpp rename to tests/cpp/TestServer2_s1.cpp diff --git a/language/cpp/tests/TestServer3.cpp b/tests/cpp/TestServer3.cpp similarity index 100% rename from language/cpp/tests/TestServer3.cpp rename to tests/cpp/TestServer3.cpp diff --git a/language/cpp/tests/TestServer4.cpp b/tests/cpp/TestServer4.cpp similarity index 100% rename from language/cpp/tests/TestServer4.cpp rename to tests/cpp/TestServer4.cpp diff --git a/language/cpp/tests/etl_profile.h b/tests/cpp/etl_profile.h similarity index 100% rename from language/cpp/tests/etl_profile.h rename to tests/cpp/etl_profile.h diff --git a/language/cpp/tests/ext_files/MyEnum2.hpp b/tests/cpp/ext_files/MyEnum2.hpp similarity index 100% rename from language/cpp/tests/ext_files/MyEnum2.hpp rename to tests/cpp/ext_files/MyEnum2.hpp diff --git a/language/cpp/tests/ext_files/MyEnum3.hpp b/tests/cpp/ext_files/MyEnum3.hpp similarity index 100% rename from language/cpp/tests/ext_files/MyEnum3.hpp rename to tests/cpp/ext_files/MyEnum3.hpp diff --git a/language/cpp/tests/ext_files/MyStruct1.hpp b/tests/cpp/ext_files/MyStruct1.hpp similarity index 100% rename from language/cpp/tests/ext_files/MyStruct1.hpp rename to tests/cpp/ext_files/MyStruct1.hpp diff --git a/language/cpp/tests/ext_files/MyStruct2.hpp b/tests/cpp/ext_files/MyStruct2.hpp similarity index 100% rename from language/cpp/tests/ext_files/MyStruct2.hpp rename to tests/cpp/ext_files/MyStruct2.hpp diff --git a/package/tests/__init__.py b/tests/python/__init__.py similarity index 100% rename from package/tests/__init__.py rename to tests/python/__init__.py diff --git a/package/tests/test_lrpc_client.py b/tests/python/test_lrpc_client.py similarity index 100% rename from package/tests/test_lrpc_client.py rename to tests/python/test_lrpc_client.py diff --git a/package/tests/test_lrpc_constant.py b/tests/python/test_lrpc_constant.py similarity index 100% rename from package/tests/test_lrpc_constant.py rename to tests/python/test_lrpc_constant.py diff --git a/package/tests/test_lrpc_decode.py b/tests/python/test_lrpc_decode.py similarity index 100% rename from package/tests/test_lrpc_decode.py rename to tests/python/test_lrpc_decode.py diff --git a/package/tests/test_lrpc_def.py b/tests/python/test_lrpc_def.py similarity index 100% rename from package/tests/test_lrpc_def.py rename to tests/python/test_lrpc_def.py diff --git a/package/tests/test_lrpc_encode.py b/tests/python/test_lrpc_encode.py similarity index 100% rename from package/tests/test_lrpc_encode.py rename to tests/python/test_lrpc_encode.py diff --git a/package/tests/test_lrpc_encode_decode.lrpc.yaml b/tests/python/test_lrpc_encode_decode.lrpc.yaml similarity index 100% rename from package/tests/test_lrpc_encode_decode.lrpc.yaml rename to tests/python/test_lrpc_encode_decode.lrpc.yaml diff --git a/package/tests/test_lrpc_encode_decode.py b/tests/python/test_lrpc_encode_decode.py similarity index 100% rename from package/tests/test_lrpc_encode_decode.py rename to tests/python/test_lrpc_encode_decode.py diff --git a/package/tests/test_lrpc_enum.py b/tests/python/test_lrpc_enum.py similarity index 100% rename from package/tests/test_lrpc_enum.py rename to tests/python/test_lrpc_enum.py diff --git a/package/tests/test_lrpc_fun.py b/tests/python/test_lrpc_fun.py similarity index 100% rename from package/tests/test_lrpc_fun.py rename to tests/python/test_lrpc_fun.py diff --git a/package/tests/test_lrpc_service.py b/tests/python/test_lrpc_service.py similarity index 100% rename from package/tests/test_lrpc_service.py rename to tests/python/test_lrpc_service.py diff --git a/package/tests/test_lrpc_struct.py b/tests/python/test_lrpc_struct.py similarity index 100% rename from package/tests/test_lrpc_struct.py rename to tests/python/test_lrpc_struct.py diff --git a/package/tests/test_lrpc_var.py b/tests/python/test_lrpc_var.py similarity index 100% rename from package/tests/test_lrpc_var.py rename to tests/python/test_lrpc_var.py diff --git a/package/tests/test_schema.py b/tests/python/test_schema.py similarity index 100% rename from package/tests/test_schema.py rename to tests/python/test_schema.py diff --git a/testdata/TestServer1.lrpc.yaml b/tests/testdata/TestServer1.lrpc.yaml similarity index 100% rename from testdata/TestServer1.lrpc.yaml rename to tests/testdata/TestServer1.lrpc.yaml diff --git a/testdata/TestServer2.lrpc.yaml b/tests/testdata/TestServer2.lrpc.yaml similarity index 100% rename from testdata/TestServer2.lrpc.yaml rename to tests/testdata/TestServer2.lrpc.yaml diff --git a/testdata/TestServer3.lrpc.yaml b/tests/testdata/TestServer3.lrpc.yaml similarity index 100% rename from testdata/TestServer3.lrpc.yaml rename to tests/testdata/TestServer3.lrpc.yaml diff --git a/testdata/TestServer4.lrpc.yaml b/tests/testdata/TestServer4.lrpc.yaml similarity index 100% rename from testdata/TestServer4.lrpc.yaml rename to tests/testdata/TestServer4.lrpc.yaml From 5b55b5c4983caeef039ed9f24d7c75e2b6602363 Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 12:46:15 +0200 Subject: [PATCH 3/7] #24 Use PyProject.toml * Update .gitignore * Update cmake --- .github/workflows/cmake.yml | 4 ++-- .gitignore | 3 ++- CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b6a8ea5..d4f3e10 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -45,8 +45,8 @@ jobs: working-directory: package run: pip install . - - name: Run lotusrpc - run: lotusrpc --help + - name: Run lotusrpc generator + run: lrpcg --help - name: Run LRPC client CLI run: lrpcc --help diff --git a/.gitignore b/.gitignore index fa47ba6..262d80b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ build .vscode **/__pycache__/**/*.* -/language/cpp/tests/generated +/tests/cpp/generated +/VENV diff --git a/CMakeLists.txt b/CMakeLists.txt index e8514e1..7e43826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0.0) enable_testing() -add_subdirectory(language/cpp/tests) \ No newline at end of file +add_subdirectory(tests/cpp) \ No newline at end of file From 8de9c66a7dc9c06d58779630e137761822565b94 Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 12:51:41 +0200 Subject: [PATCH 4/7] #24 Use PyProject.toml * Update cmake.yml --- .github/workflows/cmake.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d4f3e10..63207f7 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -39,10 +39,9 @@ jobs: run: ctest -C ${{env.BUILD_TYPE}} --output-junit ../testresults/cpptestresults.xml - name: Python tests - run: pytest package/tests -v --junitxml=testresults/pytestresults.xml + run: pytest tests/python -v --junitxml=testresults/pytestresults.xml - name: Install LRPC Python package - working-directory: package run: pip install . - name: Run lotusrpc generator From 039c89df4a90bb8b8a69aa02ee738e5edaa9dcfd Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 13:13:09 +0200 Subject: [PATCH 5/7] #24 Use PyProject.toml * Update pyproject.toml --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 7cb3b75..a09024e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,10 @@ lrpcc = "lrpc.lrpcc:run_cli" [tool.setuptools] include-package-data = true +packages = ["lrpc"] + +[tool.pytest.ini_options] +pythonpath = "." [tool.black] line-length = 120 From 078fc6a50d18805df60026548021ea682dfabe9d Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 14:17:07 +0200 Subject: [PATCH 6/7] #24 Use PyProject.toml * Moved everything to src to follow src-layout convention * Moved cmake output to cmake_build because it conflicts with pip build directory --- .github/workflows/cmake.yml | 4 ++-- pyproject.toml | 3 +-- {lrpc => src/lrpc}/__init__.py | 0 {lrpc => src/lrpc}/client/__init__.py | 0 {lrpc => src/lrpc}/client/client_cli_visitor.py | 0 {lrpc => src/lrpc}/client/decoder.py | 0 {lrpc => src/lrpc}/client/encoder.py | 0 {lrpc => src/lrpc}/client/lrpc_client.py | 0 {lrpc => src/lrpc}/codegen/__init__.py | 0 {lrpc => src/lrpc}/codegen/common.py | 0 {lrpc => src/lrpc}/codegen/constants.py | 0 {lrpc => src/lrpc}/codegen/enum.py | 0 {lrpc => src/lrpc}/codegen/server_include.py | 0 {lrpc => src/lrpc}/codegen/service_include.py | 0 {lrpc => src/lrpc}/codegen/service_shim.py | 0 {lrpc => src/lrpc}/codegen/struct.py | 0 {lrpc => src/lrpc}/codegen/utils.py | 0 {lrpc => src/lrpc}/core/__init__.py | 0 {lrpc => src/lrpc}/core/constant.py | 0 {lrpc => src/lrpc}/core/definition.py | 0 {lrpc => src/lrpc}/core/enum.py | 0 {lrpc => src/lrpc}/core/function.py | 0 {lrpc => src/lrpc}/core/service.py | 0 {lrpc => src/lrpc}/core/struct.py | 0 {lrpc => src/lrpc}/core/var.py | 0 {lrpc => src/lrpc}/lrpcc.py | 4 ++-- {lrpc => src/lrpc}/lrpcg.py | 8 ++++---- {lrpc => src/lrpc}/schema/__init__.py | 0 {lrpc => src/lrpc}/schema/load.py | 0 {lrpc => src/lrpc}/schema/lotusrpc-schema.json | 0 {lrpc => src/lrpc}/utils/__init__.py | 0 {lrpc => src/lrpc}/utils/load_definition.py | 0 {lrpc => src/lrpc}/validation/__init__.py | 0 {lrpc => src/lrpc}/validation/custom_types.py | 0 {lrpc => src/lrpc}/validation/enum.py | 0 {lrpc => src/lrpc}/validation/function.py | 0 {lrpc => src/lrpc}/validation/names.py | 0 {lrpc => src/lrpc}/validation/semantic_analyzer.py | 0 {lrpc => src/lrpc}/validation/service.py | 0 {lrpc => src/lrpc}/validation/validator.py | 0 {lrpc => src/lrpc}/visitors/__init__.py | 0 {lrpc => src/lrpc}/visitors/lrpc_visitor.py | 0 {lrpc => src/lrpc}/visitors/puml_visitor.py | 0 tests/cpp/CMakeLists.txt | 8 ++++---- 44 files changed, 13 insertions(+), 14 deletions(-) rename {lrpc => src/lrpc}/__init__.py (100%) rename {lrpc => src/lrpc}/client/__init__.py (100%) rename {lrpc => src/lrpc}/client/client_cli_visitor.py (100%) rename {lrpc => src/lrpc}/client/decoder.py (100%) rename {lrpc => src/lrpc}/client/encoder.py (100%) rename {lrpc => src/lrpc}/client/lrpc_client.py (100%) rename {lrpc => src/lrpc}/codegen/__init__.py (100%) rename {lrpc => src/lrpc}/codegen/common.py (100%) rename {lrpc => src/lrpc}/codegen/constants.py (100%) rename {lrpc => src/lrpc}/codegen/enum.py (100%) rename {lrpc => src/lrpc}/codegen/server_include.py (100%) rename {lrpc => src/lrpc}/codegen/service_include.py (100%) rename {lrpc => src/lrpc}/codegen/service_shim.py (100%) rename {lrpc => src/lrpc}/codegen/struct.py (100%) rename {lrpc => src/lrpc}/codegen/utils.py (100%) rename {lrpc => src/lrpc}/core/__init__.py (100%) rename {lrpc => src/lrpc}/core/constant.py (100%) rename {lrpc => src/lrpc}/core/definition.py (100%) rename {lrpc => src/lrpc}/core/enum.py (100%) rename {lrpc => src/lrpc}/core/function.py (100%) rename {lrpc => src/lrpc}/core/service.py (100%) rename {lrpc => src/lrpc}/core/struct.py (100%) rename {lrpc => src/lrpc}/core/var.py (100%) rename {lrpc => src/lrpc}/lrpcc.py (98%) rename {lrpc => src/lrpc}/lrpcg.py (90%) rename {lrpc => src/lrpc}/schema/__init__.py (100%) rename {lrpc => src/lrpc}/schema/load.py (100%) rename {lrpc => src/lrpc}/schema/lotusrpc-schema.json (100%) rename {lrpc => src/lrpc}/utils/__init__.py (100%) rename {lrpc => src/lrpc}/utils/load_definition.py (100%) rename {lrpc => src/lrpc}/validation/__init__.py (100%) rename {lrpc => src/lrpc}/validation/custom_types.py (100%) rename {lrpc => src/lrpc}/validation/enum.py (100%) rename {lrpc => src/lrpc}/validation/function.py (100%) rename {lrpc => src/lrpc}/validation/names.py (100%) rename {lrpc => src/lrpc}/validation/semantic_analyzer.py (100%) rename {lrpc => src/lrpc}/validation/service.py (100%) rename {lrpc => src/lrpc}/validation/validator.py (100%) rename {lrpc => src/lrpc}/visitors/__init__.py (100%) rename {lrpc => src/lrpc}/visitors/lrpc_visitor.py (100%) rename {lrpc => src/lrpc}/visitors/puml_visitor.py (100%) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 63207f7..a4aec65 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -32,10 +32,10 @@ jobs: run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}} - name: C++ tests - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}}/cmake_build run: ctest -C ${{env.BUILD_TYPE}} --output-junit ../testresults/cpptestresults.xml - name: Python tests diff --git a/pyproject.toml b/pyproject.toml index a09024e..3e7502d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,10 +46,9 @@ lrpcc = "lrpc.lrpcc:run_cli" [tool.setuptools] include-package-data = true -packages = ["lrpc"] [tool.pytest.ini_options] -pythonpath = "." +pythonpath = "src" [tool.black] line-length = 120 diff --git a/lrpc/__init__.py b/src/lrpc/__init__.py similarity index 100% rename from lrpc/__init__.py rename to src/lrpc/__init__.py diff --git a/lrpc/client/__init__.py b/src/lrpc/client/__init__.py similarity index 100% rename from lrpc/client/__init__.py rename to src/lrpc/client/__init__.py diff --git a/lrpc/client/client_cli_visitor.py b/src/lrpc/client/client_cli_visitor.py similarity index 100% rename from lrpc/client/client_cli_visitor.py rename to src/lrpc/client/client_cli_visitor.py diff --git a/lrpc/client/decoder.py b/src/lrpc/client/decoder.py similarity index 100% rename from lrpc/client/decoder.py rename to src/lrpc/client/decoder.py diff --git a/lrpc/client/encoder.py b/src/lrpc/client/encoder.py similarity index 100% rename from lrpc/client/encoder.py rename to src/lrpc/client/encoder.py diff --git a/lrpc/client/lrpc_client.py b/src/lrpc/client/lrpc_client.py similarity index 100% rename from lrpc/client/lrpc_client.py rename to src/lrpc/client/lrpc_client.py diff --git a/lrpc/codegen/__init__.py b/src/lrpc/codegen/__init__.py similarity index 100% rename from lrpc/codegen/__init__.py rename to src/lrpc/codegen/__init__.py diff --git a/lrpc/codegen/common.py b/src/lrpc/codegen/common.py similarity index 100% rename from lrpc/codegen/common.py rename to src/lrpc/codegen/common.py diff --git a/lrpc/codegen/constants.py b/src/lrpc/codegen/constants.py similarity index 100% rename from lrpc/codegen/constants.py rename to src/lrpc/codegen/constants.py diff --git a/lrpc/codegen/enum.py b/src/lrpc/codegen/enum.py similarity index 100% rename from lrpc/codegen/enum.py rename to src/lrpc/codegen/enum.py diff --git a/lrpc/codegen/server_include.py b/src/lrpc/codegen/server_include.py similarity index 100% rename from lrpc/codegen/server_include.py rename to src/lrpc/codegen/server_include.py diff --git a/lrpc/codegen/service_include.py b/src/lrpc/codegen/service_include.py similarity index 100% rename from lrpc/codegen/service_include.py rename to src/lrpc/codegen/service_include.py diff --git a/lrpc/codegen/service_shim.py b/src/lrpc/codegen/service_shim.py similarity index 100% rename from lrpc/codegen/service_shim.py rename to src/lrpc/codegen/service_shim.py diff --git a/lrpc/codegen/struct.py b/src/lrpc/codegen/struct.py similarity index 100% rename from lrpc/codegen/struct.py rename to src/lrpc/codegen/struct.py diff --git a/lrpc/codegen/utils.py b/src/lrpc/codegen/utils.py similarity index 100% rename from lrpc/codegen/utils.py rename to src/lrpc/codegen/utils.py diff --git a/lrpc/core/__init__.py b/src/lrpc/core/__init__.py similarity index 100% rename from lrpc/core/__init__.py rename to src/lrpc/core/__init__.py diff --git a/lrpc/core/constant.py b/src/lrpc/core/constant.py similarity index 100% rename from lrpc/core/constant.py rename to src/lrpc/core/constant.py diff --git a/lrpc/core/definition.py b/src/lrpc/core/definition.py similarity index 100% rename from lrpc/core/definition.py rename to src/lrpc/core/definition.py diff --git a/lrpc/core/enum.py b/src/lrpc/core/enum.py similarity index 100% rename from lrpc/core/enum.py rename to src/lrpc/core/enum.py diff --git a/lrpc/core/function.py b/src/lrpc/core/function.py similarity index 100% rename from lrpc/core/function.py rename to src/lrpc/core/function.py diff --git a/lrpc/core/service.py b/src/lrpc/core/service.py similarity index 100% rename from lrpc/core/service.py rename to src/lrpc/core/service.py diff --git a/lrpc/core/struct.py b/src/lrpc/core/struct.py similarity index 100% rename from lrpc/core/struct.py rename to src/lrpc/core/struct.py diff --git a/lrpc/core/var.py b/src/lrpc/core/var.py similarity index 100% rename from lrpc/core/var.py rename to src/lrpc/core/var.py diff --git a/lrpc/lrpcc.py b/src/lrpc/lrpcc.py similarity index 98% rename from lrpc/lrpcc.py rename to src/lrpc/lrpcc.py index 510d746..5444557 100644 --- a/lrpc/lrpcc.py +++ b/src/lrpc/lrpcc.py @@ -9,8 +9,8 @@ import click import serial import yaml -from .client import ClientCliVisitor, LrpcClient -from .utils import load_lrpc_def_from_url +from lrpc.client import ClientCliVisitor, LrpcClient +from lrpc.utils import load_lrpc_def_from_url logging.basicConfig(format="[LRPCC] %(levelname)-8s: %(message)s", level=logging.INFO) diff --git a/lrpc/lrpcg.py b/src/lrpc/lrpcg.py similarity index 90% rename from lrpc/lrpcg.py rename to src/lrpc/lrpcg.py index b64d5a8..7aa9615 100644 --- a/lrpc/lrpcg.py +++ b/src/lrpc/lrpcg.py @@ -3,8 +3,8 @@ from os import path from typing import TextIO import click -from .visitors import PlantUmlVisitor -from .codegen import ( +from lrpc.visitors import PlantUmlVisitor +from lrpc.codegen import ( ConstantsFileVisitor, EnumFileVisitor, ServerIncludeVisitor, @@ -12,8 +12,8 @@ ServiceShimVisitor, StructFileVisitor, ) -from .core import LrpcDef -from .utils import load_lrpc_def_from_file +from lrpc.core import LrpcDef +from lrpc.utils import load_lrpc_def_from_file logging.basicConfig(format="[LRPCC] %(levelname)-8s: %(message)s", level=logging.INFO) diff --git a/lrpc/schema/__init__.py b/src/lrpc/schema/__init__.py similarity index 100% rename from lrpc/schema/__init__.py rename to src/lrpc/schema/__init__.py diff --git a/lrpc/schema/load.py b/src/lrpc/schema/load.py similarity index 100% rename from lrpc/schema/load.py rename to src/lrpc/schema/load.py diff --git a/lrpc/schema/lotusrpc-schema.json b/src/lrpc/schema/lotusrpc-schema.json similarity index 100% rename from lrpc/schema/lotusrpc-schema.json rename to src/lrpc/schema/lotusrpc-schema.json diff --git a/lrpc/utils/__init__.py b/src/lrpc/utils/__init__.py similarity index 100% rename from lrpc/utils/__init__.py rename to src/lrpc/utils/__init__.py diff --git a/lrpc/utils/load_definition.py b/src/lrpc/utils/load_definition.py similarity index 100% rename from lrpc/utils/load_definition.py rename to src/lrpc/utils/load_definition.py diff --git a/lrpc/validation/__init__.py b/src/lrpc/validation/__init__.py similarity index 100% rename from lrpc/validation/__init__.py rename to src/lrpc/validation/__init__.py diff --git a/lrpc/validation/custom_types.py b/src/lrpc/validation/custom_types.py similarity index 100% rename from lrpc/validation/custom_types.py rename to src/lrpc/validation/custom_types.py diff --git a/lrpc/validation/enum.py b/src/lrpc/validation/enum.py similarity index 100% rename from lrpc/validation/enum.py rename to src/lrpc/validation/enum.py diff --git a/lrpc/validation/function.py b/src/lrpc/validation/function.py similarity index 100% rename from lrpc/validation/function.py rename to src/lrpc/validation/function.py diff --git a/lrpc/validation/names.py b/src/lrpc/validation/names.py similarity index 100% rename from lrpc/validation/names.py rename to src/lrpc/validation/names.py diff --git a/lrpc/validation/semantic_analyzer.py b/src/lrpc/validation/semantic_analyzer.py similarity index 100% rename from lrpc/validation/semantic_analyzer.py rename to src/lrpc/validation/semantic_analyzer.py diff --git a/lrpc/validation/service.py b/src/lrpc/validation/service.py similarity index 100% rename from lrpc/validation/service.py rename to src/lrpc/validation/service.py diff --git a/lrpc/validation/validator.py b/src/lrpc/validation/validator.py similarity index 100% rename from lrpc/validation/validator.py rename to src/lrpc/validation/validator.py diff --git a/lrpc/visitors/__init__.py b/src/lrpc/visitors/__init__.py similarity index 100% rename from lrpc/visitors/__init__.py rename to src/lrpc/visitors/__init__.py diff --git a/lrpc/visitors/lrpc_visitor.py b/src/lrpc/visitors/lrpc_visitor.py similarity index 100% rename from lrpc/visitors/lrpc_visitor.py rename to src/lrpc/visitors/lrpc_visitor.py diff --git a/lrpc/visitors/puml_visitor.py b/src/lrpc/visitors/puml_visitor.py similarity index 100% rename from lrpc/visitors/puml_visitor.py rename to src/lrpc/visitors/puml_visitor.py diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt index a922350..deaddb8 100644 --- a/tests/cpp/CMakeLists.txt +++ b/tests/cpp/CMakeLists.txt @@ -15,25 +15,25 @@ mark_as_advanced( add_subdirectory(../../external/gtest External/gtest EXCLUDE_FROM_ALL) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server1/Server1.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src COMMENT "Generate TestServer1 LRPC files" DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer1.lrpc.yaml COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer1.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server1) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server2/Server2.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src COMMENT "Generate TestServer2 LRPC files" DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer2.lrpc.yaml COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer2.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server2) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server3/Server3.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src COMMENT "Generate TestServer3 LRPC files" DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer3.lrpc.yaml COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer3.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server3) add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4/Server4.hpp - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src COMMENT "Generate TestServer4 LRPC files" DEPENDS ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer4.lrpc.yaml COMMAND python -m lrpc.lrpcg -w ${CMAKE_SOURCE_DIR}/tests/testdata/TestServer4.lrpc.yaml -o ${CMAKE_CURRENT_SOURCE_DIR}/generated/Server4) From b4b23001c690d24eb60878d4196e30a8134bec13 Mon Sep 17 00:00:00 2001 From: tzijnge Date: Thu, 17 Oct 2024 14:19:05 +0200 Subject: [PATCH 7/7] #24 Use PyProject.toml * Moved cmake output to cmake_build because it conflicts with pip build directory --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a4aec65..6604c54 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -29,7 +29,7 @@ jobs: pip install -r requirements/dev.txt - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/cmake_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build run: cmake --build ${{github.workspace}}/cmake_build --config ${{env.BUILD_TYPE}}