Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-14828: Update pybind11 wrappers for 2.2 #17

Merged
merged 3 commits into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.cache
.pytest_cache
pytest_session.txt
.coverage
_build.*
.sconsign.dblite
config.log
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/defaultPolicyFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(defaultPolicyFile) {
py::module mod("defaultPolicyFile");

PYBIND11_MODULE(defaultPolicyFile, mod) {
py::class_<DefaultPolicyFile, std::shared_ptr<DefaultPolicyFile>, PolicyFile> cls(mod,
"DefaultPolicyFile");

Expand All @@ -44,8 +42,6 @@ PYBIND11_PLUGIN(defaultPolicyFile) {
cls.def("load", &DefaultPolicyFile::load);
cls.def("getRepositoryPath",
[](DefaultPolicyFile const& self) -> std::string { return self.getRepositoryPath().native(); });

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(dictionary) {
py::module mod("dictionary");

PYBIND11_MODULE(dictionary, mod) {
py::class_<Dictionary, std::shared_ptr<Dictionary>, Policy> clsDictionary(mod, "Dictionary");

clsDictionary.def(py::init<>());
Expand Down Expand Up @@ -96,8 +94,6 @@ PYBIND11_PLUGIN(dictionary) {
clsDefinition.def("getMaxOccurs", &Definition::getMaxOccurs);
clsDefinition.def("getMinOccurs", &Definition::getMinOccurs);
clsDefinition.def("check", &Definition::check);

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/paf/pafWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ namespace pex {
namespace policy {
namespace paf {

PYBIND11_PLUGIN(pafWriter) {
py::module mod("pafWriter");

PYBIND11_MODULE(pafWriter, mod) {
py::class_<PAFWriter> cls(mod, "PAFWriter");

cls.def(py::init<>());
Expand All @@ -53,8 +51,6 @@ PYBIND11_PLUGIN(pafWriter) {
"policy"_a, "doDecl"_a = false);
cls.def("close", (void (PAFWriter::*)()) & PAFWriter::close);
cls.def("toString", (std::string (PAFWriter::*)()) & PAFWriter::toString);

return mod.ptr();
}

} // paf
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/policy/policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(policy) {
py::module mod("policy");

PYBIND11_MODULE(policy, mod) {
exceptions::python::declareException<BadNameError, exceptions::RuntimeError>(mod, "BadNameError",
"RuntimeError");
exceptions::python::declareException<DictionaryError, exceptions::DomainError>(mod, "DictionaryError",
Expand Down Expand Up @@ -192,8 +190,6 @@ PYBIND11_PLUGIN(policy) {
clsPolicy.def("toString", &Policy::toString);
clsPolicy.def("__str__", &Policy::toString); // Cleanup stringification later
clsPolicy.def("asPropertySet", &Policy::asPropertySet);

return mod.ptr();
}

} // policy
Expand Down
9 changes: 2 additions & 7 deletions python/lsst/pex/policy/policyFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(policyFile) {
py::module mod("policyFile");

PYBIND11_MODULE(policyFile, mod) {
py::class_<PolicyFile, std::shared_ptr<PolicyFile>, PolicySource> cls(mod, "PolicyFile");

// SupportedFormats is not exposed to Python so don't export the default argument
cls.def("__init__",
[](PolicyFile& self, std::string const& filepath) { new (&self) PolicyFile(filepath); });
cls.def(py::init([](std::string const& filepath) { return new PolicyFile(filepath); }));

cls.def("getPath", &PolicyFile::getPath);
cls.def("exists", &PolicyFile::exists);
Expand All @@ -47,8 +44,6 @@ PYBIND11_PLUGIN(policyFile) {

cls.def_readonly_static("EXT_PAF", &PolicyFile::EXT_PAF);
cls.def_readonly_static("EXT_XML", &PolicyFile::EXT_XML);

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/policySource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(policySource) {
PYBIND11_MODULE(policySource, mod) {
py::module::import("lsst.pex.exceptions");
py::module mod("policySource");

py::class_<PolicySource, std::shared_ptr<PolicySource>> cls(mod, "PolicySource");

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/policyString.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(policyString) {
py::module mod("policyString");

PYBIND11_MODULE(policyString, mod) {
py::class_<PolicyString, std::shared_ptr<PolicyString>, PolicySource> cls(mod, "PolicyString");

cls.def(py::init<const std::string&, const SupportedFormats::Ptr&>(), "data"_a,
"fmts"_a = PolicyString::defaultFormats);

cls.def(py::init<const SupportedFormats::Ptr&>(), "fmts"_a = PolicyString::defaultFormats);

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/policyStringDestination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(policyStringDestination) {
py::module mod("policyStringDestination");

PYBIND11_MODULE(policyStringDestination, mod) {
py::class_<PolicyStringDestination> cls(mod, "PolicyStringDestination");

cls.def(py::init<>());
cls.def(py::init<const std::string&>());
cls.def("getData", &PolicyStringDestination::getData);

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/supportedFormats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(supportedFormats) {
py::module mod("supportedFormats");

PYBIND11_MODULE(supportedFormats, mod) {
py::class_<SupportedFormats, std::shared_ptr<SupportedFormats>> cls(mod, "SupportedFormats");

cls.def(py::init<>());
Expand All @@ -41,8 +39,6 @@ PYBIND11_PLUGIN(supportedFormats) {
cls.def("recognizeType", &SupportedFormats::recognizeType);
cls.def("supports", &SupportedFormats::supports);
cls.def("size", &SupportedFormats::size);

return mod.ptr();
}

} // policy
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/pex/policy/urnPolicyFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ namespace lsst {
namespace pex {
namespace policy {

PYBIND11_PLUGIN(urnPolicyFile) {
py::module mod("urnPolicyFile");

PYBIND11_MODULE(urnPolicyFile, mod) {
py::class_<UrnPolicyFile, std::shared_ptr<UrnPolicyFile>, DefaultPolicyFile> cls(mod, "UrnPolicyFile");

cls.def(py::init<const std::string&, bool, bool>(), "urn"_a, "strictUrn"_a = false,
Expand All @@ -46,8 +44,6 @@ PYBIND11_PLUGIN(urnPolicyFile) {
cls.def_readonly_static("URN_PREFIX", &UrnPolicyFile::URN_PREFIX);
cls.def_readonly_static("URN_PREFIX_ABBREV", &UrnPolicyFile::URN_PREFIX_ABBREV);
cls.def_static("looksLikeUrn", &UrnPolicyFile::looksLikeUrn);

return mod.ptr();
}

} // policy
Expand Down