Skip to content

Commit

Permalink
Enabling package build and upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizog committed Feb 5, 2024
1 parent 695b647 commit 68828fe
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode/
dist/
someipy.egg-info/
__pycache__
19 changes: 7 additions & 12 deletions example_apps/send_events.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import sys
sys.path.append("..")

import asyncio
import ipaddress
import logging

import src.service_discovery
import src._internal.someip_header
import src._internal.someip_sd_header
import src.server_service_instance
from src.logging import set_someipy_log_level
from src.serialization import Uint8, Uint64, Float32
from someipy.service_discovery import construct_service_discovery
from someipy.server_service_instance import ServerServiceInstance
from someipy.logging import set_someipy_log_level
from someipy.serialization import Uint8, Uint64, Float32
from temperature_msg import TemparatureMsg

SD_MULTICAST_GROUP = "224.224.224.245"
Expand All @@ -28,15 +23,15 @@ async def main():
# Since the construction of the class ServiceDiscoveryProtocol is not trivial and would require an async __init__ function
# use the construct_service_discovery function
# The local interface IP address needs to be passed so that the src-address of all SD UDP packets is correctly set
service_discovery = await src.service_discovery.construct_service_discovery(SD_MULTICAST_GROUP, SD_PORT, INTERFACE_IP)
service_discovery = await construct_service_discovery(SD_MULTICAST_GROUP, SD_PORT, INTERFACE_IP)

# 1. For sending events use a ServerServiceInstance
# 2. Pass the service and instance ID, version and endpoint and TTL. The endpoint is needed again as the src-address
# and port of all sent events
# 3. The ServiceDiscoveryProtocol object has to be passed as well, so the ServerServiceInstance can offer his service to
# other ECUs
# 4. cyclic_offer_delay_ms is the period of sending cyclic SD Offer service entries
service_instance_temperature = src.server_service_instance.ServerServiceInstance(
service_instance_temperature = ServerServiceInstance(
service_id=1,
instance_id=1000,
major_version=1,
Expand All @@ -52,7 +47,7 @@ async def main():
service_discovery.attach(service_instance_temperature)

# For demonstration purposes we will construct a second ServerServiceInstance
service_instance_2 = src.server_service_instance.ServerServiceInstance(
service_instance_2 = ServerServiceInstance(
service_id=2,
instance_id=2000,
major_version=1,
Expand Down
5 changes: 1 addition & 4 deletions example_apps/temperature_msg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import sys
sys.path.append("..")

from src.serialization import *
from someipy.serialization import *

# With someipy it's possible to either send and receive payloads unserialized simply as bytes-objects
# You can also define the payloads structure directly as Python classes and serialize your Python object
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ['setuptools>=42']
build-backend = 'setuptools.build_meta'
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[metadata]
name = someipy
version = 0.0.0
author = Christian H.
author_email = someipy.package@gmail.com
description = A Python package implementing the SOME/IP protocol
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/chrizog/someipy
project_urls =
Bug Tracker = https://github.com/chrizog/someipy/issues
Repository = https://github.com/chrizog/someipy
classifiers =
Intended Audience :: Developers
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3.12

[options]
package_dir =
= src
packages = find:
python_requires = >=3.12

[options.packages.find]
where = src
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from src.logging import get_someipy_log_level
from someipy.logging import get_someipy_log_level

def get_logger(name: str) -> logging.Logger:
logger = logging.getLogger("someipy." + name)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from src._internal.someip_sd_header import *
from src._internal.session_handler import SessionHandler
from someipy._internal.someip_sd_header import *
from someipy._internal.session_handler import SessionHandler


class ServiceDiscoveryObserver(ABC):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import time



class SimplePeriodicTimer():
def __init__(self, period, callback):
self._period = period
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from dataclasses import dataclass
from typing import List, Tuple, TypeVar, Union

from src._internal.utils import set_bit_at_position, is_bit_set
from src._internal.someip_header import SomeIpHeader
from someipy._internal.utils import set_bit_at_position, is_bit_set
from someipy._internal.someip_header import SomeIpHeader

# Constants for byte positions inside the SD header
SD_POSITION_ENTRY_LENGTH = 20
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from dataclasses import dataclass
from typing import List

from src.service_discovery import *
from src._internal.message_types import MessageType
from src._internal.someip_sd_builder import *
from src._internal.someip_header import SomeIpHeader
from src._internal.someip_sd_header import (
from someipy.service_discovery import *
from someipy._internal.message_types import MessageType
from someipy._internal.someip_sd_builder import *
from someipy._internal.someip_header import SomeIpHeader
from someipy._internal.someip_sd_header import (
SdService,
TransportLayerProtocol,
SdEventGroupEntry,
)

from src._internal.simple_timer import SimplePeriodicTimer
from src._internal.utils import (
from someipy._internal.simple_timer import SimplePeriodicTimer
from someipy._internal.utils import (
create_udp_socket,
endpoint_to_str_int_tuple,
EndpointType,
)
from src._internal.logging import get_logger
from someipy._internal.logging import get_logger

_logger = get_logger("server_service_instance")

Expand Down
14 changes: 7 additions & 7 deletions src/service_discovery.py → src/someipy/service_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import ipaddress
from typing import Any, Union, Tuple, List

from src._internal.someip_header import SomeIpHeader
from src._internal.someip_sd_header import *
from src._internal.someip_sd_extractors import *
from src._internal.session_handler import SessionHandler
from src._internal.utils import (
from someipy._internal.someip_header import SomeIpHeader
from someipy._internal.someip_sd_header import *
from someipy._internal.someip_sd_extractors import *
from someipy._internal.session_handler import SessionHandler
from someipy._internal.utils import (
create_rcv_multicast_socket,
create_udp_socket,
DatagramAdapter,
)
from src._internal.service_discovery_abcs import *
from src._internal.logging import get_logger
from someipy._internal.service_discovery_abcs import *
from someipy._internal.logging import get_logger

_logger = get_logger("service_discovery")

Expand Down
5 changes: 4 additions & 1 deletion tests/test_serialization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sys
sys.path.append("src")

import pytest
from src.serialization import *
from someipy.serialization import *


def test_base_types_len():
Expand Down

0 comments on commit 68828fe

Please sign in to comment.