Skip to content

Commit 280f3f2

Browse files
committed
update about_dialog Fixes #177
1 parent 94f2003 commit 280f3f2

File tree

4 files changed

+69
-28
lines changed

4 files changed

+69
-28
lines changed

README.md

+36-7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ and then run it by typing:
6666
pygpsclient
6767
```
6868

69+
**NB** If you get `error: externally-managed-environment`, refer to the longer installation guidelines for **virtual environments** using [pip](#pip) or [pipx](#pipx) below.
70+
6971
## The Longer Version
7072

7173
In the following, `python3` & `pip` refer to the Python 3 executables. You may need to substitute `python` for `python3`, depending on your particular environment (*on Windows it's generally `python`*).
@@ -135,33 +137,50 @@ To access the serial port on most Linux platforms, you will need to be a member
135137
usermod -a -G tty myuser
136138
```
137139

138-
### Install using pip
140+
### <a name="pip">Install using pip</a>
139141

140142
![Python version](https://img.shields.io/pypi/pyversions/PyGPSClient.svg?style=flat)
141143
[![PyPI version](https://img.shields.io/pypi/v/PyGPSClient.svg?style=flat)](https://pypi.org/project/PyGPSClient/)
142144
![PyPI downloads](https://img.shields.io/pypi/dm/PyGPSClient.svg?style=flat)
143145

144-
The easiest way to install the latest version of `PyGPSClient` is with [pip](http://pypi.python.org/pypi/pip/):
146+
The recommended way to install the latest version of `PyGPSClient` is with [pip](http://pypi.python.org/pypi/pip/):
145147

146148
```shell
147149
python3 -m pip install --upgrade pygpsclient
148150
```
149151

150-
If required, `PyGPSClient` can also be installed into a virtual environment, e.g.:
151-
152+
If required, `PyGPSClient` can also be installed and run in a [virtual environment](https://www.geeksforgeeks.org/python-virtual-environment/) - this may be necessary if you have an `externally-managed-environment`, e.g.:
152153
```shell
153154
python3 -m venv env
154155
source env/bin/activate # (or env\Scripts\activate on Windows)
155156
python3 -m pip install --upgrade pygpsclient
157+
pygpsclient
156158
```
157159

158-
The pip installation process places an executable file `pygpsclient` in the Python binaries folder (`../bin` on Linux & MacOS, `..\Scripts` on Windows). The PyGPSClient application may be started by double-clicking on this executable file from your file manager or, if the binaries folder is in your PATH, by opening a terminal and typing (all lowercase):
160+
To deactivate the virtual environment:
159161

160162
```shell
163+
deactivate
164+
```
165+
166+
To reactivate and run from the virtual environment:
167+
```shell
168+
source env/bin/activate # (or env\Scripts\activate on Windows)
161169
pygpsclient
162170
```
163171

164-
`pygpsclient` also accepts optional command line arguments for a variety of configurable parameters. These will override any saved configuration file settings. Type the following for help:
172+
To upgrade PyGPSClient to the latest version from the virtual environment:
173+
```shell
174+
source env/bin/activate # (or env\Scripts\activate on Windows)
175+
python3 -m pip install --upgrade pygpsclient
176+
```
177+
178+
The pip installation process places an executable file `pygpsclient` in the Python binaries folder (`../bin` on Linux & MacOS, `..\Scripts` on Windows). The PyGPSClient application may be started by double-clicking on this executable file from your file manager or, if the binaries folder is in your PATH, by opening a terminal and typing (all lowercase):
179+
```shell
180+
pygpsclient
181+
````
182+
183+
`pygpsclient` accepts optional command line arguments for a variety of configurable parameters. These will override any saved configuration file settings. Type the following for help:
165184
```shell
166185
pygpsclient -h
167186
```
@@ -185,10 +204,20 @@ Typically:
185204
1. Windows: `C:\Users\myuser\AppData\Roaming\Python\Python3**\Scripts\pygpsclient.exe`
186205
2. MacOS: `/Library/Frameworks/Python.framework/Versions/3.**/bin/pygpsclient`
187206
3. Linux: `/home/myuser/.local/bin/pygpsclient`
188-
4. Virtual Env: `env/bin/pygpsclient` (or `env\Scripts\pygpsclient.exe` on Windows)
207+
4. Virtual Env: `$ENV/bin/pygpsclient` (or `$ENV\Scripts\pygpsclient.exe` on Windows), where `$ENV` is the full path to your virtual environment.
189208

190209
where `**` signifies the Python version e.g. `3.12`.
191210

211+
### <a name="pipx">Install using pipx</a>
212+
213+
You can also use [pipx](https://pipx.pypa.io/latest/installation/) (_if available_) to install `pygpsclient` into a virtual environment - use the `pipx ensurepath` command to add the relevant Python binaries folder to your PATH.
214+
215+
```shell
216+
pipx ensurepath
217+
pipx install pygpsclient
218+
```
219+
220+
`pipx` will typically create a virtual environment in the user's local shared folder e.g. `/home/user/.local/share/pipx/venvs/pygpsclient`.
192221
193222
### Creating A Desktop Application Launcher
194223

RELEASE_NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# PyGPSClient Release Notes
22

3+
### RELEASE 1.5.4
4+
5+
1. Fix issue with GUI update facility not working for virtual environments.
6+
37
### RELEASE 1.5.3
48

59
1. Fix issue with displaying final content of file in console after EOF condition.

src/pygpsclient/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
:license: BSD 3-Clause
99
"""
1010

11-
__version__ = "1.5.3"
11+
__version__ = "1.5.4"

src/pygpsclient/about_dialog.py

+28-20
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
:license: BSD 3-Clause
1111
"""
1212

13+
import logging
14+
from inspect import currentframe, getfile
15+
from os import path
1316
from platform import python_version
1417
from subprocess import CalledProcessError, run
15-
from sys import platform
18+
from sys import executable
1619
from tkinter import Button, Checkbutton, E, Frame, IntVar, Label, Tcl, Toplevel, W
1720
from webbrowser import open_new_tab
1821

@@ -50,7 +53,7 @@ class AboutDialog:
5053
About dialog box class
5154
"""
5255

53-
def __init__(self, app, **kwargs):
56+
def __init__(self, app, **kwargs): # pylint: disable=unused-argument
5457
"""
5558
Initialise Toplevel dialog
5659
@@ -59,6 +62,7 @@ def __init__(self, app, **kwargs):
5962

6063
self.__app = app # Reference to main application class
6164
self.__master = self.__app.appmaster # Reference to root class (Tk)
65+
self.logger = logging.getLogger(__name__)
6266
self._dialog = Toplevel()
6367
self._dialog.title = DLGABOUT
6468
self._dialog.geometry(
@@ -258,26 +262,30 @@ def _do_update(self, *args, **kwargs): # pylint: disable=unused-argument
258262

259263
self._btn_checkupdate.config(text="UPDATING...", fg="blue")
260264
self._dialog.update_idletasks()
261-
pyc = "python" if platform == "win32" else "python3"
262-
cmd = [
263-
pyc,
264-
"-m",
265-
"pip",
266-
"install",
267-
"--upgrade",
268-
"--user",
269-
"--force-reinstall",
270-
]
271-
for pkg in self._updates:
272-
cmd.append(pkg)
273-
265+
pth = path.dirname(path.abspath(getfile(currentframe())))
266+
if "pipx" in pth: # installed into venv using pipx
267+
cmd = [
268+
"pipx",
269+
"upgrade",
270+
"pygpsclient",
271+
]
272+
else: # installed using pip
273+
cmd = [
274+
executable, # i.e. python3 or python
275+
"-m",
276+
"pip",
277+
"install",
278+
"--upgrade",
279+
]
280+
for pkg in self._updates:
281+
cmd.append(pkg)
282+
283+
result = None
274284
try:
275-
run(
276-
cmd,
277-
check=True,
278-
capture_output=True,
279-
)
285+
result = run(cmd, check=True, capture_output=True)
286+
self.logger.debug(result.stdout)
280287
except CalledProcessError:
288+
self.logger.error(result.stdout)
281289
self._btn_checkupdate.config(text="UPDATE FAILED", fg="red")
282290
self._btn_checkupdate.bind("<Button>", self._check_for_update)
283291
return

0 commit comments

Comments
 (0)