From a90c9738f505a87b4a5411facf8a63e4df166f50 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 24 Jul 2019 14:54:15 -0400 Subject: [PATCH] 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 --- configure.ac | 2 +- pyproject.toml | 2 +- src/bindings/python/bt2/.gitignore | 2 +- src/bindings/python/bt2/Makefile.am | 3 ++- .../bt2/bt2/{__init__.py.in => __init__.py} | 5 ++-- src/bindings/python/bt2/bt2/version.py.in | 23 +++++++++++++++++++ 6 files changed, 30 insertions(+), 7 deletions(-) rename src/bindings/python/bt2/bt2/{__init__.py.in => __init__.py} (99%) create mode 100644 src/bindings/python/bt2/bt2/version.py.in diff --git a/configure.ac b/configure.ac index 268de124..951b50ce 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.in b/src/bindings/python/bt2/bt2/__init__.py similarity index 99% rename from src/bindings/python/bt2/bt2/__init__.py.in rename to src/bindings/python/bt2/bt2/__init__.py index e18188b8..313ede9b 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py @@ -20,9 +20,6 @@ # 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 @@ -113,6 +110,7 @@ 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): @@ -152,6 +150,7 @@ _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 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@' -- 2.34.1