]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
python: Correctly set and use __version__
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jun 2020 14:21:55 +0000 (14:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jun 2020 14:21:55 +0000 (14:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
src/python/__init__.py.in [moved from src/python/__init__.py with 98% similarity]
src/python/downloader.py

index 4dd8c86539e4b696a92e157eb1610916cab436d6..d368dbd7cc3205900226403f663bdae8cbb8fb17 100644 (file)
@@ -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
index 8cec76d538b7ae448564450cbfa3e13af57f971e..6beb609d281e15bd98ce6a553b8fd2bd08767418 100644 (file)
@@ -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
 
similarity index 98%
rename from src/python/__init__.py
rename to src/python/__init__.py.in
index 9b570c797c552ecf151e451de2b560980a4b27d3..bd94d3555b51fbf4e0645572cada7bafa859c438 100644 (file)
@@ -17,6 +17,8 @@
 #                                                                             #
 ###############################################################################
 
+__version__ = "@VERSION@"
+
 # Import everything from the C module
 from _location import *
 
index eb28007fc0b2561c9d83b6e2aa6aabd59cbc04e5..5caad5188a4502b44a526638ca44135c1efe70cc 100644 (file)
@@ -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