File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ PYBIND11_MODULE(pybind, m) {
1919
2020 auto subM = m.def_submodule (" sub" , " submodule" );
2121 subM.def (" second_func" , &second_func, " " );
22- auto subSubM = subM.def_submodule (" sub_sub " , " sub submodule" );
22+ auto subSubM = subM.def_submodule (" _sub_private " , " sub submodule" );
2323 subSubM.def (" sub_sub_func" , &sub_sub_func, " " );
24- subSubM.def (" _sub_sub_private_func " , &sub_sub_func, " private sub func" );
24+ subSubM.def (" _sub_private_private_func " , &sub_sub_func, " private sub func" );
2525}
Original file line number Diff line number Diff line change 88from pybind .pybind_copy import _EXTRA_SYMBOL as REGULAR_COPY_EXTRA_SYMBOL
99from pybind .pybind .sub import second_func as sub_second_func
1010import pybind .pybind .sub
11- from pybind .pybind .sub .sub_sub import *
12- from pybind .pybind .sub .sub_sub import _sub_sub_private_func
11+ from pybind .pybind .sub ._sub_private import *
12+ from pybind .pybind .sub ._sub_private import _sub_private_private_func
1313from pybind .sub_pybind .relative_import_lib import call_nested_pyind_func
1414from pybind .sub_pybind .relative_import_lib import sub_sub_private_func
1515
@@ -56,8 +56,8 @@ def test_pybind_first(self):
5656 print ("14: Submodules" )
5757 self .assertEqual (sub_second_func (1 ), 5 )
5858 self .assertEqual (pybind .pybind .sub .second_func (1 ), 6 )
59- self .assertEqual (pybind .pybind .sub .sub_sub .sub_sub_func (3 ), 6 )
60- self .assertEqual (_sub_sub_private_func (5 ), 10 )
59+ self .assertEqual (pybind .pybind .sub ._sub_private .sub_sub_func (3 ), 6 )
60+ self .assertEqual (_sub_private_private_func (5 ), 10 )
6161
6262 print ("15: Nested pybinds and relative imports" )
6363 self .assertEqual (call_nested_pyind_func (6 ), 3 )
Original file line number Diff line number Diff line change 11from .nested_pybind import nested_pybind_func
2- from ..pybind .sub .sub_sub import _sub_sub_private_func
2+ from ..pybind .sub ._sub_private import _sub_private_private_func
33
44def call_nested_pyind_func (x ):
55 return nested_pybind_func (x )
66
77def sub_sub_private_func (x ):
8- return _sub_sub_private_func (x )
8+ return _sub_private_private_func (x )
Original file line number Diff line number Diff line change 88from pybind .pybind_copy import _EXTRA_SYMBOL as REGULAR_COPY_EXTRA_SYMBOL
99from pybind .pybind .sub import second_func as sub_second_func
1010import pybind .pybind .sub
11- from pybind .pybind .sub .sub_sub import *
12- from pybind .pybind .sub .sub_sub import _sub_sub_private_func
11+ from pybind .pybind .sub ._sub_private import *
12+ from pybind .pybind .sub ._sub_private import _sub_private_private_func
1313from pybind .sub_pybind .relative_import_lib import call_nested_pyind_func
1414from pybind .sub_pybind .relative_import_lib import sub_sub_private_func
1515
@@ -56,8 +56,8 @@ def test_pybind_first(self):
5656 print ("14: Submodules" )
5757 self .assertEqual (sub_second_func (1 ), 5 )
5858 self .assertEqual (pybind .pybind .sub .second_func (1 ), 6 )
59- self .assertEqual (pybind .pybind .sub .sub_sub .sub_sub_func (3 ), 6 )
60- self .assertEqual (_sub_sub_private_func (5 ), 10 )
59+ self .assertEqual (pybind .pybind .sub ._sub_private .sub_sub_func (3 ), 6 )
60+ self .assertEqual (_sub_private_private_func (5 ), 10 )
6161
6262 print ("15: Nested pybinds and relative imports" )
6363 self .assertEqual (call_nested_pyind_func (6 ), 3 )
Original file line number Diff line number Diff line change @@ -2,11 +2,7 @@ from sys import modules
22from types import ModuleType
33
44def __update_globals(new_import_path, pywrap_m):
5- if hasattr(pywrap_m, '__all__'):
6- all_names = pywrap_m.__all__
7- else:
8- all_names = [name for name in dir(pywrap_m) if not name.startswith('_')]
9-
5+ all_names = pywrap_m.__all__ if hasattr(pywrap_m, '__all__') else dir(pywrap_m)
106 modules[new_import_path] = pywrap_m
117 for name in all_names:
128 sub_pywrap = getattr(pywrap_m, name)
You can’t perform that action at this time.
0 commit comments