Skip to content

Commit

Permalink
python: Introduce __version__
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Mar 26, 2024
1 parent 6cea2d3 commit 8e351e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gattlib-py/gattlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import logging
import pathlib

try:
# '_version.py' is generated by 'setup.py'
from ._version import __version__
except:
pass

logger = logging.getLogger(__name__)

try:
Expand Down
9 changes: 8 additions & 1 deletion gattlib-py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
stdout, stderr = git_version_command.communicate()
git_version = stdout.decode('utf-8').strip()

#
# Create '_version.py'
#
package_version = os.environ.get('GATTLIB_PY_VERSION', git_version)
with open(os.path.join("gattlib", "_version.py"), "w") as f:
f.write(f"__version__ = \"{package_version}\"\n")


class CMakeExtension(Extension):
"""Custom extension class that allows to specify the root folder of the CMake project."""
Expand Down Expand Up @@ -149,7 +156,7 @@ def build_extension(self, ext: CMakeExtension) -> None:

setup(
name='gattlib-py',
version=os.environ.get('GATTLIB_PY_VERSION', git_version),
version=package_version,
author="Olivier Martin",
author_email="olivier@labapart.com",
description="Python wrapper for gattlib library",
Expand Down

0 comments on commit 8e351e7

Please sign in to comment.