libe3py 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libe3py-0.2.3/LICENSE +178 -0
- libe3py-0.2.3/NOTICE +15 -0
- libe3py-0.2.3/PKG-INFO +38 -0
- libe3py-0.2.3/VERSION +1 -0
- libe3py-0.2.3/cmake/libe3SwigModule.cmake +55 -0
- libe3py-0.2.3/pyproject.toml +44 -0
- libe3py-0.2.3/python/CMakeLists.txt +59 -0
- libe3py-0.2.3/python/README.md +22 -0
- libe3py-0.2.3/swig/README.md +129 -0
- libe3py-0.2.3/swig/e3_dapp_session.cpp +289 -0
- libe3py-0.2.3/swig/e3_dapp_session.hpp +210 -0
- libe3py-0.2.3/swig/libe3.i +263 -0
- libe3py-0.2.3/swig/libe3_swig.hpp +73 -0
libe3py-0.2.3/LICENSE
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Copyright (c) 2026 Northeastern University
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
libe3py-0.2.3/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
libe3
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Northeastern University
|
|
4
|
+
|
|
5
|
+
This product includes software developed at the Institute for Intelligent
|
|
6
|
+
Networked Systems, Northeastern University.
|
|
7
|
+
|
|
8
|
+
Use, modification and redistribution are permitted under the Apache License,
|
|
9
|
+
Version 2.0 (see LICENSE), including the E3AP protocol definition in
|
|
10
|
+
messages/asn1/V1/e3ap-1.0.0.asn1. If you use libe3, or derive a protocol
|
|
11
|
+
definition or an implementation from it, we ask that you cite the work:
|
|
12
|
+
|
|
13
|
+
[citation to be added on publication]
|
|
14
|
+
|
|
15
|
+
That citation is a request, not an additional condition on the license.
|
libe3py-0.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: libe3py
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Python binding of libe3, the O-RAN E3 interface library
|
|
5
|
+
Author: Northeastern University
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: C++
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Project-URL: Homepage, https://github.com/wineslab/libe3
|
|
13
|
+
Project-URL: Documentation, https://github.com/wineslab/libe3/blob/main/swig/README.md
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# libe3py
|
|
18
|
+
|
|
19
|
+
Python binding of [libe3](https://github.com/wineslab/libe3), the C++ library that implements the O-RAN
|
|
20
|
+
E3 interface between a RAN node and its dApps. The [dApp library](https://github.com/wineslab/dApp-library)
|
|
21
|
+
(`pip install dapps`) uses it for E3AP; see
|
|
22
|
+
[`swig/README.md`](https://github.com/wineslab/libe3/blob/main/swig/README.md) for the API.
|
|
23
|
+
|
|
24
|
+
libe3py is built when you install it, against the libe3 installed on the machine, and it must be the same
|
|
25
|
+
version. Install libe3 once:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone --branch <version> https://github.com/wineslab/libe3 && cd libe3
|
|
29
|
+
./build_libe3 -I # build dependencies, swig and python3-dev included
|
|
30
|
+
./build_libe3 --all-encodings --install # into /usr/local, asks for sudo
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
then, in any virtual environment and without root:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install libe3py==<version>
|
|
37
|
+
python -c "import libe3py; print(libe3py.__version__)"
|
|
38
|
+
```
|
libe3py-0.2.3/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.3
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# The libe3py SWIG module, shared by the in-tree build (libe3SWIG.cmake) and the
|
|
2
|
+
# pip build against an installed libe3 (python/CMakeLists.txt), so the two
|
|
3
|
+
# cannot drift apart.
|
|
4
|
+
#
|
|
5
|
+
# libe3_add_python_module(<target> SOURCE_DIR <repo root> OUTPUT_DIR <dir> LINK <libe3 target> [INCLUDE <dir>...])
|
|
6
|
+
#
|
|
7
|
+
# Produces <OUTPUT_DIR>/_libe3py.so and <OUTPUT_DIR>/libe3py.py. The module links
|
|
8
|
+
# libe3 statically, so it needs no liblibe3.so at run time.
|
|
9
|
+
#
|
|
10
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
|
|
11
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
include_guard(GLOBAL)
|
|
14
|
+
|
|
15
|
+
find_package(SWIG 4.0 REQUIRED COMPONENTS python)
|
|
16
|
+
if(CMAKE_VERSION VERSION_LESS 3.18)
|
|
17
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
|
18
|
+
else()
|
|
19
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
|
20
|
+
endif()
|
|
21
|
+
include(UseSWIG)
|
|
22
|
+
|
|
23
|
+
function(libe3_add_python_module target)
|
|
24
|
+
cmake_parse_arguments(ARG "" "SOURCE_DIR;OUTPUT_DIR;LINK" "INCLUDE" ${ARGN})
|
|
25
|
+
set(_i "${ARG_SOURCE_DIR}/swig/libe3.i")
|
|
26
|
+
file(MAKE_DIRECTORY "${ARG_OUTPUT_DIR}")
|
|
27
|
+
set_property(SOURCE "${_i}" PROPERTY CPLUSPLUS ON)
|
|
28
|
+
set(_swig_inc "${ARG_SOURCE_DIR}/swig" ${ARG_INCLUDE})
|
|
29
|
+
set_property(SOURCE "${_i}" PROPERTY INCLUDE_DIRECTORIES ${_swig_inc})
|
|
30
|
+
set(_swig_flags "")
|
|
31
|
+
foreach(_d IN LISTS _swig_inc)
|
|
32
|
+
list(APPEND _swig_flags "-I${_d}")
|
|
33
|
+
endforeach()
|
|
34
|
+
# latrec.h refuses to compile without CLOCK_MONOTONIC declared (see its own
|
|
35
|
+
# #error), which SWIG's preprocessor never sees for real: it does not walk
|
|
36
|
+
# glibc's actual <time.h>/<bits/time.h> chain the way the real compiler does
|
|
37
|
+
# afterwards on the generated wrapper. The numeric value is never evaluated
|
|
38
|
+
# by SWIG, only its definedness, so a placeholder satisfies the check.
|
|
39
|
+
list(APPEND _swig_flags "-DCLOCK_MONOTONIC=1")
|
|
40
|
+
set_property(SOURCE "${_i}" PROPERTY SWIG_FLAGS ${_swig_flags})
|
|
41
|
+
|
|
42
|
+
swig_add_library(${target}
|
|
43
|
+
TYPE SHARED
|
|
44
|
+
LANGUAGE python
|
|
45
|
+
SOURCES "${_i}" "${ARG_SOURCE_DIR}/swig/e3_dapp_session.cpp"
|
|
46
|
+
OUTPUT_DIR "${ARG_OUTPUT_DIR}")
|
|
47
|
+
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${ARG_OUTPUT_DIR}")
|
|
48
|
+
target_include_directories(${target} PRIVATE "${ARG_SOURCE_DIR}/swig" ${ARG_INCLUDE})
|
|
49
|
+
if(TARGET Python3::Module)
|
|
50
|
+
target_link_libraries(${target} PRIVATE ${ARG_LINK} Python3::Module)
|
|
51
|
+
else()
|
|
52
|
+
target_include_directories(${target} PRIVATE ${Python3_INCLUDE_DIRS})
|
|
53
|
+
target_link_libraries(${target} PRIVATE ${ARG_LINK} ${Python3_LIBRARIES})
|
|
54
|
+
endif()
|
|
55
|
+
endfunction()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# libe3py: the Python binding of libe3, built against the libe3 installed on the
|
|
5
|
+
# machine (see python/CMakeLists.txt). Install libe3 first, then `pip install libe3py`.
|
|
6
|
+
[build-system]
|
|
7
|
+
requires = ["scikit-build-core>=0.8", "swig>=4.0"]
|
|
8
|
+
build-backend = "scikit_build_core.build"
|
|
9
|
+
|
|
10
|
+
[project]
|
|
11
|
+
name = "libe3py"
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
description = "Python binding of libe3, the O-RAN E3 interface library"
|
|
14
|
+
readme = "python/README.md"
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
license = "Apache-2.0"
|
|
17
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
18
|
+
authors = [{ name = "Northeastern University" }]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: C++",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/wineslab/libe3"
|
|
27
|
+
Documentation = "https://github.com/wineslab/libe3/blob/main/swig/README.md"
|
|
28
|
+
|
|
29
|
+
[tool.scikit-build]
|
|
30
|
+
cmake.version = ">=3.18"
|
|
31
|
+
cmake.build-type = "Release"
|
|
32
|
+
cmake.source-dir = "python"
|
|
33
|
+
build-dir = "build/{wheel_tag}"
|
|
34
|
+
wheel.packages = []
|
|
35
|
+
sdist.exclude = ["*"]
|
|
36
|
+
sdist.include = [
|
|
37
|
+
"VERSION", "LICENSE", "NOTICE", "pyproject.toml",
|
|
38
|
+
"python/**", "swig/**", "cmake/libe3SwigModule.cmake",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.scikit-build.metadata.version]
|
|
42
|
+
provider = "scikit_build_core.metadata.regex"
|
|
43
|
+
input = "VERSION"
|
|
44
|
+
regex = "^(?P<value>\\d+\\.\\d+\\.\\d+)"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# libe3py, the Python binding of libe3, built by pip (scikit-build-core, see
|
|
2
|
+
# ../pyproject.toml) against the libe3 already installed on the machine:
|
|
3
|
+
#
|
|
4
|
+
# sudo ./build_libe3 --all-encodings --install # once
|
|
5
|
+
# pip install libe3py # or: pip install . from the checkout
|
|
6
|
+
#
|
|
7
|
+
# The module is compiled from the same SWIG sources as the in-tree build and links
|
|
8
|
+
# the installed static libe3, with the feature macros (encodings, latrec) that
|
|
9
|
+
# libe3 was built with. It refuses an installed libe3 of another version, so the
|
|
10
|
+
# binding and the library always match.
|
|
11
|
+
#
|
|
12
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
|
|
13
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
14
|
+
|
|
15
|
+
cmake_minimum_required(VERSION 3.18)
|
|
16
|
+
|
|
17
|
+
set(LIBE3_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
|
18
|
+
file(READ "${LIBE3_SOURCE_DIR}/VERSION" LIBE3PY_VERSION)
|
|
19
|
+
string(STRIP "${LIBE3PY_VERSION}" LIBE3PY_VERSION)
|
|
20
|
+
|
|
21
|
+
project(libe3py VERSION ${LIBE3PY_VERSION} LANGUAGES CXX)
|
|
22
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
23
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
24
|
+
|
|
25
|
+
find_package(libe3 CONFIG QUIET)
|
|
26
|
+
if(NOT libe3_FOUND)
|
|
27
|
+
message(FATAL_ERROR
|
|
28
|
+
"libe3py ${LIBE3PY_VERSION} is built against an installed libe3, and none was found.\n"
|
|
29
|
+
"Install libe3 ${LIBE3PY_VERSION} first (https://github.com/wineslab/libe3):\n"
|
|
30
|
+
" git clone --branch ${LIBE3PY_VERSION} https://github.com/wineslab/libe3 && cd libe3\n"
|
|
31
|
+
" ./build_libe3 -I && ./build_libe3 --all-encodings --install\n"
|
|
32
|
+
"For a libe3 outside /usr and /usr/local, pass its prefix: "
|
|
33
|
+
"pip install libe3py --config-settings=cmake.define.CMAKE_PREFIX_PATH=<prefix>")
|
|
34
|
+
endif()
|
|
35
|
+
if(NOT libe3_VERSION VERSION_EQUAL LIBE3PY_VERSION)
|
|
36
|
+
message(FATAL_ERROR
|
|
37
|
+
"The installed libe3 is ${libe3_VERSION} (${libe3_DIR}), but this is libe3py ${LIBE3PY_VERSION}.\n"
|
|
38
|
+
"Install the libe3py that matches it (pip install \"libe3py==${libe3_VERSION}\"), or install libe3 ${LIBE3PY_VERSION}.")
|
|
39
|
+
endif()
|
|
40
|
+
message(STATUS "Building libe3py ${LIBE3PY_VERSION} against libe3 ${libe3_VERSION} from ${libe3_DIR}")
|
|
41
|
+
|
|
42
|
+
list(APPEND CMAKE_MODULE_PATH "${LIBE3_SOURCE_DIR}/cmake")
|
|
43
|
+
include(libe3SwigModule)
|
|
44
|
+
|
|
45
|
+
get_target_property(_libe3_inc libe3::libe3 INTERFACE_INCLUDE_DIRECTORIES)
|
|
46
|
+
set(_out "${CMAKE_CURRENT_BINARY_DIR}/swig")
|
|
47
|
+
libe3_add_python_module(libe3py
|
|
48
|
+
SOURCE_DIR "${LIBE3_SOURCE_DIR}"
|
|
49
|
+
OUTPUT_DIR "${_out}"
|
|
50
|
+
LINK libe3::libe3
|
|
51
|
+
INCLUDE ${_libe3_inc})
|
|
52
|
+
|
|
53
|
+
if(DEFINED SKBUILD_PLATLIB_DIR)
|
|
54
|
+
set(_dest "${SKBUILD_PLATLIB_DIR}")
|
|
55
|
+
else()
|
|
56
|
+
set(_dest ".")
|
|
57
|
+
endif()
|
|
58
|
+
install(TARGETS libe3py LIBRARY DESTINATION "${_dest}")
|
|
59
|
+
install(FILES "${_out}/libe3py.py" DESTINATION "${_dest}")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# libe3py
|
|
2
|
+
|
|
3
|
+
Python binding of [libe3](https://github.com/wineslab/libe3), the C++ library that implements the O-RAN
|
|
4
|
+
E3 interface between a RAN node and its dApps. The [dApp library](https://github.com/wineslab/dApp-library)
|
|
5
|
+
(`pip install dapps`) uses it for E3AP; see
|
|
6
|
+
[`swig/README.md`](https://github.com/wineslab/libe3/blob/main/swig/README.md) for the API.
|
|
7
|
+
|
|
8
|
+
libe3py is built when you install it, against the libe3 installed on the machine, and it must be the same
|
|
9
|
+
version. Install libe3 once:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone --branch <version> https://github.com/wineslab/libe3 && cd libe3
|
|
13
|
+
./build_libe3 -I # build dependencies, swig and python3-dev included
|
|
14
|
+
./build_libe3 --all-encodings --install # into /usr/local, asks for sudo
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
then, in any virtual environment and without root:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install libe3py==<version>
|
|
21
|
+
python -c "import libe3py; print(libe3py.__version__)"
|
|
22
|
+
```
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# libe3 Python bindings (`libe3py`)
|
|
2
|
+
|
|
3
|
+
SWIG bindings that let Python drive libe3 in the **dApp role**. A Python dApp can
|
|
4
|
+
delete its pure-Python E3AP stack (ZMQ + `asn1tools`) and let libe3 own E3AP on
|
|
5
|
+
both ends of the link — exactly the split OAI already uses on the RAN side. An
|
|
6
|
+
example consumer is available in
|
|
7
|
+
[dApp-library](https://github.com/wineslab/dApp-library).
|
|
8
|
+
|
|
9
|
+
## The split: E3AP in libe3, E3SM in Python
|
|
10
|
+
|
|
11
|
+
libe3 owns **E3AP**: transport, the setup handshake, subscribe/unsubscribe,
|
|
12
|
+
indication/control framing, and all wire encodings (ASN.1 / JSON / Protobuf,
|
|
13
|
+
selected at runtime by `E3Config.encoding`). Python owns **E3SM**: the
|
|
14
|
+
service-model payloads ride opaque, as `bytes`, and are encoded/decoded in
|
|
15
|
+
Python. `libe3py` never touches SM contents.
|
|
16
|
+
|
|
17
|
+
## Two layers
|
|
18
|
+
|
|
19
|
+
| Symbol | Purpose |
|
|
20
|
+
|--------|---------|
|
|
21
|
+
| `E3Config`, enums (`E3Role`, `E3LinkLayer`, `E3TransportLayer`, `EncodingFormat`, `ResponseCode`, `AgentState`, `ErrorCode`) | Configure a session. |
|
|
22
|
+
| `E3Agent` (minimal view) | Backwards-compatible seam: construct/config/start, push opaque bytes. Kept for the smoke test. |
|
|
23
|
+
| **`DAppSession` + `E3Event`** | The real dApp seam: full lifecycle + a **batched, lock-free inbound queue**. This is what a Python dApp consumes. |
|
|
24
|
+
|
|
25
|
+
See [`e3_dapp_session.hpp`](e3_dapp_session.hpp) for the authoritative,
|
|
26
|
+
Doxygen-documented API.
|
|
27
|
+
|
|
28
|
+
## Why batched drain + GIL release (not callbacks)
|
|
29
|
+
|
|
30
|
+
E3AP runs at real-time sub-millisecond cadence with very high message
|
|
31
|
+
throughput, so the binding must not become the bottleneck. At those rates the
|
|
32
|
+
limiters are the **count of GIL acquisitions**, the **count of Python↔C++
|
|
33
|
+
boundary crossings**, and libe3's C++ worker threads **stalling on the GIL** —
|
|
34
|
+
not payload copy size (E3AP payloads are small; bulk IQ travels out-of-band in
|
|
35
|
+
shared memory).
|
|
36
|
+
|
|
37
|
+
`DAppSession` therefore:
|
|
38
|
+
|
|
39
|
+
- registers libe3's C++ handlers itself and pushes each inbound message into a
|
|
40
|
+
**bounded lock-free ring** (`libe3::LockFreeQueue`), incrementing a drop
|
|
41
|
+
counter on overflow instead of blocking libe3;
|
|
42
|
+
- exposes **`poll_events(max_batch, timeout_ms)`**, which blocks for the *first*
|
|
43
|
+
event (latency ≈ ring wakeup) then sweeps up to `max_batch` already-queued
|
|
44
|
+
events in a single call — amortising one GIL acquire + one boundary crossing
|
|
45
|
+
across the whole batch;
|
|
46
|
+
- is wrapped with `%module(threads="1")` (see [`libe3.i`](libe3.i)) so the GIL is
|
|
47
|
+
**released** around every call; libe3's threads run freely while Python waits.
|
|
48
|
+
|
|
49
|
+
**Rejected alternatives:** SWIG *directors* run the Python callback on libe3's
|
|
50
|
+
inbound thread under the GIL (serialises dispatch, deadlock-prone if Python
|
|
51
|
+
re-enters libe3); a *per-message* poll pays one GIL round-trip per message and
|
|
52
|
+
caps throughput with no latency benefit over batching.
|
|
53
|
+
|
|
54
|
+
## Lifecycle
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
DAppSession(cfg) # ctor registers all inbound handlers
|
|
58
|
+
→ start() # connects; begins the handshake
|
|
59
|
+
→ wait_for_setup(ms) # blocks until setup completes
|
|
60
|
+
→ dapp_id() / setup_ran_function_*() # read what the RAN advertised
|
|
61
|
+
→ subscribe(rfid, telemetry, control, sub_time, periodicity)
|
|
62
|
+
→ loop:
|
|
63
|
+
for ev in poll_events(max_batch, timeout_ms):
|
|
64
|
+
dispatch(ev) # E3_EVENT_INDICATION / _XAPP_CONTROL / ...
|
|
65
|
+
send_control(rfid, cid, payload_bytes) # or send_report(...)
|
|
66
|
+
→ release() # tell the RAN we are leaving
|
|
67
|
+
→ stop() # tear down; unblocks any poll_events
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Minimal Python example
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import libe3py as e3
|
|
74
|
+
|
|
75
|
+
cfg = e3.E3Config()
|
|
76
|
+
cfg.role = e3.E3Role_DAPP
|
|
77
|
+
cfg.link_layer = e3.E3LinkLayer_ZMQ
|
|
78
|
+
cfg.transport_layer = e3.E3TransportLayer_IPC
|
|
79
|
+
cfg.encoding = e3.EncodingFormat_ASN1 # must match the RAN's E3Configuration
|
|
80
|
+
cfg.dapp_name = "MyDApp"
|
|
81
|
+
|
|
82
|
+
s = e3.DAppSession(cfg)
|
|
83
|
+
assert s.start() == 0 # ErrorCode.SUCCESS
|
|
84
|
+
assert s.wait_for_setup(6000) == 0
|
|
85
|
+
print("dApp id:", s.dapp_id())
|
|
86
|
+
|
|
87
|
+
# Enumerate what the RAN advertised in the SetupResponse.
|
|
88
|
+
for i in range(s.setup_ran_function_count()):
|
|
89
|
+
rfid = s.setup_ran_function_id(i)
|
|
90
|
+
ran_function_data = s.setup_ran_function_data(i) # opaque bytes -> decode in Python
|
|
91
|
+
|
|
92
|
+
s.subscribe(1, [1], [1], -1, -1) # RAN function 1, telemetry {1}, control {1}
|
|
93
|
+
|
|
94
|
+
while True:
|
|
95
|
+
for ev in s.poll_events(256, 100): # drain up to 256 per wake, 100ms wait
|
|
96
|
+
if ev.kind == e3.E3_EVENT_INDICATION:
|
|
97
|
+
handle(ev.ran_function_id, ev.get_payload()) # get_payload() -> native bytes
|
|
98
|
+
elif ev.kind == e3.E3_EVENT_SUBSCRIPTION_RESPONSE:
|
|
99
|
+
...
|
|
100
|
+
# send an SM-encoded control back when needed:
|
|
101
|
+
# s.send_control(1, 1, sm_encode(...))
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Build & install
|
|
105
|
+
|
|
106
|
+
Install libe3 once (`./build_libe3 --all-encodings --install`, see the main README), then the binding
|
|
107
|
+
with pip, in any virtual environment:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pip install libe3py # or, from the libe3 checkout: pip install .
|
|
111
|
+
python -c "import libe3py; print('libe3py OK', libe3py.__version__)"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
pip builds the module from these sources against the installed libe3 (`python/CMakeLists.txt`); it
|
|
115
|
+
needs `swig >= 4.0`, the Python headers and a C++17 compiler (`./build_libe3 -I` installs them), and it
|
|
116
|
+
stops with an error if the installed libe3 is not the same version. For a libe3 outside `/usr` and
|
|
117
|
+
`/usr/local`: `pip install libe3py --config-settings=cmake.define.CMAKE_PREFIX_PATH=<prefix>`.
|
|
118
|
+
|
|
119
|
+
For development, `./build_libe3 --enable-swig` builds the module in `build/swig` (run the smoke test with
|
|
120
|
+
`PYTHONPATH=build/swig python3 tests/test_swig_smoke.py`); `cmake --install` installs it only if
|
|
121
|
+
`-DLIBE3_PYTHON_INSTALL_DIR=<dir>` is given.
|
|
122
|
+
|
|
123
|
+
## Service-model definitions
|
|
124
|
+
|
|
125
|
+
The Simple SM grammar is installed alongside the library under
|
|
126
|
+
`<datadir>/libe3/sm/sm_simple/` — both `e3sm_simple.asn` (ASN.1) and
|
|
127
|
+
`e3sm_simple.proto` (Protobuf) — discoverable via
|
|
128
|
+
`pkg-config --variable=smdir libe3`, so Python dApps can reuse the exact grammar
|
|
129
|
+
their C++ counterpart (`examples/simple_agent.cpp`) uses instead of copying it.
|