git: 1472a559157f - main - devel/py-pnio-dcp: New port: Library to PROFINET Discovery and basic DCP protocol

From: Jose Alonso Cardenas Marquez <acm_at_FreeBSD.org>
Date: Mon, 19 Feb 2024 00:29:15 UTC
The branch main has been updated by acm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1472a559157fb57b848ecf1db367bde505d0f4bb

commit 1472a559157fb57b848ecf1db367bde505d0f4bb
Author:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
AuthorDate: 2024-02-19 00:28:12 +0000
Commit:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
CommitDate: 2024-02-19 00:28:12 +0000

    devel/py-pnio-dcp: New port: Library to PROFINET Discovery and basic DCP protocol
    
    A simple Python library to send and receive messages with the Profinet
    Discovery and basic Configuration Protocol (DCP) protocol. It can send requests
    and parse the corresponding responses to identify devices over the network, get
    and set their parameters or reset them to factory settings.
---
 devel/Makefile                                     |  1 +
 devel/py-pnio-dcp/Makefile                         | 29 ++++++++++++++++++++++
 devel/py-pnio-dcp/distinfo                         |  3 +++
 .../files/patch-pnio__dcp_l2socket_____init____.py | 10 ++++++++
 .../py-pnio-dcp/files/patch-pnio__dcp_pnio__dcp.py | 22 ++++++++++++++++
 devel/py-pnio-dcp/files/patch-setup.py             | 11 ++++++++
 devel/py-pnio-dcp/pkg-descr                        |  4 +++
 7 files changed, 80 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index ad7ed6b60dd3..2eaae82d05a3 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -5220,6 +5220,7 @@
     SUBDIR += py-pluginbase
     SUBDIR += py-plux
     SUBDIR += py-ply
+    SUBDIR += py-pnio-dcp
     SUBDIR += py-pockets
     SUBDIR += py-podcastparser
     SUBDIR += py-poetry
diff --git a/devel/py-pnio-dcp/Makefile b/devel/py-pnio-dcp/Makefile
new file mode 100644
index 000000000000..d782d3252520
--- /dev/null
+++ b/devel/py-pnio-dcp/Makefile
@@ -0,0 +1,29 @@
+PORTNAME=	pnio-dcp
+PORTVERSION=	1.2.0
+CATEGORIES=	devel python
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	acm@FreeBSD.org
+COMMENT=	Library to PROFINET Discovery and basic DCP protocol
+WWW=		https://gitlab.com/pyshacks/pnio_dcp
+
+LICENSE=	MIT
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools_scm>0:devel/py-setuptools_scm@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}psutil>=0:sysutils/py-psutil@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}importlib-metadata>0:devel/py-importlib-metadata@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	autoplist distutils
+
+USE_GITLAB=     yes
+GL_ACCOUNT=     pyshacks
+GL_PROJECT=     ${PORTNAME:S/-/_/}
+GL_COMMIT=	6156aa9c10bca35a118a58a02837b97a7e5a829e
+
+NO_ARCH=	yes
+
+post-patch:
+	${REINPLACE_CMD} -e 's|%%PORTVERSION%%|${PORTVERSION}|g' ${WRKSRC}/setup.py
+
+.include <bsd.port.mk>
diff --git a/devel/py-pnio-dcp/distinfo b/devel/py-pnio-dcp/distinfo
new file mode 100644
index 000000000000..a012c6cdcc58
--- /dev/null
+++ b/devel/py-pnio-dcp/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1708286638
+SHA256 (pyshacks-pnio_dcp-6156aa9c10bca35a118a58a02837b97a7e5a829e_GL0.tar.gz) = c5aa5822faf78cae39ae1c7dc9010528acd322cef5d7037c6b71522e03f601e5
+SIZE (pyshacks-pnio_dcp-6156aa9c10bca35a118a58a02837b97a7e5a829e_GL0.tar.gz) = 32613
diff --git a/devel/py-pnio-dcp/files/patch-pnio__dcp_l2socket_____init____.py b/devel/py-pnio-dcp/files/patch-pnio__dcp_l2socket_____init____.py
new file mode 100644
index 000000000000..5201c36f362e
--- /dev/null
+++ b/devel/py-pnio-dcp/files/patch-pnio__dcp_l2socket_____init____.py
@@ -0,0 +1,10 @@
+--- pnio_dcp/l2socket/__init__.py.orig	2024-02-18 23:35:44 UTC
++++ pnio_dcp/l2socket/__init__.py
+@@ -10,5 +10,7 @@ if sys.platform == 'win32':
+     L2Socket = L2PcapSocket
+ elif sys.platform.startswith('linux'):
+     L2Socket = L2LinuxSocket
++elif sys.platform.startswith('freebsd'):
++    L2Socket = L2LinuxSocket
+ else:
+     raise NotImplementedError(f"Platform {sys.platform} is currently not supported.")
diff --git a/devel/py-pnio-dcp/files/patch-pnio__dcp_pnio__dcp.py b/devel/py-pnio-dcp/files/patch-pnio__dcp_pnio__dcp.py
new file mode 100644
index 000000000000..18e68a4ce8c6
--- /dev/null
+++ b/devel/py-pnio-dcp/files/patch-pnio__dcp_pnio__dcp.py
@@ -0,0 +1,22 @@
+--- pnio_dcp/pnio_dcp.py.orig	2024-02-18 23:53:00 UTC
++++ pnio_dcp/pnio_dcp.py
+@@ -49,7 +49,7 @@ class DCP:
+     available through this instance.
+     """
+ 
+-    def __init__(self, ip):
++    def __init__(self, ip, timeout=7):
+         """
+         Create a new instance, use the given ip to select the network interface.
+         :param ip: The ip address used to select the network interface.
+@@ -57,8 +57,8 @@ class DCP:
+         """
+         self.src_mac, network_interface = self.__get_network_interface_and_mac_address(ip)
+ 
+-        self.default_timeout = 7  # default timeout for requests (in seconds)
+-        self.identify_all_timeout = 7  # timeout to receive all responses for identify_all
++        self.default_timeout = timeout  # default timeout for requests (in seconds)
++        self.identify_all_timeout = timeout  # timeout to receive all responses for identify_all
+ 
+         # the XID is the id of the current transaction and can be used to identify the responses to a request
+         self.__xid = int(random.getrandbits(32))  # initialize it with a random value
diff --git a/devel/py-pnio-dcp/files/patch-setup.py b/devel/py-pnio-dcp/files/patch-setup.py
new file mode 100644
index 000000000000..02a992f8b10c
--- /dev/null
+++ b/devel/py-pnio-dcp/files/patch-setup.py
@@ -0,0 +1,11 @@
+--- setup.py.orig	2023-10-04 11:20:39 UTC
++++ setup.py
+@@ -30,7 +30,7 @@ classifiers = [
+               ]
+ 
+ setup(name="pnio_dcp",
+-      use_scm_version={"local_scheme": "no-local-version"},
++      version='1.2.0',
+       setup_requires=['setuptools_scm'],
+       description='Discover and configure PROFINET devices with the PROFINET Discovery and basic Configuration Protocol (DCP) '
+                   'protocol.',
diff --git a/devel/py-pnio-dcp/pkg-descr b/devel/py-pnio-dcp/pkg-descr
new file mode 100644
index 000000000000..454a8a2d8ae9
--- /dev/null
+++ b/devel/py-pnio-dcp/pkg-descr
@@ -0,0 +1,4 @@
+A simple Python library to send and receive messages with the Profinet
+Discovery and basic Configuration Protocol (DCP) protocol. It can send requests
+and parse the corresponding responses to identify devices over the network, get
+and set their parameters or reset them to factory settings.