Merge remote-tracking branch 'origin/stable' into debian/sid
This commit is contained in:
commit
1de786f1cc
4
setup.py
4
setup.py
|
@ -3,7 +3,7 @@ from setuptools import setup
|
||||||
# Available at setup time due to pyproject.toml
|
# Available at setup time due to pyproject.toml
|
||||||
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
||||||
|
|
||||||
__version__ = "1.0.2"
|
__version__ = "1.0.3"
|
||||||
|
|
||||||
# Note:
|
# Note:
|
||||||
# Sort input source files if you glob sources to ensure bit-for-bit
|
# Sort input source files if you glob sources to ensure bit-for-bit
|
||||||
|
@ -11,7 +11,7 @@ __version__ = "1.0.2"
|
||||||
|
|
||||||
ext_modules = [Pybind11Extension(
|
ext_modules = [Pybind11Extension(
|
||||||
"oxenmq",
|
"oxenmq",
|
||||||
["src/bencode.cpp", "src/module.cpp", "src/oxenmq.cpp"],
|
["src/oxenmq.cpp"],
|
||||||
cxx_std=17,
|
cxx_std=17,
|
||||||
libraries=["oxenmq"],
|
libraries=["oxenmq"],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
#include "common.hpp"
|
|
||||||
#include "oxenmq/base32z.h"
|
|
||||||
|
|
||||||
namespace oxenmq {
|
|
||||||
|
|
||||||
void BEncode_Init(py::module& mod) {
|
|
||||||
mod.def("base32z_encode", [](py::bytes data) {
|
|
||||||
char* ptr = nullptr;
|
|
||||||
py::ssize_t sz = 0;
|
|
||||||
PyBytes_AsStringAndSize(data.ptr(), &ptr, &sz);
|
|
||||||
return oxenmq::to_base32z(ptr, ptr+sz);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <pybind11/pybind11.h>
|
|
||||||
#include <pybind11/stl.h>
|
|
||||||
#include <pybind11/functional.h>
|
|
||||||
|
|
||||||
namespace py = pybind11;
|
|
||||||
|
|
||||||
namespace oxenmq {
|
|
||||||
|
|
||||||
void OxenMQ_Init(py::module &mod);
|
|
||||||
void BEncode_Init(py::module & mod);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include "common.hpp"
|
|
||||||
|
|
||||||
PYBIND11_MODULE(oxenmq, m) {
|
|
||||||
oxenmq::OxenMQ_Init(m);
|
|
||||||
oxenmq::BEncode_Init(m);
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "common.hpp"
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <oxenmq/oxenmq.h>
|
#include <oxenmq/oxenmq.h>
|
||||||
|
@ -14,6 +13,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
|
namespace py = pybind11;
|
||||||
|
|
||||||
namespace oxenmq {
|
namespace oxenmq {
|
||||||
|
|
||||||
// Convert a py::object containing a str, bytes, or iterable over str/bytes to a vector of message
|
// Convert a py::object containing a str, bytes, or iterable over str/bytes to a vector of message
|
||||||
|
@ -51,8 +52,7 @@ struct stderr_logger {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
PYBIND11_MODULE(oxenmq, mod)
|
||||||
OxenMQ_Init(py::module& mod)
|
|
||||||
{
|
{
|
||||||
using namespace pybind11::literals;
|
using namespace pybind11::literals;
|
||||||
constexpr py::kw_only kwonly{};
|
constexpr py::kw_only kwonly{};
|
||||||
|
@ -151,7 +151,7 @@ This typically protects administrative commands like shutting down or access to
|
||||||
|
|
||||||
py::class_<Message> msg(mod, "Message", "Temporary object containing details of a just-received message");
|
py::class_<Message> msg(mod, "Message", "Temporary object containing details of a just-received message");
|
||||||
msg
|
msg
|
||||||
.def_property_readonly("is_reply", [](const Message& m) { return !m.reply_tag.empty(); },
|
.def_property_readonly("is_request", [](const Message& m) { return !m.reply_tag.empty(); },
|
||||||
"True if this message is expecting a reply (i.e. it was received on a request_command endpoint)")
|
"True if this message is expecting a reply (i.e. it was received on a request_command endpoint)")
|
||||||
.def_readonly("remote", &Message::remote, py::return_value_policy::copy,
|
.def_readonly("remote", &Message::remote, py::return_value_policy::copy,
|
||||||
R"(Some sort of remote address from which the request came.
|
R"(Some sort of remote address from which the request came.
|
||||||
|
@ -187,7 +187,7 @@ or .to_bytes() on each one)"
|
||||||
R"(Sends a reply back to this caller.
|
R"(Sends a reply back to this caller.
|
||||||
|
|
||||||
`args` must be bytes, str, or iterables thereof (and will be flatted). Should only be used from a
|
`args` must be bytes, str, or iterables thereof (and will be flatted). Should only be used from a
|
||||||
request_command endpoint (i.e. when .is_reply is true)")
|
request_command endpoint (i.e. when .is_request is true)")
|
||||||
.def("back", [](Message& m, std::string command, py::args args) {
|
.def("back", [](Message& m, std::string command, py::args args) {
|
||||||
m.send_back(command, send_option::data_parts(extract_data_parts(args)));
|
m.send_back(command, send_option::data_parts(extract_data_parts(args)));
|
||||||
},
|
},
|
||||||
|
@ -223,7 +223,7 @@ instance is still alive).)")
|
||||||
;
|
;
|
||||||
|
|
||||||
py::class_<Message::DeferredSend>(msg, "DeferredSend")
|
py::class_<Message::DeferredSend>(msg, "DeferredSend")
|
||||||
.def_property_readonly("is_reply", [](const Message::DeferredSend& m) { return !m.reply_tag.empty(); },
|
.def_property_readonly("is_request", [](const Message::DeferredSend& m) { return !m.reply_tag.empty(); },
|
||||||
"True if this message is expecting a reply (i.e. it was received on a request_command endpoint)")
|
"True if this message is expecting a reply (i.e. it was received on a request_command endpoint)")
|
||||||
.def("reply", [](Message::DeferredSend& d, py::args args) {
|
.def("reply", [](Message::DeferredSend& d, py::args args) {
|
||||||
d.reply(send_option::data_parts(extract_data_parts(args)));
|
d.reply(send_option::data_parts(extract_data_parts(args)));
|
||||||
|
|
Loading…
Reference in New Issue