Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/modules/registration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#endif

#include <sprokit/pipeline/utils.h>
#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_exceptions.h>
#include <sprokit/python/util/python_gil.h>
#include <sprokit/python/util/python.h>
Expand Down Expand Up @@ -80,6 +81,9 @@ class scoped_save_thread
};


static sprokit::python::pyoptions options;


// ==================================================================
/**
* @brief Python module loader.
Expand Down
5 changes: 5 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>

#include <sprokit/python/util/pyoptions.h>

#include <sstream>

/**
Expand Down Expand Up @@ -76,6 +78,9 @@ static void config_delitem( kwiver::vital::config_block_sptr self,
kwiver::vital::config_block_key_t const& key );


static sprokit::python::pyoptions options;


PYBIND11_MODULE(config, m)
{
m.def("empty_config", &kwiver::vital::config_block::empty_config
Expand Down
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/datum.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <sprokit/pipeline/datum.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_gil.h>

// Type conversions
Expand Down Expand Up @@ -86,6 +87,9 @@ template<class T> T datum_get_object(sprokit::datum &);
char const* sprokit_datum_PyCapsule_name() { return "sprokit::datum"; }


static sprokit::python::pyoptions options;


PYBIND11_MODULE(datum, m)
{

Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/edge.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <sprokit/pipeline/edge.h>
#include <sprokit/pipeline/stamp.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_gil.h>

#include <pybind11/stl_bind.h>
Expand All @@ -50,6 +51,8 @@ static void push_datum(sprokit::edge& self, wrap_edge_datum const& datum);
static wrap_edge_datum get_datum(sprokit::edge& self);
static wrap_edge_datum peek_datum(sprokit::edge& self, pybind11::size_t const& idx);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(edge, m)
{
class_<wrap_edge_datum>(m, "EdgeDatum")
Expand Down
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/modules.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <pybind11/pybind11.h>

#include <sprokit/python/util/pyoptions.h>

/**
* \file modules.cxx
*
Expand All @@ -49,6 +51,8 @@ void load_known_modules()
kwiver::vital::plugin_manager::instance().load_all_plugins();
}

static sprokit::python::pyoptions options;

PYBIND11_MODULE(modules, m)
{
m.def("load_known_modules", &sprokit::load_known_modules
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/pipeline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <sprokit/pipeline/pipeline.h>
#include <sprokit/pipeline/process_cluster.h>
#include <sprokit/python/util/pyoptions.h>

#if WIN32
#pragma warning (push)
Expand All @@ -54,6 +55,8 @@ static std::shared_ptr<wrap_process_cluster> cluster_by_name(sprokit::pipeline&
static std::vector<wrap_port_addr> connections_from_addr(sprokit::pipeline& self, sprokit::process::name_t const& name, sprokit::process::port_t const& port);
static std::vector<wrap_port_addr> receivers_for_port(sprokit::pipeline& self, sprokit::process::name_t const& name, sprokit::process::port_t const& port);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(pipeline,m)
{
bind_vector<std::vector<std::string> >(m, "names_t");
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/process.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
typedef std::set<std::string> string_set; // This has to be done first thing, or the macro breaks
PYBIND11_MAKE_OPAQUE(string_set)

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_exceptions.h>

#include <pybind11/stl_bind.h>
Expand Down Expand Up @@ -155,6 +156,8 @@ void push_datum_to_port(sprokit::process &self, sprokit::process::port_t const&

std::string config_value(sprokit::process &self, kwiver::vital::config_block_key_t const& key);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(process, m)
{
bind_vector<sprokit::process::names_t>(m, "ProcessNames"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <sprokit/pipeline/process.h>
#include <sprokit/pipeline/process_cluster.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_exceptions.h>
#include <sprokit/python/util/python_gil.h>

Expand All @@ -49,6 +50,8 @@ using namespace pybind11;

static object cluster_from_process(sprokit::process_t const& process);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(process_cluster, m)
{
class_<sprokit::process_cluster, wrap_process_cluster, sprokit::process_cluster_t, sprokit::process >(m, "PythonProcessCluster"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <sprokit/pipeline/process_factory.h>
#include <sprokit/pipeline/process_registry_exception.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_exceptions.h>
#include <sprokit/python/util/python_gil.h>

Expand Down Expand Up @@ -129,6 +130,9 @@ create_object(kwiver::vital::config_block_sptr const& config)
}


static sprokit::python::pyoptions options;


// ==================================================================
PYBIND11_MODULE(process_factory, m)
{
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/scheduler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <sprokit/pipeline/pipeline.h>
#include <sprokit/pipeline/scheduler.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_exceptions.h>
#include <sprokit/python/util/python_gil.h>

Expand Down Expand Up @@ -73,6 +74,8 @@ class scheduler_trampoline
void _stop() override;
};

static sprokit::python::pyoptions options;

PYBIND11_MODULE(scheduler, m)
{
class_<sprokit::scheduler, scheduler_trampoline, sprokit::scheduler_t>(m, "PythonScheduler"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <sprokit/pipeline/scheduler_factory.h>
#include <sprokit/pipeline/scheduler_registry_exception.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/python_gil.h>
#include <sprokit/python/util/python_exceptions.h>

Expand Down Expand Up @@ -111,6 +112,9 @@ create_object(sprokit::pipeline_t const& pipe, kwiver::vital::config_block_sptr
}


static sprokit::python::pyoptions options;


//==================================================================
PYBIND11_MODULE(scheduler_factory, m)
{
Expand Down
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/stamp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "python_wrappers.cxx"

#include <sprokit/python/util/pyoptions.h>

/**
* \file stamp.cxx
*
Expand All @@ -40,6 +42,8 @@

using namespace pybind11;

static sprokit::python::pyoptions options;

PYBIND11_MODULE(stamp, m)
{
m.def("new_stamp", &new_stamp
Expand Down
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include <sprokit/pipeline/utils.h>

#include <sprokit/python/util/pyoptions.h>

/**
* \file utils.cxx
*
Expand All @@ -41,6 +43,8 @@

using namespace pybind11;

static sprokit::python::pyoptions options;

PYBIND11_MODULE(utils, m)
{
m.def("name_thread", &sprokit::name_thread
Expand Down
4 changes: 4 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline/version.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <sprokit/version.h>

#include <sprokit/python/util/pyoptions.h>


/**
* \file version.cxx
Expand Down Expand Up @@ -78,6 +80,8 @@ class runtime
{
};

static sprokit::python::pyoptions options;

PYBIND11_MODULE(version, m)
{
class_<compile>(m,"compile"
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline_util/bake.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sprokit/pipeline/pipeline.h>
#include <sprokit/pipeline/process_factory.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/pystream.h>
#include <sprokit/python/util/python_gil.h>

Expand All @@ -61,6 +62,8 @@ static sprokit::pipeline_t bake_pipe(object stream);
static sprokit::cluster_info_t bake_cluster_file(std::string const& path);
static sprokit::cluster_info_t bake_cluster(object stream);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(bake, m)
{
class_<sprokit::cluster_info, sprokit::cluster_info_t>(m, "ClusterInfo"
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline_util/export.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sprokit/pipeline_util/export_dot.h>
#include <sprokit/pipeline_util/export_dot_exception.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/pystream.h>
#include <sprokit/python/util/python_gil.h>

Expand All @@ -50,6 +51,8 @@ using namespace pybind11;

void export_dot(object const& stream, sprokit::pipeline_t const pipe, std::string const& graph_name);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(export_, m)
{
m.def("export_dot", &export_dot, call_guard<gil_scoped_release>()
Expand Down
3 changes: 3 additions & 0 deletions sprokit/src/bindings/python/sprokit/pipeline_util/load.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <sprokit/pipeline/process.h>

#include <sprokit/python/util/pyoptions.h>
#include <sprokit/python/util/pystream.h>
#include <sprokit/python/util/python_gil.h>

Expand Down Expand Up @@ -79,6 +80,8 @@ static sprokit::cluster_blocks load_cluster(object const& stream);
static std::vector<wrap_port_addr> get_targets(sprokit::cluster_input_t const& self);
static void set_targets(sprokit::cluster_input_t &self, std::vector<wrap_port_addr> const& wrap_targets);

static sprokit::python::pyoptions options;

PYBIND11_MODULE(load, m)
{
bind_vector<sprokit::config_flags_t>(m, "ConfigFlags"
Expand Down
1 change: 1 addition & 0 deletions sprokit/src/sprokit/python/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(python_util_srcs
python_exceptions.cxx)

set(python_util_headers
pyoptions.h
python_exceptions.h
python_gil.h
python.h)
Expand Down
55 changes: 55 additions & 0 deletions sprokit/src/sprokit/python/util/pyoptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*ckwg +29
* Copyright 2011-2013 by Kitware, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither name of Kitware, Inc. nor the names of any contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef SPROKIT_PYTHON_UTIL_PYOPTIONS_H
#define SPROKIT_PYTHON_UTIL_PYOPTIONS_H

#include <pybind11/pybind11.h>

namespace sprokit {
namespace python {

// NOTE: This has to be in the header because pybind11 is header-only, so each
// shared library gets its own copy of the pybind11::options singleton. DO NOT
// EXPORT THIS CLASS!
class pyoptions
: public pybind11::options
{
public:
pyoptions()
{
enable_use_gilstate();
}
};

}
}

#endif // SPROKIT_PYTHON_UTIL_PYOPTIONS_H