diff options
author | prettyboy <prettyboy@yandex-team.com> | 2023-09-08 00:22:12 +0300 |
---|---|---|
committer | prettyboy <prettyboy@yandex-team.com> | 2023-09-08 00:46:04 +0300 |
commit | 3a6cd865171eed9b89bf536cd242285f8b583a91 (patch) | |
tree | 25e2756c125f7484fb118e0d5724212199662389 /library/cpp/pybind/v2.cpp | |
parent | 67f3f216950849664a29035458cfaa5d12a62846 (diff) | |
download | ydb-3a6cd865171eed9b89bf536cd242285f8b583a91.tar.gz |
[build/plugins/ytest] Allow prebuilt linters for opensource
Без этого, ydb или не сможет запускать flake8 с помощью ya make.
Или к ним поедет сборка flake8.
Возможно последнее и не так плохо, но сейчас предлагается пока так
Diffstat (limited to 'library/cpp/pybind/v2.cpp')
-rw-r--r-- | library/cpp/pybind/v2.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/cpp/pybind/v2.cpp b/library/cpp/pybind/v2.cpp new file mode 100644 index 00000000000..edce0be7195 --- /dev/null +++ b/library/cpp/pybind/v2.cpp @@ -0,0 +1,43 @@ +#include "v2.h" +namespace NPyBind { + namespace Detail { + template <> + PyTypeObject* GetParentType<void>(const TPyModuleDefinition&) { + return nullptr; + } + + + template <bool InitEnabled> + void UpdateClassNamesInModule(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType) { + if (!InitEnabled) { + return; + } + M.ClassName2Type[name] = pythonType; + } + + template <bool InitEnabled> + void UpdateGetContextInModule(TPyModuleDefinition& M, const TString& name, IGetContextBase* base) { + if (!InitEnabled) { + return; + } + M.Class2ContextGetter[name] = base; + } + + TPyModuleRegistry::TPyModuleRegistry() { +#if PY_MAJOR_VERSION >= 3 + NPrivate::AddFinalizationCallBack([this]() { + if (UnnamedModule) { + UnnamedModule.Clear(); + } + Name2Def.clear(); + }); +#endif + } + template void UpdateClassNamesInModule<false>(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType); + template void UpdateClassNamesInModule<true>(TPyModuleDefinition& M, const TString& name, PyTypeObject* pythonType); + + + template void UpdateGetContextInModule<false>(TPyModuleDefinition& M, const TString& name, IGetContextBase* pythonType); + template void UpdateGetContextInModule<true>(TPyModuleDefinition& M, const TString& name, IGetContextBase* pythonType); + }//Detail +}//NPyBind |