Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12 compatibility #164

Merged
merged 9 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3"]
os: ["ubuntu-latest"]
include:
- {python: "3.8", os: "ubuntu-22.04"}
- {python: "3.9", os: "ubuntu-22.04"}
- {python: "3.10", os: "ubuntu-22.04"}
- {python: "3.11", os: "ubuntu-22.04"}
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install flake8
python -m pip install setuptools wheel
python -m pip install importlib_metadata
- name: Lint with flake8
run: |
Expand All @@ -41,7 +37,7 @@ jobs:
- name: Build and test
run: |
python setup.py sdist --formats=zip
pip install dist/pynmea2*.zip
pip install --find-links=./dist --no-index --no-build-isolation pynmea2
pytest
- name: Coveralls
env:
Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
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+

![Python version](https://img.shields.io/pypi/pyversions/pynmea2.svg?style=flat)
[![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.
Expand Down Expand Up @@ -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:

Expand All @@ -101,17 +100,14 @@ 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
>>> str(msg)
'$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)

Expand All @@ -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)

Expand Down
24 changes: 22 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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',
Expand Down