From 7865c7d4b820b94430e2f1219529348c52d5a183 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 12 Jun 2020 14:21:55 +0000 Subject: [PATCH] python: Correctly set and use __version__ Signed-off-by: Michael Tremer --- .gitignore | 1 + Makefile.am | 10 +++++++++- src/python/{__init__.py => __init__.py.in} | 2 ++ src/python/downloader.py | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) rename src/python/{__init__.py => __init__.py.in} (98%) diff --git a/.gitignore b/.gitignore index 4dd8c86..d368dbd 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ Makefile.in /stamp-h1 /src/python/location /src/python/location-importer +/src/python/__init__.py /src/systemd/location-update.service /src/systemd/location-update.timer /test.db diff --git a/Makefile.am b/Makefile.am index 8cec76d..6beb609 100644 --- a/Makefile.am +++ b/Makefile.am @@ -148,7 +148,6 @@ CLEANFILES += \ src/libloc.pc dist_pkgpython_PYTHON = \ - src/python/__init__.py \ src/python/database.py \ src/python/downloader.py \ src/python/export.py \ @@ -156,6 +155,15 @@ dist_pkgpython_PYTHON = \ src/python/importer.py \ src/python/logger.py +pkgpython_PYTHON = \ + src/python/__init__.py + +EXTRA_DIST += \ + src/python/__init__.py.in + +CLEANFILES += \ + src/python/__init__.py + pyexec_LTLIBRARIES = \ src/python/_location.la diff --git a/src/python/__init__.py b/src/python/__init__.py.in similarity index 98% rename from src/python/__init__.py rename to src/python/__init__.py.in index 9b570c7..bd94d35 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py.in @@ -17,6 +17,8 @@ # # ############################################################################### +__version__ = "@VERSION@" + # Import everything from the C module from _location import * diff --git a/src/python/downloader.py b/src/python/downloader.py index eb28007..5caad51 100644 --- a/src/python/downloader.py +++ b/src/python/downloader.py @@ -28,6 +28,7 @@ import urllib.error import urllib.parse import urllib.request +from . import __version__ from _location import Database, DATABASE_VERSION_LATEST DATABASE_FILENAME = "location.db.xz" @@ -71,7 +72,7 @@ class Downloader(object): # Update headers headers.update({ - "User-Agent" : "location/@VERSION@", + "User-Agent" : "location/%s" % __version__, }) # Set headers -- 2.39.5