tuberd 0.14__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.
- tuberd-0.14/.git_archival.txt +3 -0
- tuberd-0.14/.gitattributes +1 -0
- tuberd-0.14/.github/workflows/black.yml +11 -0
- tuberd-0.14/.github/workflows/cmake.yml +54 -0
- tuberd-0.14/.github/workflows/package.yml +137 -0
- tuberd-0.14/.gitignore +21 -0
- tuberd-0.14/CHANGES +126 -0
- tuberd-0.14/CMakeLists.txt +45 -0
- tuberd-0.14/LICENSE +27 -0
- tuberd-0.14/PKG-INFO +206 -0
- tuberd-0.14/README.rst +159 -0
- tuberd-0.14/include/tuber_support.hpp +180 -0
- tuberd-0.14/pyproject.toml +36 -0
- tuberd-0.14/requirements.txt +7 -0
- tuberd-0.14/setup.cfg +4 -0
- tuberd-0.14/setup.py +121 -0
- tuberd-0.14/src/server.cpp +659 -0
- tuberd-0.14/tests/__init__.py +0 -0
- tuberd-0.14/tests/conftest.py +30 -0
- tuberd-0.14/tests/test.py +711 -0
- tuberd-0.14/tests/test_module.cpp +46 -0
- tuberd-0.14/tuber/__init__.py +44 -0
- tuberd-0.14/tuber/_version.py +16 -0
- tuberd-0.14/tuber/client.py +559 -0
- tuberd-0.14/tuber/codecs.py +228 -0
- tuberd-0.14/tuber/server.py +87 -0
- tuberd-0.14/tuberd.egg-info/PKG-INFO +206 -0
- tuberd-0.14/tuberd.egg-info/SOURCES.txt +38 -0
- tuberd-0.14/tuberd.egg-info/dependency_links.txt +1 -0
- tuberd-0.14/tuberd.egg-info/requires.txt +7 -0
- tuberd-0.14/tuberd.egg-info/top_level.txt +2 -0
- tuberd-0.14/wheels/FindLibHttpServer.cmake +42 -0
- tuberd-0.14/wheels/install_deps.sh +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.git_archival.txt export-subst
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CMake
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
CC: gcc-10
|
|
11
|
+
CXX: g++-10
|
|
12
|
+
LD_LIBRARY_PATH: /usr/local/lib # this is where libhttpserver installs itself
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Check out libhttpserver dependency
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
with:
|
|
24
|
+
repository: etr/libhttpserver
|
|
25
|
+
ref: 0.19.0
|
|
26
|
+
path: libhttpserver
|
|
27
|
+
|
|
28
|
+
- name: Install Python dependencies
|
|
29
|
+
uses: py-actions/py-dependency-install@v4
|
|
30
|
+
|
|
31
|
+
- name: Install C++ dependencies
|
|
32
|
+
run: |
|
|
33
|
+
sudo apt-get update
|
|
34
|
+
sudo apt-get install -y libmicrohttpd-dev libfmt-dev pybind11-dev
|
|
35
|
+
|
|
36
|
+
- name: Build and install libhttpserver
|
|
37
|
+
run: |
|
|
38
|
+
cd libhttpserver
|
|
39
|
+
./bootstrap
|
|
40
|
+
mkdir build
|
|
41
|
+
cd build
|
|
42
|
+
../configure
|
|
43
|
+
make
|
|
44
|
+
sudo make install
|
|
45
|
+
|
|
46
|
+
- name: Configure CMake
|
|
47
|
+
run: cmake -B ${{github.workspace}}/build -DCMAKE_MODULE_PATH=/usr/local/share/cmake/Modules
|
|
48
|
+
|
|
49
|
+
- name: Build
|
|
50
|
+
run: cmake --build ${{github.workspace}}/build
|
|
51
|
+
|
|
52
|
+
- name: Test
|
|
53
|
+
working-directory: ${{github.workspace}}/build
|
|
54
|
+
run: ctest --verbose
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
release:
|
|
10
|
+
types: [ published ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build_wheels_linux:
|
|
14
|
+
name: Build wheels for cp3${{ matrix.python_version_minor }}
|
|
15
|
+
runs-on: ubuntu-20.04
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python_version_minor: [8, 9, 10, 11, 12]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
fetch-tags: true
|
|
27
|
+
|
|
28
|
+
- name: Setup python
|
|
29
|
+
uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: 3.${{ matrix.python_version_minor }}
|
|
32
|
+
architecture: x64
|
|
33
|
+
|
|
34
|
+
- name: Install dependencies
|
|
35
|
+
run: |
|
|
36
|
+
pip install --upgrade patchelf auditwheel
|
|
37
|
+
./wheels/install_deps.sh
|
|
38
|
+
|
|
39
|
+
- name: Build wheel
|
|
40
|
+
run: pip wheel . -w wheelhouse -vvv
|
|
41
|
+
|
|
42
|
+
- name: Repair wheel
|
|
43
|
+
run: >
|
|
44
|
+
auditwheel -v repair ./wheelhouse/tuberd*.whl
|
|
45
|
+
--exclude libpython3.${{ matrix.python_version_minor }}.so
|
|
46
|
+
--plat manylinux_2_31_x86_64
|
|
47
|
+
|
|
48
|
+
- name: Install wheel for tests
|
|
49
|
+
run: pip install ./wheelhouse/tuberd*manylinux*.whl
|
|
50
|
+
|
|
51
|
+
- name: Run tests
|
|
52
|
+
run: |
|
|
53
|
+
cd tests
|
|
54
|
+
./test.py --import-mode append
|
|
55
|
+
./test.py --import-mode append --orjson-with-numpy
|
|
56
|
+
|
|
57
|
+
- name: Upload artifacts
|
|
58
|
+
uses: actions/upload-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: cibw-wheels-${{ runner.os }}-cp3${{ matrix.python_version_minor }}
|
|
61
|
+
path: ./wheelhouse/tuberd*manylinux*.whl
|
|
62
|
+
|
|
63
|
+
build_wheels_osx:
|
|
64
|
+
name: Build wheels on ${{ matrix.os }}
|
|
65
|
+
runs-on: ${{ matrix.os }}
|
|
66
|
+
strategy:
|
|
67
|
+
fail-fast: false
|
|
68
|
+
matrix:
|
|
69
|
+
include:
|
|
70
|
+
# macos-13 is an intel runner, macos-14 is apple silicon
|
|
71
|
+
- os: macos-13
|
|
72
|
+
target: 10.15
|
|
73
|
+
- os: macos-14
|
|
74
|
+
target: 11.0
|
|
75
|
+
|
|
76
|
+
steps:
|
|
77
|
+
- name: Set macOS deployment target
|
|
78
|
+
run: echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.target }}" >> $GITHUB_ENV
|
|
79
|
+
|
|
80
|
+
- name: Checkout
|
|
81
|
+
uses: actions/checkout@v4
|
|
82
|
+
with:
|
|
83
|
+
fetch-depth: 0
|
|
84
|
+
fetch-tags: true
|
|
85
|
+
|
|
86
|
+
- name: Build wheels
|
|
87
|
+
uses: pypa/cibuildwheel@v2.20.0
|
|
88
|
+
env:
|
|
89
|
+
CIBW_BEFORE_ALL: brew install automake libtool && ./wheels/install_deps.sh
|
|
90
|
+
CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} -e Python.framework"
|
|
91
|
+
CIBW_BUILD_VERBOSITY: 3
|
|
92
|
+
CIBW_SKIP: cp36-* cp37-* cp313-* cp38-macosx_arm64 pp*
|
|
93
|
+
CIBW_TEST_COMMAND: >
|
|
94
|
+
{project}/tests/test.py --import-mode append &&
|
|
95
|
+
{project}/tests/test.py --import-mode append --orjson-with-numpy
|
|
96
|
+
|
|
97
|
+
- name: Upload artifacts
|
|
98
|
+
uses: actions/upload-artifact@v4
|
|
99
|
+
with:
|
|
100
|
+
name: cibw-wheels-${{ matrix.os }}
|
|
101
|
+
path: ./wheelhouse/tuberd*.whl
|
|
102
|
+
|
|
103
|
+
build_sdist:
|
|
104
|
+
name: Build source distribution
|
|
105
|
+
runs-on: ubuntu-latest
|
|
106
|
+
steps:
|
|
107
|
+
- uses: actions/checkout@v4
|
|
108
|
+
with:
|
|
109
|
+
fetch-depth: 0
|
|
110
|
+
fetch-tags: true
|
|
111
|
+
|
|
112
|
+
- name: Build sdist
|
|
113
|
+
run: pipx run build --sdist
|
|
114
|
+
|
|
115
|
+
- uses: actions/upload-artifact@v4
|
|
116
|
+
with:
|
|
117
|
+
name: cibw-sdist
|
|
118
|
+
path: dist/*.tar.gz
|
|
119
|
+
|
|
120
|
+
upload_pypi:
|
|
121
|
+
needs: [build_wheels_linux, build_wheels_osx, build_sdist]
|
|
122
|
+
runs-on: ubuntu-latest
|
|
123
|
+
environment: pypi
|
|
124
|
+
permissions:
|
|
125
|
+
id-token: write
|
|
126
|
+
if: github.event_name == 'release' && github.event.action == 'published'
|
|
127
|
+
steps:
|
|
128
|
+
- name: Download artifacts
|
|
129
|
+
uses: actions/download-artifact@v4
|
|
130
|
+
with:
|
|
131
|
+
# unpacks all CIBW artifacts into dist/
|
|
132
|
+
pattern: cibw-*
|
|
133
|
+
path: dist
|
|
134
|
+
merge-multiple: true
|
|
135
|
+
|
|
136
|
+
- name: Publish package distributions to PyPI
|
|
137
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
tuberd-0.14/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
CMakeFiles/
|
|
2
|
+
CMakeCache.txt
|
|
3
|
+
CTestTestfile.cmake
|
|
4
|
+
DartConfiguration.tcl
|
|
5
|
+
Testing/
|
|
6
|
+
Makefile
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
_build/
|
|
10
|
+
_deps/
|
|
11
|
+
_generate/
|
|
12
|
+
cmake_install.cmake
|
|
13
|
+
*.so
|
|
14
|
+
*.py[cod]
|
|
15
|
+
*.egg-info
|
|
16
|
+
*env*
|
|
17
|
+
*.swp
|
|
18
|
+
tuberd
|
|
19
|
+
tuber/_version.py
|
|
20
|
+
Pipfile
|
|
21
|
+
deps/
|
tuberd-0.14/CHANGES
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Version 0.14
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
- CI/CD improvements: builds wheels for manylinux and OS X
|
|
5
|
+
|
|
6
|
+
Version 0.13
|
|
7
|
+
============
|
|
8
|
+
|
|
9
|
+
- A "simple" (non-asyncio) client now lives alongside the asyncio client. The
|
|
10
|
+
points of entry for these are "resolve" and "resolve_simple". They are
|
|
11
|
+
approximately API-compatible, but the non-asyncio version entirely avoids
|
|
12
|
+
async code style (async def / await / ...).
|
|
13
|
+
|
|
14
|
+
- Multiple calls (using a Context or SimpleContext) can now optionally continue
|
|
15
|
+
after errors, using the continue_on_error flag. When this is True, all calls
|
|
16
|
+
in a Context/SimpleContext run to completion even if some of them fail.
|
|
17
|
+
The default behaviour remains the same - when continue_on_error is False,
|
|
18
|
+
server-side execution proceeds in sequence and halts at the first call that
|
|
19
|
+
encounters an error.
|
|
20
|
+
|
|
21
|
+
Version 0.12
|
|
22
|
+
============
|
|
23
|
+
|
|
24
|
+
- Headers are now properly included in binary builds (.whl files)
|
|
25
|
+
- Corrected PYTHONPATH for "make test"; broken in 0.11.
|
|
26
|
+
|
|
27
|
+
Version 0.11
|
|
28
|
+
============
|
|
29
|
+
|
|
30
|
+
- resolve now required (20)
|
|
31
|
+
- tuber package rearranged to tuber.server / tuber.client; registry moved to server (#19)
|
|
32
|
+
- linter (black) added to CI/CD flow (#17)
|
|
33
|
+
- client-side Python packages (aiohttpd) no longer required in server environment (#18)
|
|
34
|
+
- setuptools now builds client and server (#14)
|
|
35
|
+
|
|
36
|
+
Version 0.10
|
|
37
|
+
============
|
|
38
|
+
|
|
39
|
+
- Adds support for CBOR as a transport mechanism.
|
|
40
|
+
|
|
41
|
+
Version 0.9
|
|
42
|
+
===========
|
|
43
|
+
|
|
44
|
+
- Removes dependency on boost::program_options in favour of getoptA
|
|
45
|
+
- Compatibility fixes for libfmt, libhttpserver, OS X, Clang
|
|
46
|
+
|
|
47
|
+
Version 0.8
|
|
48
|
+
===========
|
|
49
|
+
|
|
50
|
+
- Compatibility fix for libfmt
|
|
51
|
+
|
|
52
|
+
Version 0.7
|
|
53
|
+
===========
|
|
54
|
+
|
|
55
|
+
Released 2023-12-11
|
|
56
|
+
|
|
57
|
+
* New features:
|
|
58
|
+
|
|
59
|
+
- Added support for warnings.warn calls in server-side code - these are
|
|
60
|
+
propagated through a "warnings" field in the result object and bubbled up
|
|
61
|
+
as client-side warnings.
|
|
62
|
+
|
|
63
|
+
Version 0.6
|
|
64
|
+
===========
|
|
65
|
+
|
|
66
|
+
Released 2023-02-24
|
|
67
|
+
|
|
68
|
+
* Fixes:
|
|
69
|
+
|
|
70
|
+
- Acquire GIL earlier in response scope, outside "try" block. Otherwise, the
|
|
71
|
+
exception path occurs outside the GIL block, and it's not valid to use
|
|
72
|
+
json_dumps to emit error messages. Fixes a segfault when invalid JSON is
|
|
73
|
+
supplied.
|
|
74
|
+
|
|
75
|
+
Version 0.5
|
|
76
|
+
===========
|
|
77
|
+
|
|
78
|
+
Released 2022-05-24
|
|
79
|
+
|
|
80
|
+
* Fixes:
|
|
81
|
+
|
|
82
|
+
- Correct preamble install path.
|
|
83
|
+
|
|
84
|
+
Version 0.4
|
|
85
|
+
===========
|
|
86
|
+
|
|
87
|
+
Released 2022-04-14
|
|
88
|
+
|
|
89
|
+
* Features:
|
|
90
|
+
|
|
91
|
+
- Adds --orjson-with-numpy extension to enable orjson fast-path. This
|
|
92
|
+
serializer offers significant performance gains, especially when using
|
|
93
|
+
numpy objects.
|
|
94
|
+
|
|
95
|
+
Version 0.3
|
|
96
|
+
===========
|
|
97
|
+
|
|
98
|
+
Released 2022-04-07
|
|
99
|
+
|
|
100
|
+
* Features:
|
|
101
|
+
|
|
102
|
+
- Adds option for use of user-specified JSON module.
|
|
103
|
+
|
|
104
|
+
Version 0.2
|
|
105
|
+
===========
|
|
106
|
+
|
|
107
|
+
Released 2022-04-06
|
|
108
|
+
|
|
109
|
+
* Features:
|
|
110
|
+
|
|
111
|
+
- Removes dependency on nlohmann::json. The JSON dependency is intended to
|
|
112
|
+
speed up serialization. The Python-native JSON serializer is implemented in
|
|
113
|
+
C under the hood, and should be better able to avoid casual
|
|
114
|
+
copy-conversions of arguments and results.
|
|
115
|
+
|
|
116
|
+
- Adds Python test framework. The test framework is a starting point (it does not exercise unhappy
|
|
117
|
+
paths or argument variations right now.)
|
|
118
|
+
|
|
119
|
+
Version 0.1
|
|
120
|
+
===========
|
|
121
|
+
|
|
122
|
+
Released 2022-04-03
|
|
123
|
+
|
|
124
|
+
* Features:
|
|
125
|
+
|
|
126
|
+
- Initial release.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Build instructions for tuberd server only. The client portion is installed
|
|
2
|
+
# via setuptools.
|
|
3
|
+
|
|
4
|
+
cmake_minimum_required(VERSION 3.16...3.22)
|
|
5
|
+
project(tuberd VERSION 1.0.0 LANGUAGES CXX)
|
|
6
|
+
|
|
7
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
8
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
9
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|
10
|
+
|
|
11
|
+
# link against deps dir
|
|
12
|
+
if(EXISTS ${CMAKE_SOURCE_DIR}/deps)
|
|
13
|
+
message(STATUS "Found deps: ${CMAKE_SOURCE_DIR}/deps")
|
|
14
|
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/deps/share/cmake/Modules")
|
|
15
|
+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/deps")
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
|
19
|
+
find_package(fmt REQUIRED)
|
|
20
|
+
find_package(LibHttpServer REQUIRED)
|
|
21
|
+
find_package(pybind11 REQUIRED)
|
|
22
|
+
find_package(Threads REQUIRED)
|
|
23
|
+
|
|
24
|
+
include(CTest)
|
|
25
|
+
|
|
26
|
+
add_executable(tuberd src/server.cpp)
|
|
27
|
+
target_link_libraries(tuberd PRIVATE fmt::fmt ${LIBHTTPSERVER_LIBRARIES} pybind11::embed Threads::Threads)
|
|
28
|
+
|
|
29
|
+
pybind11_add_module(test_module MODULE tests/test_module.cpp)
|
|
30
|
+
target_include_directories(test_module PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
31
|
+
target_link_libraries(test_module PRIVATE fmt::fmt)
|
|
32
|
+
|
|
33
|
+
add_test(NAME test-native-json
|
|
34
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
35
|
+
COMMAND tests/test.py)
|
|
36
|
+
|
|
37
|
+
add_test(NAME test-orjson-fastpath
|
|
38
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
39
|
+
COMMAND tests/test.py --orjson-with-numpy)
|
|
40
|
+
|
|
41
|
+
set_tests_properties(test-native-json test-orjson-fastpath
|
|
42
|
+
PROPERTIES ENVIRONMENT "PATH=${CMAKE_BINARY_DIR}:$ENV{PATH};PYTHONPATH=${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}")
|
|
43
|
+
|
|
44
|
+
set_target_properties(tuberd PROPERTIES PUBLIC_HEADER "include/tuber_support.hpp")
|
|
45
|
+
install(TARGETS tuberd PUBLIC_HEADER DESTINATION include)
|
tuberd-0.14/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2023-2024 Graeme Smecher <gsmecher@threespeedlogic.com>
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
15
|
+
may be used to endorse or promote products derived from this software
|
|
16
|
+
without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
tuberd-0.14/PKG-INFO
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: tuberd
|
|
3
|
+
Version: 0.14
|
|
4
|
+
Summary: Serve Python (or C++) objects across a LAN using something like JSON-RPC
|
|
5
|
+
Author-email: Graeme Smecher <gsmecher@threespeedlogic.com>
|
|
6
|
+
License: Copyright (c) 2023-2024 Graeme Smecher <gsmecher@threespeedlogic.com>
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
|
10
|
+
modification, are permitted provided that the following conditions are met:
|
|
11
|
+
|
|
12
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
13
|
+
list of conditions and the following disclaimer.
|
|
14
|
+
|
|
15
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
16
|
+
this list of conditions and the following disclaimer in the documentation
|
|
17
|
+
and/or other materials provided with the distribution.
|
|
18
|
+
|
|
19
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
20
|
+
may be used to endorse or promote products derived from this software
|
|
21
|
+
without specific prior written permission.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
24
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
25
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
26
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
27
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
28
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
29
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
30
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
31
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
32
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
|
|
34
|
+
Project-URL: source, https://github.com/gsmecher/tuberd
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Description-Content-Type: text/x-rst
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Requires-Dist: numpy
|
|
41
|
+
Requires-Dist: orjson
|
|
42
|
+
Requires-Dist: pytest
|
|
43
|
+
Requires-Dist: requests
|
|
44
|
+
Requires-Dist: aiohttp
|
|
45
|
+
Requires-Dist: pytest-asyncio
|
|
46
|
+
Requires-Dist: cbor2
|
|
47
|
+
|
|
48
|
+
.. image:: https://badge.fury.io/py/tuberd.svg
|
|
49
|
+
:target: https://badge.fury.io/py/tuberd
|
|
50
|
+
|
|
51
|
+
.. image:: https://github.com/gsmecher/tuberd/actions/workflows/package.yml/badge.svg
|
|
52
|
+
:target: https://github.com/gsmecher/tuberd/actions/workflows/package.yml
|
|
53
|
+
|
|
54
|
+
Tuber Server and Client
|
|
55
|
+
=======================
|
|
56
|
+
|
|
57
|
+
Tuber_ is a C++ server and Python client for exposing an instrumentation
|
|
58
|
+
control plane across a network.
|
|
59
|
+
|
|
60
|
+
On a client, you can write Python code like this:
|
|
61
|
+
|
|
62
|
+
.. code:: python
|
|
63
|
+
|
|
64
|
+
>>> some_resource.increment([1, 2, 3, 4, 5])
|
|
65
|
+
[2, 3, 4, 5, 6]
|
|
66
|
+
|
|
67
|
+
...and end up with a remote method call on a networked resource written in
|
|
68
|
+
Python or (more usually) C++. The C++ implementation might look like this:
|
|
69
|
+
|
|
70
|
+
.. code:: c++
|
|
71
|
+
|
|
72
|
+
class SomeResource {
|
|
73
|
+
public:
|
|
74
|
+
std::vector<int> increment(std::vector<int> x) {
|
|
75
|
+
std::ranges::for_each(x, [](int &n) { n++; });
|
|
76
|
+
return x;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
On the client side, Python needs to know where to find the server. On the
|
|
81
|
+
server side, the C++ code must be registered with pybind11 (just as any other
|
|
82
|
+
pybind11 code) and the tuber server. Other than that, however, there is no
|
|
83
|
+
ceremony and no boilerplate.
|
|
84
|
+
|
|
85
|
+
Its main features and design principles are:
|
|
86
|
+
|
|
87
|
+
- Pythonic call styles, including \*args, \*\*kwargs, and DocStrings.
|
|
88
|
+
|
|
89
|
+
- JSON and CBOR support for efficient and friendly serialization of return
|
|
90
|
+
values.
|
|
91
|
+
|
|
92
|
+
- "Less-is-more" approach to code. For example, Tuber uses pybind11_ and C++ as
|
|
93
|
+
a shim between C and Python, because the combination gives us the shortest
|
|
94
|
+
and most expressive way to produce the results we want. It pairs excellently
|
|
95
|
+
with orjson_ (as a JSON interface) or cbor2_ (as a CBOR interface), which
|
|
96
|
+
efficiently serialize (for example) NumPy_ arrays created in C++ across the
|
|
97
|
+
network.
|
|
98
|
+
|
|
99
|
+
- Schema-less RPC using standard-ish protocols (HTTP 1.1, JSON, CBOR, and
|
|
100
|
+
something like JSON-RPC_). Avoiding a schema allows server and client code to
|
|
101
|
+
be independently and seamlessly up- and downgraded, with differences between
|
|
102
|
+
exposed APIs only visible at the sites where RPC calls are made.
|
|
103
|
+
|
|
104
|
+
- A mature, quick-ish, third-party, low-overhead, low-prerequisite embedded
|
|
105
|
+
webserver. Tuber uses libhttpserver_, which in turn, is a C++ wrapper around
|
|
106
|
+
the well-established libmicrohttpd_. We use the thread-per-connection
|
|
107
|
+
configuration because a single keep-alive connection with a single client is
|
|
108
|
+
the expected "hot path"; C10K_-style server architectures wouldn't be better.
|
|
109
|
+
|
|
110
|
+
- High performance when communicating with RPC endpoints, using:
|
|
111
|
+
|
|
112
|
+
- HTTP/1.1 Keep-Alive to avoid single-connection-per-request overhead. See
|
|
113
|
+
`this Wikipedia page
|
|
114
|
+
<https://en.wikipedia.org/wiki/HTTP_persistent_connection#HTTP_1.1>`_ for
|
|
115
|
+
details.
|
|
116
|
+
|
|
117
|
+
- A call API that (optionally) allows multiple RPC calls to be combined and
|
|
118
|
+
dispatched together.
|
|
119
|
+
|
|
120
|
+
- Client-side caches for remote properties (server-side constants)
|
|
121
|
+
|
|
122
|
+
- Python 3.x's aiohttp_/asyncio_ libraries to asynchronously dispatch across
|
|
123
|
+
multiple endpoints (e.g. multiple boards in a crate, each of which is an
|
|
124
|
+
independent Tuber endpoint.)
|
|
125
|
+
|
|
126
|
+
- A friendly interactive experience using Jupyter_/IPython_-style REPL
|
|
127
|
+
environments. Tuber servers export metadata that can be used to provide
|
|
128
|
+
DocStrings and tab-completion for RPC resources.
|
|
129
|
+
|
|
130
|
+
- The ability to serve a web-based UI using static JavaScript, CSS, and HTML.
|
|
131
|
+
|
|
132
|
+
Anti-goals of this Tuber server include the following:
|
|
133
|
+
|
|
134
|
+
- No authentication/encryption is used. For now, network security is strictly
|
|
135
|
+
out-of-scope. (Yes, it feels naïve to write this in 2022.)
|
|
136
|
+
|
|
137
|
+
- The additional complexity of HTTP/2 and HTTP/3 protocols are not justified.
|
|
138
|
+
HTTP/1.1 keep-alive obviates much of the performance gains promised by
|
|
139
|
+
connection multiplexing.
|
|
140
|
+
|
|
141
|
+
- The performance gains possible using a binary RPC protocol do not justify the
|
|
142
|
+
loss of a human-readable, browser-accessible JSON protocol.
|
|
143
|
+
|
|
144
|
+
- The use of newer, better languages than C++ (server side) or Python (client
|
|
145
|
+
side). The instruments Tuber targets are likely to be a polyglot stew, and I
|
|
146
|
+
am mindful that every additional language or runtime reduces the project's
|
|
147
|
+
accessibility to newcomers. Perhaps pybind11_ will be eclipsed by something
|
|
148
|
+
in Rust one day - for now, the ability to make casual cross-language calls is
|
|
149
|
+
essential to keeping Tuber small. (Exception: the orjson JSON library is a
|
|
150
|
+
wonderful complement to tuber and I recommend using them together!)
|
|
151
|
+
|
|
152
|
+
Although the Tuber server hosts an embedded Python interpreter and can expose
|
|
153
|
+
embedded resources coded in ordinary Python, it is intended to expose C/C++
|
|
154
|
+
code. The Python interpeter provides a convenient, Pythonic approach to
|
|
155
|
+
attribute and method lookup and dispatch without the overhead of a fully
|
|
156
|
+
interpreted embedded runtime.
|
|
157
|
+
|
|
158
|
+
Tuber is licensed using the 3-clause BSD license (BSD-3-Clause). This software
|
|
159
|
+
is intended to be useful, and its licensing is intended to be pragmatic. If
|
|
160
|
+
licensing is a stumbling block for you, please contact me at
|
|
161
|
+
`gsmecher@threespeedlogic.com <mailto:gsmecher@threespeedlogic.com>`_.
|
|
162
|
+
|
|
163
|
+
.. _Tuber: https://github.com/gsmecher/tuber
|
|
164
|
+
.. _GPLv3: https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
165
|
+
.. _Jupyter: https://jupyter.org/
|
|
166
|
+
.. _IPython: https://ipython.org/
|
|
167
|
+
.. _libhttpserver: https://github.com/etr/libhttpserver
|
|
168
|
+
.. _NumPy: https://www.numpy.org
|
|
169
|
+
.. _orjson: https://github.com/ijl/orjson
|
|
170
|
+
.. _cbor2: https://github.com/agronholm/cbor2
|
|
171
|
+
.. _libmicrohttpd: https://www.gnu.org/software/libmicrohttpd/
|
|
172
|
+
.. _JSON-RPC: https://www.jsonrpc.org/
|
|
173
|
+
.. _pybind11: https://pybind11.readthedocs.io/en/stable/index.html
|
|
174
|
+
.. _C10K: http://www.kegel.com/c10k.html
|
|
175
|
+
.. _asyncio: https://docs.python.org/3/library/asyncio.html
|
|
176
|
+
.. _aiohttp: https://docs.aiohttp.org/en/stable/
|
|
177
|
+
.. _autoawait: https://ipython.readthedocs.io/en/stable/interactive/autoawait.html
|
|
178
|
+
|
|
179
|
+
Installation
|
|
180
|
+
------------
|
|
181
|
+
|
|
182
|
+
Pre-built wheels for Linux and macOS operating systems are available on PyPI for
|
|
183
|
+
CPython 3.8+:
|
|
184
|
+
|
|
185
|
+
.. code:: bash
|
|
186
|
+
|
|
187
|
+
pip install tuberd
|
|
188
|
+
|
|
189
|
+
Building from source requires the ``libfmt`` and ``libmicrohttpd`` dependencies,
|
|
190
|
+
along with ``libhttpserver``. To ensure that ``cmake`` can find the
|
|
191
|
+
``libhttpserver`` library, you may need to add the path where the
|
|
192
|
+
``FindLibHttpServer.cmake`` file is installed to the ``CMAKE_MODULE_PATH``
|
|
193
|
+
option, for example:
|
|
194
|
+
|
|
195
|
+
.. code:: bash
|
|
196
|
+
|
|
197
|
+
CMAKE_ARGS="-DCMAKE_MODULE_PATH=/usr/local/share/cmake/Modules" pip install .
|
|
198
|
+
|
|
199
|
+
To simplify the build process, the ``wheels/install_deps.sh`` script can be used to
|
|
200
|
+
build all the dependencies locally and compile against them. In this instance,
|
|
201
|
+
``cmake`` should be able to discover the appropriate paths for all dependencies:
|
|
202
|
+
|
|
203
|
+
.. code:: bash
|
|
204
|
+
|
|
205
|
+
./wheels/install_deps.sh
|
|
206
|
+
pip install .
|