Skip to content

Commit 08a876f

Browse files
authored
Merge pull request #67 from exislow/62-bug-version-info-not-displayed
🛠️ Version will be shown correctly.
2 parents 0461c53 + c7c8c12 commit 08a876f

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

poetry.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pyside6 = {version = "^6.6.2", optional = true}
4040
pyqtdarktheme = {version = "^2.1.0", optional = true}
4141
mpegdash = "^0.4.0"
4242
rich = "^13.7.1"
43+
usingversion = "^0.1.2"
4344

4445
[tool.poetry.extras]
4546
gui = ["pyside6", "pyqtdarktheme"]
@@ -170,7 +171,7 @@ profile = "black"
170171
multi_line_output = 3
171172
indent = 4
172173
color_output = true
173-
known_third_party = ["Crypto", "PySide6", "coloredlogs", "dataclasses_json", "ffmpeg", "helper", "m3u8", "mpegdash", "mutagen", "pathvalidate", "requests", "rich", "tidalapi", "typer"]
174+
known_third_party = ["Crypto", "PySide6", "coloredlogs", "dataclasses_json", "ffmpeg", "helper", "m3u8", "mpegdash", "mutagen", "pathvalidate", "requests", "rich", "tidalapi", "typer", "usingversion"]
174175

175176
[tool.mypy]
176177
# https://mypy.readthedocs.io/en/latest/config_file.html#using-a-pyproject-toml-file

tidal_dl_ng/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/usr/bin/env python
2-
import importlib.metadata
2+
from usingversion import getattr_with_version
33

4-
try:
5-
# __package__ allows for the case where __name__ is "__main__"
6-
__version__ = importlib.metadata.version(__package__ or __name__)
7-
__name_display__ = importlib.metadata.metadata(__package__ or __name__).json["name"]
8-
except importlib.metadata.PackageNotFoundError:
9-
__version__ = "0.0.0"
10-
__name_display__ = __package__ or __name__
4+
__getattr__ = getattr_with_version("mypackage", __file__, __name__)
5+
__name_display__ = __package__ or __name__

tidal_dl_ng/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from rich.progress import BarColumn, Console, Progress, SpinnerColumn, TextColumn
99
from rich.table import Table
1010

11-
from tidal_dl_ng import __version__
11+
from tidal_dl_ng import version
1212
from tidal_dl_ng.config import Settings, Tidal
1313
from tidal_dl_ng.constants import CTX_TIDAL, MediaType
1414
from tidal_dl_ng.download import Download
@@ -22,7 +22,7 @@
2222

2323
def version_callback(value: bool):
2424
if value:
25-
print(f"{__version__}")
25+
print(f"{version}")
2626
raise typer.Exit()
2727

2828

tidal_dl_ng/dialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from PySide6 import QtCore, QtGui, QtWidgets
77
from tidalapi import Quality as QualityAudio
88

9-
from tidal_dl_ng import __version__
9+
from tidal_dl_ng import version
1010
from tidal_dl_ng.config import Settings
1111
from tidal_dl_ng.constants import CoverDimensions, QualityVideo, SkipExisting
1212
from tidal_dl_ng.model.cfg import HelpSettings
@@ -30,7 +30,7 @@ def __init__(self, parent=None):
3030
# Run the .setupUi() method to show the GUI
3131
self.ui.setupUi(self)
3232
# Set the version.
33-
self.ui.l_version.setText("v" + __version__)
33+
self.ui.l_version.setText("v" + version)
3434
# Show
3535
self.exec()
3636

tidal_dl_ng/gui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from requests.exceptions import HTTPError
66

7-
from tidal_dl_ng import __version__
7+
from tidal_dl_ng import version
88
from tidal_dl_ng.dialog import DialogLogin, DialogPreferences, DialogVersion
99
from tidal_dl_ng.helper.exceptions import MediaUnknown
1010
from tidal_dl_ng.helper.path import get_format_template
@@ -629,7 +629,7 @@ def gui_activate(tidal: Tidal | None = None):
629629
# Make sure Pyinstaller icons are still grouped
630630
if not sys.argv[0].endswith(".exe"):
631631
# Arbitrary string
632-
my_app_id: str = "exislow.tidal.dl-ng." + __version__
632+
my_app_id: str = "exislow.tidal.dl-ng." + version
633633
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(my_app_id)
634634

635635
window = MainWindow(tidal=tidal)

0 commit comments

Comments
 (0)