Skip to content

Commit dfb8749

Browse files
committed
gui.about: detect most versions using importlib.metadata (this is partly why 3.8 is required now), detect if frozen and mention the program used for it
1 parent bd85b0f commit dfb8749

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

ninfs/gui/about.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@
99
import tkinter.ttk as ttk
1010
import webbrowser
1111
from os.path import join
12+
from importlib.metadata import metadata
1213
from typing import TYPE_CHECKING
1314

14-
from Cryptodome import __version__ as pycryptodomex_version
15-
from pyctr import __version__ as pyctr_version
16-
1715
from .osver import get_os_ver
1816
# "from .. import" didn't work :/
1917
from __init__ import __copyright__ as ninfs_copyright
2018
from __init__ import __version__ as ninfs_version
2119

20+
frozen_using = None
21+
if getattr(sys, 'frozen', False):
22+
if getattr(sys, '_MEIPASS', False):
23+
frozen_using = 'PyInstaller'
24+
else:
25+
# cx-Freeze probably
26+
frozen_using = 'cx-Freeze'
27+
2228
if TYPE_CHECKING:
2329
from . import NinfsGUI
2430

@@ -68,7 +74,10 @@ def __init__(self, parent: 'NinfsGUI' = None):
6874
header_label = ttk.Label(container, text=f'ninfs {ninfs_version}', font=(None, 15, 'bold'))
6975
header_label.grid(row=0, column=0, padx=pad, pady=pad, sticky=tk.W)
7076

71-
version_label = ttk.Label(container, text=f'Running on {python_version} {pybits}-bit')
77+
running_on = f'Running on Python {python_version} {pybits}-bit'
78+
if frozen_using:
79+
running_on += f' (frozen using {frozen_using})'
80+
version_label = ttk.Label(container, text=running_on)
7281
version_label.grid(row=1, column=0, padx=pad, pady=(0, pad), sticky=tk.W)
7382

7483
copyright_label = ttk.Label(container, text='This program uses several libraries and modules, which have '
@@ -77,15 +86,15 @@ def __init__(self, parent: 'NinfsGUI' = None):
7786

7887
# tab name, license file name, url
7988
info = [
80-
(f'ninfs {ninfs_version}', 'ninfs.md', 'https://github.com/ihaveamac/ninfs',
89+
(f'ninfs', ninfs_version, 'ninfs.md', 'https://github.com/ihaveamac/ninfs',
8190
'ninfs - Copyright (c) 2017-2021 Ian Burgwin'),
82-
(f'WinFsp 2020.2', 'winfsp.txt', 'https://github.com/billziss-gh/winfsp',
91+
(f'WinFsp', '2023', 'winfsp.txt', 'https://github.com/billziss-gh/winfsp',
8392
'WinFsp - Windows File System Proxy, Copyright (C) Bill Zissimopoulos'),
84-
(f'pycryptodomex {pycryptodomex_version}', 'pycryptodome.rst',
93+
(f'pycryptodomex', metadata('pycryptodomex')['Version'], 'pycryptodome.rst',
8594
'https://github.com/Legrandin/pycryptodome', 'PyCryptodome - multiple licenses'),
86-
(f'pyctr {pyctr_version}', 'pyctr', 'https://github.com/ihaveamac/pyctr',
95+
(f'pyctr', metadata('pyctr')['Version'], 'pyctr', 'https://github.com/ihaveamac/pyctr',
8796
'pyctr - Copyright (c) 2017-2021 Ian Burgwin'),
88-
('haccrypto 0.1.2', 'haccrypto.md', 'https://github.com/luigoalma/haccrypto',
97+
('haccrypto', metadata('haccrypto')['Version'], 'haccrypto.md', 'https://github.com/luigoalma/haccrypto',
8998
'haccrypto - Copyright (c) 2017-2021 Ian Burgwin & Copyright (c) 2020-2021 Luis Marques')
9099
]
91100

@@ -97,10 +106,9 @@ def func():
97106
webbrowser.open(do_url)
98107
return func
99108

100-
for tab_name, license_file, url, header in info:
101-
print([tab_name, license_file, url])
109+
for proj_name, proj_version, license_file, url, header in info:
102110
frame = ttk.Frame(license_notebook)
103-
license_notebook.add(frame, text=tab_name)
111+
license_notebook.add(frame, text=proj_name + ' ' + proj_version)
104112

105113
license_header_label = ttk.Label(frame, text=header)
106114
license_header_label.grid(row=0, sticky=tk.W, padx=pad//2, pady=pad//2)

ninfs/gui/data/licenses/winfsp.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[NOTE: this license is for the version of WinFsp included with the ninfs installer, which may be different from what you have installed]
2+
13
The WinFsp project is Copyright (C) Bill Zissimopoulos. It is licensed
24
under the terms of the GPLv3.
35

@@ -6,7 +8,7 @@ permissions to Free/Libre and Open Source Software ("FLOSS") without requiring
68
that such software is covered by the GPLv3.
79

810
1. Permission to link with a platform specific version of the WinFsp DLL
9-
(one of: winfsp-x64.dll, winfsp-x86.dll, winfsp-msil.dll).
11+
(one of: winfsp-a64.dll, winfsp-x64.dll, winfsp-x86.dll, winfsp-msil.dll).
1012

1113
2. Permission to distribute unmodified binary releases of the WinFsp
1214
installer (as released by the WinFsp project).

0 commit comments

Comments
 (0)