✨ Version is correctly shown in PyInstaller running mode. Running the app from source code points to dev config dir (~/.config/tidal_dl_ng-dev).
This commit is contained in:
+46
-3
@@ -1,5 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
from usingversion import getattr_with_version
|
||||
import importlib.metadata
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
__getattr__ = getattr_with_version("mypackage", __file__, __name__)
|
||||
__name_display__ = __package__ or __name__
|
||||
import toml
|
||||
|
||||
|
||||
def get_version_app() -> str:
|
||||
file_path: Path = Path(__file__)
|
||||
|
||||
paths: [Path] = [
|
||||
file_path.parent,
|
||||
file_path.parent.parent,
|
||||
file_path.parent.parent.parent,
|
||||
]
|
||||
version: str = "0.0.0"
|
||||
|
||||
for pyproject_toml_dir in paths:
|
||||
pyproject_toml_file: Path = pyproject_toml_dir / "pyproject.toml"
|
||||
|
||||
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
|
||||
package_version: str = toml.load(pyproject_toml_file)["tool"]["poetry"]["version"]
|
||||
|
||||
version = package_version
|
||||
|
||||
break
|
||||
|
||||
return version
|
||||
|
||||
|
||||
def get_name_app() -> str:
|
||||
name_app: str = __package__ or __name__
|
||||
|
||||
# Check if package is running from source code == dev mode
|
||||
# If package is not running in PyInstaller environment.
|
||||
if getattr(sys, "frozen", True) and not hasattr(sys, "_MEIPASS"):
|
||||
try:
|
||||
importlib.metadata.version(name_app)
|
||||
except:
|
||||
# If package is not installed
|
||||
name_app = name_app + "-dev"
|
||||
|
||||
return name_app
|
||||
|
||||
|
||||
__name_display__ = get_name_app()
|
||||
__version__ = get_version_app()
|
||||
|
||||
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
from tidalapi import Quality as QualityAudio
|
||||
|
||||
from tidal_dl_ng import version
|
||||
from tidal_dl_ng import __version__
|
||||
from tidal_dl_ng.config import Settings
|
||||
from tidal_dl_ng.constants import CoverDimensions, QualityVideo, SkipExisting
|
||||
from tidal_dl_ng.helper.path import is_installed_ffmpeg
|
||||
@@ -30,7 +30,7 @@ class DialogVersion(QtWidgets.QDialog):
|
||||
# Run the .setupUi() method to show the GUI
|
||||
self.ui.setupUi(self)
|
||||
# Set the version.
|
||||
self.ui.l_version.setText("v" + version)
|
||||
self.ui.l_version.setText("v" + __version__)
|
||||
# Show
|
||||
self.exec()
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ from collections.abc import Callable
|
||||
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from tidal_dl_ng import version
|
||||
from tidal_dl_ng import __version__
|
||||
from tidal_dl_ng.dialog import DialogLogin, DialogPreferences, DialogVersion
|
||||
from tidal_dl_ng.helper.path import get_format_template
|
||||
from tidal_dl_ng.helper.tidal import (
|
||||
@@ -671,7 +671,7 @@ def gui_activate(tidal: Tidal | None = None):
|
||||
# Make sure Pyinstaller icons are still grouped
|
||||
if not sys.argv[0].endswith(".exe"):
|
||||
# Arbitrary string
|
||||
my_app_id: str = "exislow.tidal.dl-ng." + version
|
||||
my_app_id: str = "exislow.tidal.dl-ng." + __version__
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(my_app_id)
|
||||
|
||||
window = MainWindow(tidal=tidal)
|
||||
|
||||
Reference in New Issue
Block a user