Skip to content

Commit b67f291

Browse files
authored
Merge pull request #75 from oresat/packaging-improvements
Use more modern python packaging conventions
2 parents 86224da + 0f5f9f3 commit b67f291

11 files changed

Lines changed: 41 additions & 67 deletions

File tree

.github/workflows/pypi.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ name: Upload Python Package
22

33
on:
44
release:
5-
types: [published]
5+
types: [ "published" ]
66

77
jobs:
88
deploy:
9-
109
runs-on: ubuntu-latest
10+
environment: pypi
11+
permissions:
12+
id-token: write
1113

1214
steps:
13-
- uses: actions/checkout@v3
14-
15-
- name: Set up Python
16-
uses: actions/setup-python@v3
15+
- uses: actions/checkout@v6
16+
- uses: actions/setup-python@v6
1717
with:
18-
python-version: '3.x'
18+
python-version: "3.9"
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
@@ -24,9 +24,5 @@ jobs:
2424
- name: Build package
2525
run: python -m build
2626

27-
- name: Publish package
28-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
29-
with:
30-
user: __token__
31-
password: ${{ secrets.PYPI_API_TOKEN }}
32-
27+
- name: Publish
28+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ jobs:
2626
id: dependencies
2727
run: |
2828
python -m pip install --upgrade pip
29-
pip install -r requirements.txt
29+
pip install . --group dev
3030
3131
# - name: Lint with Pylama
3232
# if: always() && steps.dependencies.conclusion == 'success'
3333
# run: pylama
3434

35-
- name: Check format with Black
35+
- name: Lint with Ruff
3636
if: always() && steps.dependencies.conclusion == 'success'
37-
run: black --check --diff .
37+
run: ruff check --select=E,F,I
3838

39-
- name: Check format with isort
39+
- name: Check format with Ruff
4040
if: always() && steps.dependencies.conclusion == 'success'
41-
run: isort --check --diff .
41+
run: ruff format --check --diff
4242

4343
- name: Test with Python's unittest
4444
if: always() && steps.dependencies.conclusion == 'success'

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ Framework), which it built on top of [CANopen for Python] project. See the
2020

2121
**For development**, install `oresat-configs` from the GitHub repo at
2222
https://github.com/oresat/oresat-configs (not from PyPI). That repo may have
23-
changes that are not apart of the latest release yet.
23+
changes that are not apart of the latest release yet. Cloning it and using
24+
`pip install --editable <path to your oresat-configs repo>` is very convenient.
2425

2526
Install dependencies
2627

2728
```bash
28-
$ pip3 install -r requirements.txt
29+
$ pip3 install -e . --group dev
2930
```
3031

3132
Make a virtual CAN bus (skip if using a real CAN bus)

oresat_c3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""C3 OLAF App."""
22

3-
from enum import Enum, IntEnum
3+
from enum import IntEnum
44

55
try:
66
from ._version import version as __version__ # type: ignore

oresat_c3/drivers/fm24cl64b.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def __init__(self, bus_num: int, addr: int, mock: bool = False):
3838

3939
if addr not in self.ADDRESSES:
4040
raise Fm24cl64bError(
41-
f"arg addr 0x{addr:X} is not between 0x{self.ADDR_MIN:X} "
42-
f"and 0x{self.ADDR_MAX:X}"
41+
f"arg addr 0x{addr:X} is not between 0x{self.ADDR_MIN:X} and 0x{self.ADDR_MAX:X}"
4342
)
4443

4544
self._bus_num = bus_num

oresat_c3/protocols/edl_packet.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,8 @@
99

1010
from spacepackets.cfdp.pdu import PduFactory
1111
from spacepackets.cfdp.pdu.file_directive import AbstractPduBase
12-
from spacepackets.uslp.frame import ( # type: ignore
13-
FrameType,
14-
TfdzConstructionRules,
15-
TransferFrame,
16-
TransferFrameDataField,
17-
UslpProtocolIdentifier,
18-
)
19-
from spacepackets.uslp.header import ( # type: ignore
20-
BypassSequenceControlFlag,
21-
PrimaryHeader,
22-
ProtocolCommandFlag,
23-
SourceOrDestField,
24-
)
12+
from spacepackets.uslp.frame import FrameType, TransferFrame
13+
from spacepackets.uslp.header import SourceOrDestField
2514

2615
from .edl_command import EdlCommandCode, EdlCommandError, EdlCommandRequest, EdlCommandResponse
2716
from .uslp import HMAC_LEN, SEQ_NUM_LEN, make_frame

oresat_c3/subsystems/opd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ def uart_node(self) -> Union[str, None]:
597597

598598
@uart_node.setter
599599
def uart_node(self, name: Union[str, None]) -> None:
600-
601600
self._uart_disconnect()
602601
if name is None or self._nodes[name].status == OpdNodeState.NOT_FOUND:
603602
return

pyproject.toml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,29 @@ classifiers = [
1616
"Programming Language :: Python :: 3.11",
1717
"Topic :: Software Development :: Embedded Systems",
1818
]
19+
dynamic = ["version"]
20+
1921
dependencies = [
2022
"bitstring",
2123
"cfdp-py~=0.6.0",
2224
"dataclasses-json",
2325
"fastcrc~=0.3",
24-
"oresat-configs==0.8.*",
25-
"oresat-olaf>=3.6.5",
26+
"oresat-configs>=1.1.1",
27+
"oresat-olaf>=3.7.1",
2628
"smbus2",
2729
"spacepackets>=0.30.1",
2830
"ccsds-cop>=0.0.0",
2931
]
30-
dynamic = ["version"]
32+
33+
[dependency-groups]
34+
dev = [
35+
"build",
36+
"pylama[all,toml]",
37+
"ruff",
38+
"sphinx",
39+
"sphinx-rtd-theme",
40+
"sphinxcontrib-mermaid",
41+
]
3142

3243
[project.scripts]
3344
oresat-c3 = "oresat_c3.__main__:main"
@@ -41,8 +52,11 @@ exclude = ["docs*", "tests*", "scripts*"]
4152
[tool.setuptools_scm]
4253
write_to = "oresat_c3/_version.py"
4354

44-
[tool.black]
45-
line_length = 100
55+
[tool.ruff]
56+
line-length = 100
57+
58+
[tool.ruff.format]
59+
quote-style = "preserve"
4660

4761
[tool.pylama]
4862
format = "pylint"
@@ -87,7 +101,3 @@ ignore = "W0212"
87101
[[tool.mypy.overrides]]
88102
module = "canopen,olaf,oresat_configs,spacepackets"
89103
ignore_missing_imports = true
90-
91-
[tool.isort]
92-
profile = "black"
93-
line_length = 100

requirements.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

scripts/beacon.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
"""Listens for and prints C3 beacons"""
33

4-
54
import os
65
import socket
76
import sys

0 commit comments

Comments
 (0)