Fixed the --version command when installed from source (#344)
The command only worked when running it inside the git repository. Now, it works from everywhere, and the version is constructed using the latest git tag and the SHA of the latest commit, which may help with further debugging in future issues.
This commit is contained in:
parent
1673583304
commit
d2dba2fc31
|
@ -12,6 +12,7 @@ import time
|
||||||
import click
|
import click
|
||||||
import warnings
|
import warnings
|
||||||
import configparser
|
import configparser
|
||||||
|
import pkg_resources
|
||||||
from math import isclose
|
from math import isclose
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import which
|
from shutil import which
|
||||||
|
@ -111,7 +112,7 @@ except PermissionError:
|
||||||
# display running version of auto-cpufreq
|
# display running version of auto-cpufreq
|
||||||
def app_version():
|
def app_version():
|
||||||
|
|
||||||
print("auto-cpufreq version:")
|
print("auto-cpufreq version: ", end="")
|
||||||
|
|
||||||
# snap package
|
# snap package
|
||||||
if os.getenv("PKG_MARKER") == "SNAP":
|
if os.getenv("PKG_MARKER") == "SNAP":
|
||||||
|
@ -120,19 +121,13 @@ def app_version():
|
||||||
elif dist_name in ["arch", "manjaro", "garuda"]:
|
elif dist_name in ["arch", "manjaro", "garuda"]:
|
||||||
aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True)
|
aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True)
|
||||||
if aur_pkg_check == 1:
|
if aur_pkg_check == 1:
|
||||||
print(
|
print(pkg_resources.require("auto-cpufreq")[0].version)
|
||||||
"Git commit:",
|
|
||||||
check_output(["git", "describe", "--always"]).strip().decode(),
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
print(getoutput("pacman -Qi auto-cpufreq | grep Version"))
|
print(getoutput("pacman -Qi auto-cpufreq | grep Version"))
|
||||||
else:
|
else:
|
||||||
# source code (auto-cpufreq-installer)
|
# source code (auto-cpufreq-installer)
|
||||||
try:
|
try:
|
||||||
print(
|
print(pkg_resources.require("auto-cpufreq")[0].version)
|
||||||
"Git commit:",
|
|
||||||
check_output(["git", "describe", "--always"]).strip().decode(),
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(repr(e))
|
print(repr(e))
|
||||||
pass
|
pass
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -15,7 +15,11 @@ def read(name):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="auto-cpufreq",
|
name="auto-cpufreq",
|
||||||
version="1.0",
|
version_config={
|
||||||
|
"template": "{tag}.{sha}",
|
||||||
|
"dev_template": "{tag}.{sha}"
|
||||||
|
},
|
||||||
|
setup_requires=["setuptools-git-versioning"],
|
||||||
description="Automatic CPU speed & power optimizer for Linux",
|
description="Automatic CPU speed & power optimizer for Linux",
|
||||||
long_description=readme,
|
long_description=readme,
|
||||||
author="Adnan Hodzic",
|
author="Adnan Hodzic",
|
||||||
|
|
Loading…
Reference in New Issue