Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#24 Use PyProject.toml #25

Merged
merged 7 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,23 @@ 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}}/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
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
run: lotusrpc --help
- name: Run lotusrpc generator
run: lrpcg --help

- name: Run LRPC client CLI
run: lrpcc --help
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
build
.vscode
**/__pycache__/**/*.*
/language/cpp/tests/generated
/tests/cpp/generated
/VENV
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)

enable_testing()
add_subdirectory(language/cpp/tests)
add_subdirectory(tests/cpp)
1 change: 0 additions & 1 deletion package/README

This file was deleted.

25 changes: 0 additions & 25 deletions package/setup.py

This file was deleted.

53 changes: 52 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
[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 = { 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",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: C++",
"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.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.scripts]
lrpcg = "lrpc.lrpcg:run_cli"
lrpcc = "lrpc.lrpcc:run_cli"

[tool.setuptools.package-data]
"lrpc.schema" = ["lotusrpc-schema.json"]

[tool.setuptools]
include-package-data = true

[tool.pytest.ini_options]
pythonpath = "src"

[tool.black]
line-length = 120

Expand All @@ -14,7 +66,6 @@ disable = ["line-too-long"]
allow-reexport-from-package = true

[tool.mypy]
exclude = "external"
strict = true
# Increase strictness of checks
disallow_any_decorated = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package/lrpc/lrpcc.py → src/lrpc/lrpcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions package/lrpc/lotusrpc.py → src/lrpc/lrpcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
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,
ServiceIncludeVisitor,
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)

Expand Down Expand Up @@ -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:
Expand All @@ -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()
File renamed without changes.
2 changes: 1 addition & 1 deletion package/lrpc/schema/load.py → src/lrpc/schema/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions language/cpp/tests/CMakeLists.txt → tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}/src
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}/src
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}/src
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}/src
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)

Expand All @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading