Move version number from __init__.py to __main__.py

This will allow the access from outside the package. setup.py and the
Makefile can use this version number. The __init__.py script imports
the version number, so the module will have the __version__ variable
as usual.
This commit is contained in:
2023-01-15 18:05:51 +01:00
parent 15058feb7e
commit 8e2b8311ef
5 changed files with 19 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "RevPi Commander" #define MyAppName "RevPi Commander"
#define MyAppVersion "0.9.10rc3" #define MyAppVersion "0.9.10rc4"
#define MyAppPublisher "Sven Sager" #define MyAppPublisher "Sven Sager"
#define MyAppURL "https://revpimodio.org/" #define MyAppURL "https://revpimodio.org/"
#define MyAppICO "data\revpicommander.ico" #define MyAppICO "data\revpicommander.ico"

View File

@@ -6,9 +6,11 @@ __license__ = "GPLv3"
from setuptools import find_namespace_packages, setup from setuptools import find_namespace_packages, setup
from src.revpicommander.__main__ import __version__
setup( setup(
name="revpicommander", name="revpicommander",
version="0.9.10rc3", version=__version__,
packages=find_namespace_packages("src"), packages=find_namespace_packages("src"),
package_dir={'': 'src'}, package_dir={'': 'src'},

View File

@@ -3,4 +3,5 @@
__author__ = "Sven Sager" __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2023 Sven Sager" __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv3" __license__ = "GPLv3"
__version__ = "0.9.10rc3"
from .__main__ import __version__

View File

@@ -3,6 +3,7 @@
__author__ = "Sven Sager" __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2023 Sven Sager" __copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "GPLv3" __license__ = "GPLv3"
__version__ = "0.9.10rc4"
# If we are running from a wheel, add the wheel to sys.path # If we are running from a wheel, add the wheel to sys.path
if __package__ == "": if __package__ == "":
@@ -16,6 +17,13 @@ if __package__ == "":
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
if len(sys.argv) == 2 and "--version" in sys.argv:
# Catch --version, if this is the only argument (sys.argv[0] is always the script name)
print(__version__)
sys.exit(0)
else:
from revpicommander.revpicommander import main from revpicommander.revpicommander import main
# Run the main application of this package # Run the main application of this package

View File

@@ -89,11 +89,12 @@ parser.add_argument(
"-f", "--logfile", dest="logfile", "-f", "--logfile", dest="logfile",
help="Save log entries to this file" help="Save log entries to this file"
) )
parser.add_argument( parser.add_argument(
"-v", "--verbose", action="count", dest="verbose", default=0, "-v", "--verbose", action="count", dest="verbose", default=0,
help="Switch on verbose logging" help="Switch on verbose logging"
) )
# The __main__ script will process the version number argument
parser.add_argument("--version", action="store_true", help="Print version number of program and exit")
pargs = parser.parse_args() pargs = parser.parse_args()
# Check important objects and set to default if they do not exists # Check important objects and set to default if they do not exists