summarylogtreecommitdiffstats
path: root/python312.patch
blob: 533547e470895e1bf1fae8ba8bc0ae5308e3f241 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
From 802bfb627eb05a1ee655854dd261800061322b9a Mon Sep 17 00:00:00 2001
From: Simon H <howroydlsu@gmail.com>
Date: Sun, 11 Feb 2024 17:59:59 +0000
Subject: [PATCH] Python 3.12 compatibility (#164)

* Removed depreciated `imp` and replaced with `importlib`

* Updated meta classifiers to include newer Python versions

* Added Python3.12 into github workflow action

* Updated workflow to test all versions we say we do

* Tidied mixed markup styles

* Assed Windows and MacOS to tests

* Updated depreciated setup-python action to v5

* Adding Python3.12 to Action

* Removed my test branch from Actions
---
 .github/workflows/ci.yml | 20 ++++++++------------
 README.md                | 28 +++++++++++-----------------
 setup.py                 | 24 ++++++++++++++++++++++--
 3 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/README.md b/README.md
index 06f922d..16ca26c 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,12 @@
-pynmea2
-=======
+# pynmea2
 
 `pynmea2` is a python library for the [NMEA 0183](http://en.wikipedia.org/wiki/NMEA_0183) protocol
 
 `pynmea2` is based on [`pynmea`](https://code.google.com/p/pynmea/) by Becky Lewis
 
-The `pynmea2` homepage is located at http://github.com/Knio/pynmea2
+The `pynmea2` homepage is located at <http://github.com/Knio/pynmea2>
 
- ### Compatibility
+## Compatibility
 
 `pynmea2` is compatable with Python 2.7 and Python 3.4+
 
@@ -15,18 +14,19 @@ The `pynmea2` homepage is located at http://github.com/Knio/pynmea2
 [![Build status](https://github.com/Knio/pynmea2/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Knio/pynmea2/actions/workflows/ci.yml?query=branch%3Amaster+)
 [![Coverage status](https://img.shields.io/coveralls/github/Knio/pynmea2/master.svg?style=flat)](https://coveralls.io/r/Knio/pynmea2?branch=master)
 
-### Installation
+## Installation
 
 The recommended way to install `pynmea2` is with
 [pip](http://pypi.python.org/pypi/pip/):
 
-    pip install pynmea2
+```bash
+pip install pynmea2
+```
 
 [![PyPI version](https://img.shields.io/pypi/v/pynmea2.svg?style=flat)](https://pypi.org/project/pynmea2/)
 [![PyPI downloads](https://img.shields.io/pypi/dm/pynmea2.svg?style=flat)](https://pypi.org/project/pynmea2/)
 
-Parsing
--------
+## Parsing
 
 You can parse individual NMEA sentences using the `parse(data, check=False)` function, which takes a string containing a
 NMEA 0183 sentence and returns a `NMEASentence` object. Note that the leading '$' is optional and trailing whitespace is ignored when parsing a sentence.
@@ -91,8 +91,7 @@ For example, `latitude` and `longitude` properties exist as helpers to access th
 "-19°29′02.7000″"
 ```
 
-Generating
-----------
+## Generating
 
 You can create a `NMEASentence` object by calling the constructor with talker, message type, and data fields:
 
@@ -101,7 +100,6 @@ You can create a `NMEASentence` object by calling the constructor with talker, m
 >>> msg = pynmea2.GGA('GP', 'GGA', ('184353.07', '1929.045', 'S', '02410.506', 'E', '1', '04', '2.6', '100.00', 'M', '-33.9', 'M', '', '0000'))
 ```
 
-
 and generate a NMEA string from a `NMEASentence` object:
 
 ```python
@@ -109,9 +107,7 @@ and generate a NMEA string from a `NMEASentence` object:
 '$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D'
 ```
 
-
-File reading example
---------
+## File reading example
 
 See [examples/read_file.py](/examples/read_file.py)
 
@@ -129,9 +125,7 @@ for line in file.readlines():
         continue
 ```
 
-
-pySerial device example
----------
+## `pySerial` device example
 
 See [examples/read_serial.py](/examples/read_serial.py)
 
diff --git a/setup.py b/setup.py
index facd391..d9d3eb8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,24 @@
+import importlib.machinery
+import importlib.util
+
 from setuptools import setup
 
-import imp
-_version = imp.load_source("pynmea2._version", "pynmea2/_version.py")
+
+def load_source(modname, filename):
+    """Load a source file and return its module object.
+
+    From: https://docs.python.org/3.12/whatsnew/3.12.html#imp
+    """
+    loader = importlib.machinery.SourceFileLoader(modname, filename)
+    spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+    module = importlib.util.module_from_spec(spec)
+    # The module is always executed and not cached in sys.modules.
+    # Uncomment the following line to cache the module.
+    # sys.modules[module.__name__] = module
+    loader.exec_module(module)
+    return module
+
+_version = load_source("pynmea2._version", "pynmea2/_version.py")
 
 setup(
     name='pynmea2',
@@ -29,6 +46,9 @@
         'Programming Language :: Python :: 3.7',
         'Programming Language :: Python :: 3.8',
         'Programming Language :: Python :: 3.9',
+        'Programming Language :: Python :: 3.10',
+        'Programming Language :: Python :: 3.11',
+        'Programming Language :: Python :: 3.12',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Scientific/Engineering :: GIS',
         'Topic :: Software Development :: Libraries :: Python Modules',