From: Simon Marchi Date: Wed, 24 Jul 2019 18:54:15 +0000 (-0400) Subject: bt2: move __version__ to version.py.in X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=07041dafaae18146e189a70c33a8a0695cbdd813 bt2: move __version__ to version.py.in The only bit of __init__.py that is set at configure time is the package version. Move it to its own file, version.py.in, and make __init__.py not generated. This will make life a bit easier when we need to modify __init__.py. Change-Id: Ibc9fb67a897b226c46b4fddb3af7c2219d1f94e9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1759 CI-Build: Philippe Proulx Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/configure.ac b/configure.ac index 64bed089..3649cb45 100644 --- a/configure.ac +++ b/configure.ac @@ -689,7 +689,7 @@ AC_CONFIG_FILES([ src/babeltrace2-ctf-writer.pc src/babeltrace2.pc src/bindings/Makefile - src/bindings/python/bt2/bt2/__init__.py + src/bindings/python/bt2/bt2/version.py src/bindings/python/bt2/Makefile src/bindings/python/bt2/setup.py src/bindings/python/Makefile diff --git a/pyproject.toml b/pyproject.toml index e3a6b3c0..2b8c201e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ src/bindings/python/bt2/build/ | src/bindings/python/bt2/setup\.py$ | src/bindings/python/bt2/bt2/native_bt\.py$ - | src/bindings/python/bt2/bt2/__init__\.py$ + | src/bindings/python/bt2/bt2/version\.py$ | tests/utils/python/tap ) diff --git a/src/bindings/python/bt2/.gitignore b/src/bindings/python/bt2/.gitignore index efc7e9f1..994976c8 100644 --- a/src/bindings/python/bt2/.gitignore +++ b/src/bindings/python/bt2/.gitignore @@ -1,6 +1,6 @@ -bt2/__init__.py bt2/native_bt.py bt2/native_bt.c +bt2/version.py build build-python-bindings.stamp installed_files.txt diff --git a/src/bindings/python/bt2/Makefile.am b/src/bindings/python/bt2/Makefile.am index 2816279a..54df1e5f 100644 --- a/src/bindings/python/bt2/Makefile.am +++ b/src/bindings/python/bt2/Makefile.am @@ -41,6 +41,7 @@ STATIC_NATIVE_LIB_SRCS = \ bt2/logging.h STATIC_BINDINGS_DEPS = \ + bt2/__init__.py \ bt2/clock_class.py \ bt2/clock_snapshot.py \ bt2/component.py \ @@ -79,8 +80,8 @@ STATIC_LIBRARIES_DEPS = \ $(top_builddir)/src/py-common/libbabeltrace2-py-common.la GENERATED_BINDINGS_DEPS = \ - bt2/__init__.py \ bt2/native_bt.c \ + bt2/version.py \ setup.py BUILD_FLAGS=CC="$(CC)" \ diff --git a/src/bindings/python/bt2/bt2/__init__.py b/src/bindings/python/bt2/bt2/__init__.py new file mode 100644 index 00000000..313ede9b --- /dev/null +++ b/src/bindings/python/bt2/bt2/__init__.py @@ -0,0 +1,194 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Philippe Proulx +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# import all public names +from bt2.clock_class import ClockClassOffset +from bt2.clock_snapshot import _ClockSnapshot +from bt2.clock_snapshot import _UnknownClockSnapshot +from bt2.component import _SourceComponentClass +from bt2.component import _FilterComponentClass +from bt2.component import _SinkComponentClass +from bt2.component import _SourceComponent +from bt2.component import _FilterComponent +from bt2.component import _SinkComponent +from bt2.component import _UserSourceComponent +from bt2.component import _UserFilterComponent +from bt2.component import _UserSinkComponent +from bt2.error import ComponentClassType +from bt2.error import _ErrorCause +from bt2.error import _ComponentErrorCause +from bt2.error import _ComponentClassErrorCause +from bt2.error import _MessageIteratorErrorCause +from bt2.error import _Error +from bt2.event_class import EventClassLogLevel +from bt2.field import _IntegerField +from bt2.field import _UnsignedIntegerField +from bt2.field import _SignedIntegerField +from bt2.field import _RealField +from bt2.field import _EnumerationField +from bt2.field import _UnsignedEnumerationField +from bt2.field import _SignedEnumerationField +from bt2.field import _StringField +from bt2.field import _StructureField +from bt2.field import _VariantField +from bt2.field import _ArrayField +from bt2.field import _StaticArrayField +from bt2.field import _DynamicArrayField +from bt2.field_class import IntegerDisplayBase +from bt2.field_class import _IntegerFieldClass +from bt2.field_class import _UnsignedIntegerFieldClass +from bt2.field_class import _SignedIntegerFieldClass +from bt2.field_class import _RealFieldClass +from bt2.field_class import _EnumerationFieldClass +from bt2.field_class import _UnsignedEnumerationFieldClass +from bt2.field_class import _SignedEnumerationFieldClass +from bt2.field_class import _StringFieldClass +from bt2.field_class import _StructureFieldClass +from bt2.field_class import _VariantFieldClass +from bt2.field_class import _VariantFieldClassWithoutSelector +from bt2.field_class import _VariantFieldClassWithSelector +from bt2.field_class import _VariantFieldClassWithUnsignedSelector +from bt2.field_class import _VariantFieldClassWithSignedSelector +from bt2.field_class import _ArrayFieldClass +from bt2.field_class import _StaticArrayFieldClass +from bt2.field_class import _DynamicArrayFieldClass +from bt2.field_path import FieldPathScope +from bt2.field_path import _IndexFieldPathItem +from bt2.field_path import _CurrentArrayElementFieldPathItem +from bt2.graph import Graph +from bt2.integer_range_set import SignedIntegerRange +from bt2.integer_range_set import UnsignedIntegerRange +from bt2.integer_range_set import SignedIntegerRangeSet +from bt2.integer_range_set import UnsignedIntegerRangeSet +from bt2.interrupter import Interrupter +from bt2.logging import LoggingLevel +from bt2.logging import get_minimal_logging_level +from bt2.logging import get_global_logging_level +from bt2.logging import set_global_logging_level +from bt2.message import _EventMessage +from bt2.message import _PacketBeginningMessage +from bt2.message import _PacketEndMessage +from bt2.message import _StreamBeginningMessage +from bt2.message import _StreamEndMessage +from bt2.message import _MessageIteratorInactivityMessage +from bt2.message import _DiscardedEventsMessage +from bt2.message import _DiscardedPacketsMessage +from bt2.message_iterator import _UserMessageIterator +from bt2.plugin import find_plugins_in_path +from bt2.plugin import find_plugins +from bt2.plugin import find_plugin +from bt2.py_plugin import plugin_component_class +from bt2.py_plugin import register_plugin +from bt2.query_executor import QueryExecutor +from bt2.trace_collection_message_iterator import ComponentSpec +from bt2.trace_collection_message_iterator import TraceCollectionMessageIterator +from bt2.value import create_value +from bt2.value import BoolValue +from bt2.value import _IntegerValue +from bt2.value import UnsignedIntegerValue +from bt2.value import SignedIntegerValue +from bt2.value import RealValue +from bt2.value import StringValue +from bt2.value import ArrayValue +from bt2.value import MapValue +from bt2.version import __version__ + + +def _del_global_name(name): + if name in globals(): + del globals()[name] + + +# remove private module names from the package +_del_global_name('_native_bt') +_del_global_name('clock_class') +_del_global_name('clock_snapshot') +_del_global_name('component') +_del_global_name('connection') +_del_global_name('error') +_del_global_name('event') +_del_global_name('event_class') +_del_global_name('field') +_del_global_name('field_class') +_del_global_name('field_path') +_del_global_name('graph') +_del_global_name('integer_range_set') +_del_global_name('interrupter') +_del_global_name('logging') +_del_global_name('message') +_del_global_name('message_iterator') +_del_global_name('native_bt') +_del_global_name('object') +_del_global_name('packet') +_del_global_name('plugin') +_del_global_name('port') +_del_global_name('py_plugin') +_del_global_name('query_executor') +_del_global_name('stream') +_del_global_name('stream_class') +_del_global_name('trace') +_del_global_name('trace_class') +_del_global_name('trace_collection_message_iterator') +_del_global_name('utils') +_del_global_name('value') +_del_global_name('version') + +# remove private `_del_global_name` name from the package +del _del_global_name + + +class _MemoryError(_Error): + '''Raised when an operation fails due to memory issues.''' + + +class InvalidObject(Exception): + pass + + +class _OverflowError(_Error, OverflowError): + pass + + +class TryAgain(Exception): + pass + + +class Stop(StopIteration): + pass + + +class _IncompleteUserClass(Exception): + pass + + +def _init_and_register_exit(): + from bt2 import native_bt + import atexit + + atexit.register(native_bt.bt2_cc_exit_handler) + native_bt.bt2_cc_init_from_bt2() + + +_init_and_register_exit() + +# remove private `_init_and_register_exit` name from the package +del _init_and_register_exit diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in deleted file mode 100644 index e18188b8..00000000 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ /dev/null @@ -1,195 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2017 Philippe Proulx -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -__version__ = '@PACKAGE_VERSION@' - - -# import all public names -from bt2.clock_class import ClockClassOffset -from bt2.clock_snapshot import _ClockSnapshot -from bt2.clock_snapshot import _UnknownClockSnapshot -from bt2.component import _SourceComponentClass -from bt2.component import _FilterComponentClass -from bt2.component import _SinkComponentClass -from bt2.component import _SourceComponent -from bt2.component import _FilterComponent -from bt2.component import _SinkComponent -from bt2.component import _UserSourceComponent -from bt2.component import _UserFilterComponent -from bt2.component import _UserSinkComponent -from bt2.error import ComponentClassType -from bt2.error import _ErrorCause -from bt2.error import _ComponentErrorCause -from bt2.error import _ComponentClassErrorCause -from bt2.error import _MessageIteratorErrorCause -from bt2.error import _Error -from bt2.event_class import EventClassLogLevel -from bt2.field import _IntegerField -from bt2.field import _UnsignedIntegerField -from bt2.field import _SignedIntegerField -from bt2.field import _RealField -from bt2.field import _EnumerationField -from bt2.field import _UnsignedEnumerationField -from bt2.field import _SignedEnumerationField -from bt2.field import _StringField -from bt2.field import _StructureField -from bt2.field import _VariantField -from bt2.field import _ArrayField -from bt2.field import _StaticArrayField -from bt2.field import _DynamicArrayField -from bt2.field_class import IntegerDisplayBase -from bt2.field_class import _IntegerFieldClass -from bt2.field_class import _UnsignedIntegerFieldClass -from bt2.field_class import _SignedIntegerFieldClass -from bt2.field_class import _RealFieldClass -from bt2.field_class import _EnumerationFieldClass -from bt2.field_class import _UnsignedEnumerationFieldClass -from bt2.field_class import _SignedEnumerationFieldClass -from bt2.field_class import _StringFieldClass -from bt2.field_class import _StructureFieldClass -from bt2.field_class import _VariantFieldClass -from bt2.field_class import _VariantFieldClassWithoutSelector -from bt2.field_class import _VariantFieldClassWithSelector -from bt2.field_class import _VariantFieldClassWithUnsignedSelector -from bt2.field_class import _VariantFieldClassWithSignedSelector -from bt2.field_class import _ArrayFieldClass -from bt2.field_class import _StaticArrayFieldClass -from bt2.field_class import _DynamicArrayFieldClass -from bt2.field_path import FieldPathScope -from bt2.field_path import _IndexFieldPathItem -from bt2.field_path import _CurrentArrayElementFieldPathItem -from bt2.graph import Graph -from bt2.integer_range_set import SignedIntegerRange -from bt2.integer_range_set import UnsignedIntegerRange -from bt2.integer_range_set import SignedIntegerRangeSet -from bt2.integer_range_set import UnsignedIntegerRangeSet -from bt2.interrupter import Interrupter -from bt2.logging import LoggingLevel -from bt2.logging import get_minimal_logging_level -from bt2.logging import get_global_logging_level -from bt2.logging import set_global_logging_level -from bt2.message import _EventMessage -from bt2.message import _PacketBeginningMessage -from bt2.message import _PacketEndMessage -from bt2.message import _StreamBeginningMessage -from bt2.message import _StreamEndMessage -from bt2.message import _MessageIteratorInactivityMessage -from bt2.message import _DiscardedEventsMessage -from bt2.message import _DiscardedPacketsMessage -from bt2.message_iterator import _UserMessageIterator -from bt2.plugin import find_plugins_in_path -from bt2.plugin import find_plugins -from bt2.plugin import find_plugin -from bt2.py_plugin import plugin_component_class -from bt2.py_plugin import register_plugin -from bt2.query_executor import QueryExecutor -from bt2.trace_collection_message_iterator import ComponentSpec -from bt2.trace_collection_message_iterator import TraceCollectionMessageIterator -from bt2.value import create_value -from bt2.value import BoolValue -from bt2.value import _IntegerValue -from bt2.value import UnsignedIntegerValue -from bt2.value import SignedIntegerValue -from bt2.value import RealValue -from bt2.value import StringValue -from bt2.value import ArrayValue -from bt2.value import MapValue - - -def _del_global_name(name): - if name in globals(): - del globals()[name] - - -# remove private module names from the package -_del_global_name('_native_bt') -_del_global_name('clock_class') -_del_global_name('clock_snapshot') -_del_global_name('component') -_del_global_name('connection') -_del_global_name('error') -_del_global_name('event') -_del_global_name('event_class') -_del_global_name('field') -_del_global_name('field_class') -_del_global_name('field_path') -_del_global_name('graph') -_del_global_name('integer_range_set') -_del_global_name('interrupter') -_del_global_name('logging') -_del_global_name('message') -_del_global_name('message_iterator') -_del_global_name('native_bt') -_del_global_name('object') -_del_global_name('packet') -_del_global_name('plugin') -_del_global_name('port') -_del_global_name('py_plugin') -_del_global_name('query_executor') -_del_global_name('stream') -_del_global_name('stream_class') -_del_global_name('trace') -_del_global_name('trace_class') -_del_global_name('trace_collection_message_iterator') -_del_global_name('utils') -_del_global_name('value') - -# remove private `_del_global_name` name from the package -del _del_global_name - - -class _MemoryError(_Error): - '''Raised when an operation fails due to memory issues.''' - - -class InvalidObject(Exception): - pass - - -class _OverflowError(_Error, OverflowError): - pass - - -class TryAgain(Exception): - pass - - -class Stop(StopIteration): - pass - - -class _IncompleteUserClass(Exception): - pass - - -def _init_and_register_exit(): - from bt2 import native_bt - import atexit - - atexit.register(native_bt.bt2_cc_exit_handler) - native_bt.bt2_cc_init_from_bt2() - - -_init_and_register_exit() - -# remove private `_init_and_register_exit` name from the package -del _init_and_register_exit diff --git a/src/bindings/python/bt2/bt2/version.py.in b/src/bindings/python/bt2/bt2/version.py.in new file mode 100644 index 00000000..b2f0cc4e --- /dev/null +++ b/src/bindings/python/bt2/bt2/version.py.in @@ -0,0 +1,23 @@ +# The MIT License (MIT) +# +# Copyright (c) 2017 Philippe Proulx +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +__version__ = '@PACKAGE_VERSION@'