diff --git a/setup.py b/setup.py index 7884d27..10f3ca5 100755 --- a/setup.py +++ b/setup.py @@ -203,15 +203,15 @@ if sys.version_info[0] < 3: FileNotFoundError = EnvironmentError module_pEp = Extension( - 'native_pEp', + 'pEp._pEp', sources=[ - 'src/pEp/native_pEp/pEpmodule.cc', - 'src/pEp/native_pEp/basic_api.cc', - 'src/pEp/native_pEp/identity.cc', - 'src/pEp/native_pEp/message.cc', - 'src/pEp/native_pEp/message_api.cc', - 'src/pEp/native_pEp/str_attr.cc', - # 'src/pEp/native_pEp/user_interface.cc', + 'src/pEp/_pEp/pEpmodule.cc', + 'src/pEp/_pEp/basic_api.cc', + 'src/pEp/_pEp/identity.cc', + 'src/pEp/_pEp/message.cc', + 'src/pEp/_pEp/message_api.cc', + 'src/pEp/_pEp/str_attr.cc', + # 'src/pEp/_pEp/user_interface.cc', ], ) diff --git a/src/pEp/__init__.py b/src/pEp/__init__.py index ab29698..1af6eac 100755 --- a/src/pEp/__init__.py +++ b/src/pEp/__init__.py @@ -1,25 +1,35 @@ +# -*- coding: UTF-8 -*- # pEp package -# This file is being exectued upon 'import pEp' +# +# The names that are in _pEp that do not begin with an underscore, will be be imported into, and "re-exported" from this module. +# They are defined in boost-python/C++, and are directly part of the pEpPythonAdapter API +# The names that are in _pEp that DO begin with an underscore, will not be imported into this module, but will be accessible like _pEp._underscore_function(). +# They are not directly part of the pEpPythonAdapter API, and are meant to be wrapped in this module. +# Example: +# def underscore_function(): +# _pEp._underscore_function() # # __all__ could be used to limit the symbols exported when using from import * -from pkg_resources import DistributionNotFound, get_distribution +# TODO: Commented out until problems solved +# from pkg_resources import DistributionNotFound, get_distribution + +# Imports all symbols EXCEPT the ones beginning with underscore +from ._pEp import * -# Import all symbols EXCEPT the ones beginning with underscore into the current namespace -from native_pEp import * -# TODO: inter-pkg ref to make sure which native_pEp in sys.path gets loaded -# like: pEp.native_pEp -# import the module -import native_pEp +# import the native module into the current namespace because we also need to access the names beginning +# with an underscore (of _pEp), but we dont want to import them into this module +import ._pEp -try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - print("Package is not installed.") +# TODO: Commented out until problems solved +# try: +# __version__ = get_distribution(__name__).version +# except DistributionNotFound: +# print("Package is not installed.") # Executed on module import def init(): print(init, "called") - native_pEp._init_after_main_module() + _pEp._init_after_main_module() def message_to_send(msg): diff --git a/src/pEp/native_pEp/basic_api.cc b/src/pEp/_pEp/basic_api.cc similarity index 100% rename from src/pEp/native_pEp/basic_api.cc rename to src/pEp/_pEp/basic_api.cc diff --git a/src/pEp/native_pEp/basic_api.hh b/src/pEp/_pEp/basic_api.hh similarity index 100% rename from src/pEp/native_pEp/basic_api.hh rename to src/pEp/_pEp/basic_api.hh diff --git a/src/pEp/native_pEp/identity.cc b/src/pEp/_pEp/identity.cc similarity index 100% rename from src/pEp/native_pEp/identity.cc rename to src/pEp/_pEp/identity.cc diff --git a/src/pEp/native_pEp/identity.hh b/src/pEp/_pEp/identity.hh similarity index 100% rename from src/pEp/native_pEp/identity.hh rename to src/pEp/_pEp/identity.hh diff --git a/src/pEp/native_pEp/message.cc b/src/pEp/_pEp/message.cc similarity index 100% rename from src/pEp/native_pEp/message.cc rename to src/pEp/_pEp/message.cc diff --git a/src/pEp/native_pEp/message.hh b/src/pEp/_pEp/message.hh similarity index 100% rename from src/pEp/native_pEp/message.hh rename to src/pEp/_pEp/message.hh diff --git a/src/pEp/native_pEp/message_api.cc b/src/pEp/_pEp/message_api.cc similarity index 100% rename from src/pEp/native_pEp/message_api.cc rename to src/pEp/_pEp/message_api.cc diff --git a/src/pEp/native_pEp/message_api.hh b/src/pEp/_pEp/message_api.hh similarity index 100% rename from src/pEp/native_pEp/message_api.hh rename to src/pEp/_pEp/message_api.hh diff --git a/src/pEp/native_pEp/pEpmodule.cc b/src/pEp/_pEp/pEpmodule.cc similarity index 99% rename from src/pEp/native_pEp/pEpmodule.cc rename to src/pEp/_pEp/pEpmodule.cc index 3d2bff1..73a1f6d 100644 --- a/src/pEp/native_pEp/pEpmodule.cc +++ b/src/pEp/_pEp/pEpmodule.cc @@ -178,7 +178,7 @@ namespace pEp { _throw_status(status); } - BOOST_PYTHON_MODULE(native_pEp) { + BOOST_PYTHON_MODULE(_pEp) { init_before_main_module(); // Module init function called by pEp.init() diff --git a/src/pEp/native_pEp/pEpmodule.hh b/src/pEp/_pEp/pEpmodule.hh similarity index 100% rename from src/pEp/native_pEp/pEpmodule.hh rename to src/pEp/_pEp/pEpmodule.hh diff --git a/src/pEp/native_pEp/str_attr.cc b/src/pEp/_pEp/str_attr.cc similarity index 100% rename from src/pEp/native_pEp/str_attr.cc rename to src/pEp/_pEp/str_attr.cc diff --git a/src/pEp/native_pEp/str_attr.hh b/src/pEp/_pEp/str_attr.hh similarity index 100% rename from src/pEp/native_pEp/str_attr.hh rename to src/pEp/_pEp/str_attr.hh diff --git a/src/pEp/native_pEp/user_interface.cc b/src/pEp/_pEp/user_interface.cc similarity index 100% rename from src/pEp/native_pEp/user_interface.cc rename to src/pEp/_pEp/user_interface.cc diff --git a/src/pEp/native_pEp/user_interface.hh b/src/pEp/_pEp/user_interface.hh similarity index 100% rename from src/pEp/native_pEp/user_interface.hh rename to src/pEp/_pEp/user_interface.hh diff --git a/tests/test_message.py b/tests/test_message.py index b3a0388..9787133 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -40,7 +40,7 @@ def test_msg_enc_dec_roundtrip(create_alice_identity, create_bob_identity): # AttributeError: module 'pEp' has no attribute 'PEP_rating' # assert rating == pEp.PEP_rating.PEP_rating_reliable # It seems to have changed to the following. - assert rating == pEp.native_pEp.rating.reliable + assert rating == pEp._pEp.rating.reliable # The first 2 keys are Alice's ones, the last is Bob's one. assert key_list[0] == key_list[1] == constants.ALICE_FP