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

Update submodules & prepare for pypi distribution #11

Merged
merged 37 commits into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3a789df
update submodules
2bndy5 Jul 21, 2022
a00284c
update docs (workaround bug in sphinx theme)
2bndy5 Jul 21, 2022
c3dc37c
declare RF24_NO_INTERRUPT for building C++
2bndy5 Jul 21, 2022
b46beab
hard code RF24_NO_INTERRUPT
2bndy5 Jul 21, 2022
71a638d
testing patch from new RF24 branch
2bndy5 Jul 21, 2022
7b2399a
define RF24_NO_IRQ for all targets
2bndy5 Jul 22, 2022
b78813a
remove cmake from pyproject.toml and adjust README
2bndy5 Jul 22, 2022
74ce07c
try cibuildwheels
2bndy5 Jul 22, 2022
7ebec54
don't try to build armhf wheels
2bndy5 Jul 22, 2022
f34e277
lower the required python minimum to v3.6
2bndy5 Jul 22, 2022
3a9c5b5
limit the built wheels to arm & aarch64
2bndy5 Jul 22, 2022
8be9702
trye explicitly specifying armv6
2bndy5 Jul 22, 2022
2291033
only build aarch64 wheels
2bndy5 Jul 22, 2022
13f0238
bump min req py ver back to 3.7
2bndy5 Jul 23, 2022
d258201
proofread stubs
2bndy5 Jul 23, 2022
637e4b6
update CI workflows
2bndy5 Jul 23, 2022
4615046
add explanatory comment to toml
2bndy5 Jul 23, 2022
4534d19
trim sdist by manually specifying the MANIFEST
2bndy5 Jul 23, 2022
8c4715a
create & archive both bdist & sdist in build CI
2bndy5 Jul 23, 2022
a8d1a67
fix pkg classifier in setup.py
2bndy5 Jul 23, 2022
4b51978
do not publish amd64 bdist to pypi
2bndy5 Jul 23, 2022
bbaf81b
update scanner.py
2bndy5 Jul 23, 2022
53750eb
update RF24 to latest master
2bndy5 Jul 23, 2022
23ac1df
fix glob warnings from sdist MANIFEST
2bndy5 Jul 23, 2022
bde0905
change the version str for non-tagged commits
2bndy5 Jul 23, 2022
da254ac
encourage -v when pip installing
2bndy5 Jul 23, 2022
7cfcb58
build CI upload sdist to testPyPi (only from main)
2bndy5 Jul 23, 2022
e781115
revise build CI about uploading to testPyPi
2bndy5 Jul 23, 2022
c224b45
check type hinting with mypy tool
2bndy5 Jul 23, 2022
f2bb036
remove unused import; don't pkg .pylintrc
2bndy5 Jul 23, 2022
188a0c9
fix typo
2bndy5 Jul 23, 2022
bcb24c4
update secret token name
2bndy5 Jul 23, 2022
45da372
self review
2bndy5 Jul 23, 2022
442267c
remove ninja from build reqs in toml
2bndy5 Jul 23, 2022
2ff5bf0
make setup.py more readable
2bndy5 Jul 23, 2022
cd49829
proofread README changes
2bndy5 Jul 23, 2022
f7c6903
docs don't have a dedicated search page
2bndy5 Jul 23, 2022
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
47 changes: 37 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Build CI

on: [pull_request, push]
on: [pull_request, push, workflow_dispatch]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.9

Expand All @@ -18,40 +18,67 @@ jobs:
fetch-depth: 0

- name: Install dependencies
# cmake ships with the ubuntu-latest runner
run: |
sudo apt-get install python3-dev graphviz
python3 -m pip install --upgrade pip pylint
python3 -m pip install --upgrade pip pylint mypy
python3 -m pip install -r docs/requirements.txt -r requirements.txt

- name: Build package for docs extraction and linting examples
id: wheel
run: |
python3 setup.py bdist_wheel
python3 -m pip install $(ls dist/pyrf24-*.whl)
python3 setup.py sdist bdist_wheel
python3 -m pip install dist/pyrf24-*.whl

- name: check python typing
run: mypy src

- name: check python examples PEP8 compliance
run: |
pylint examples/*.py --disable=duplicate-code
# duplicate-code error gets flagged because some examples use similar code snippets
run: pylint examples/*.py src/pyrf24/*.py --disable=duplicate-code --output-format=json:pylint.json

- name: Match pylint problems to diff via github annotations
run: python ./.github/workflows/pylint_matcher.py pylint.json

- name: Build docs
working-directory: docs
run: sphinx-build -E -W -b html . _build/html

- name: Save built docs as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: "pyRF24_docs"
path: ${{ github.workspace }}/docs/_build/html

- name: upload to github pages
# only publish doc changes from main branch
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html

- name: Save distributable wheels as artifacts
uses: actions/upload-artifact@v2
with:
name: "pyRF24_pkg_dist"
path: ${{ github.workspace }}/dist

- name: Create sdist for testPyPi
# Doing this again to ensure a fresh build env.
# We don't need to upload a bdist as we can check that locally, but
# sdist is used by the piwheels project to create a bdist for RPi OS
run: |
rm -r dist/ _skbuild
python3 setup.py sdist

- name: Validate distribution
run: |
python3 -m pip install twine
twine check dist/*
python3 -m twine check dist/*

- name: upload to test PyPi
if: github.event_name == 'push' && github.repository == 'nRF24/pyRF24' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: python3 -m twine upload -r testpypi dist/*
69 changes: 69 additions & 0 deletions .github/workflows/pylint_matcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Parse output from clang-tidy's stdout"""
import argparse
import pathlib
import json
from typing import Dict, Union, List
import logging

log_commander = logging.getLogger("PylintMatcher")
log_commander.setLevel(logging.DEBUG) # be sure that log commands are output
console_handler = logging.StreamHandler() # Create special stdout stream handler
console_handler.setFormatter(logging.Formatter("%(message)s")) # no formatted log cmds
log_commander.addHandler(console_handler) # Use special handler for log_commander
log_commander.propagate = False # prevent duplicate messages in the parent logger obj


def annotate_pylint_note(obj: Dict[str, Union[int, str]]) -> str:
"""Translate a 1 notification from pylint to github's checks API.

:param dict obj: The JSON object output by pylint (for 1 notification).
A typical JSON object output from pylint looks like:

.. code-block:: json

{
"type": "error",
"module": "basic_test",
"obj": "",
"line": 3,
"column": 19,
"path": "tests/basic_test.py",
"symbol": "syntax-error",
"message": "invalid syntax (<unknown>, line 3)",
"message-id": "E0001"
}
clang_autodoc\clang_parse.py:92: error: Argument 1 to "serialize_src_loc" of "ClangParse" has incompatible type "int"; expected "SourceLocation"
:Returns:
A `str` that can be used by github's workflow log commands.
"""
priority = {
"convention": "notice",
"refactor": "notice",
"warning": "warning",
"error": "error",
"fatal": "error",
}
return (
"::{level} file={path},line={line},title={path}:{line}:{col} {symbol} [{code}]"
"::{msg}".format(
level=priority[obj["type"]],
path=obj["path"],
line=obj["line"],
col=obj["column"],
symbol=obj["symbol"],
code=obj["message-id"],
msg=obj["message"],
)
)


if __name__ == "__main__":
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("json_output", type=pathlib.Path)
args = arg_parser.parse_args()

pylint_result: List[Dict[str, Union[int, str]]] = json.loads(
pathlib.Path(args.json_output).read_text(encoding="utf-8")
)
for note in pylint_result:
log_commander.info(annotate_pylint_note(note))
43 changes: 31 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Release Actions

on:
workflow_dispatch:
release:
types: [published]

jobs:
upload-pypi:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.9

- name: Checkout Current Repo
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
Expand All @@ -24,20 +25,38 @@ jobs:
sudo apt install python3-dev
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install twine

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: aarch64

- name: Build wheels with cibuildwheels
uses: pypa/cibuildwheel@v2.8.1
env:
CIBW_ARCHS_LINUX: aarch64
CIBW_SKIP: cp36* pp* cp311*

- name: Move cross-compiled wheels to dist folder
run: |
mkdir -p dist
mv ./wheelhouse/*.whl ${{ github.workspace }}/dist/

- name: build binary distributable wheel
run: python setup.py bdist_wheel
# sdist for non-supprted platforms will serve as a stub lib install
run: python setup.py sdist

- name: Save distributable wheels as artifacts
uses: actions/upload-artifact@v2
with:
name: "pyRF24_pkg_dist"
path: ${{ github.workspace }}/dist

###### We need a self-hosted runner to build distributable wheels for armv7l
# - name: Publish to PyPi
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.pypi_token }}
# run: |
# twine upload dist/*
- name: Publish to PyPi
# only upload distributions to PyPi when triggered by a published release
if: github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: twine upload dist/*
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ if(SKBUILD)
message(STATUS "This project is being built using scikit-build & pybind11")
endif()

include(cmake/using_flags.cmake)

add_subdirectory(pybind11)
add_subdirectory(RF24/utility) # configure the RF24_DRIVER
include(cmake/using_flags.cmake)

################################# RF24 #############################

Expand Down
20 changes: 20 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
recursive-include RF24* *
recursive-include cmake *
recursive-include src/pyrf24 *.cpp *.typed
recursive-include pybind11 *
recursive-exclude */.github *
recursive-exclude */docs *
recursive-exclude */examples* *
recursive-exclude */images *
recursive-exclude */tests *
recursive-exclude */build *
recursive-exclude */cmake/toolchains *.cmake
recursive-exclude RF24/utility/AT* *.h *.cpp *.c
recursive-exclude RF24/utility/Teensy *.h
recursive-exclude RF24/utility/Template* *.h
recursive-exclude RF24/utility/rp2 *.h *.cpp *.txt
recursive-exclude RF24*/pyRF24* *
recursive-exclude RF24Network/RPi/pyRF24Network *
global-exclude .clang-format .clang-tidy .git* library.json library.properties Doxyfile keywords.txt Makefile* doxygen-custom.css **.yml **.yaml *.pdf .pylintrc
exclude */*.md */README* RF24/utility/includes.h RF24/configure
include pyproject.toml setup.py CMakeLists.txt
16 changes: 12 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ To build this python package locally, you need to have cloned this library's rep

git clone --recurse-submodules https://github.com/nRF24/pyRF24.git
cd pyRF24
python -m pip install .
python -m pip install . -v

.. note::
The ``-v`` is optional. Here, we use it to show that pip isn't frozen during the
build process.

Installing the package can take a long time, and you might think that pip is frozen
on the step labeled "Building wheel for pyrf24 (pyproject.toml)". Just wait for about
5 minutes (maybe longer on older/slower variants of Raspberry Pi).
Expand All @@ -81,7 +84,7 @@ it is appropriate to pass an additional argument to the install command:

.. code-block:: bash

python setup.py install -DRF24_DRIVER=RPi
python setup.py bdist_wheel -DRF24_DRIVER=RPi

Building a wheel
-----------------
Expand Down Expand Up @@ -110,7 +113,7 @@ same version of CPython, CPU architecture, and C standard lib.

.. code-block:: bash

rm -r _skbuild/
rm -r _skbuild/ dist/

3. To install a built wheel, simply pass the wheel's path and file name to ``pip install``:

Expand All @@ -120,7 +123,12 @@ same version of CPython, CPU architecture, and C standard lib.

Where the following would be replaced accordingly:

- ``MAJOR.MINOR.PATCH`` is the current version of the pyrf24 package
- ``MAJOR.MINOR.PATCH`` is the current version of the pyrf24 package.

- If not building a tagged commit, then the version will describe the commit relative to
the number of commits since the latest tag. For example, ``0.1.1.post1.dev3`` is
the third commit (``dev3``) since the first "post release" (``post1``) after the
tagged version ``0.1.1``. This adhere's to `PEP440 <https://peps.python.org/pep-0440>`_.
- ``cp3X`` is the version of python used to build the wheel (ie ``cp39`` for CPython 3.9)
The second occurrence of ``cp3X`` describes the CPython ABI compatibility.
- ``ARCH`` is the architecture type of the CPU. This corresponds to the compiler used.
Expand Down
2 changes: 1 addition & 1 deletion RF24
Submodule RF24 updated 149 files
2 changes: 1 addition & 1 deletion RF24Mesh
Submodule RF24Mesh updated 40 files
+165 −0 .clang-format
+60 −15 .github/workflows/build_arduino.yml
+27 −0 .github/workflows/build_linux.yml
+21 −13 .github/workflows/build_platformIO.yml
+27 −0 .github/workflows/build_rp2xxx.yml
+13 −5 .github/workflows/doxygen.yml
+3 −2 .readthedocs.yaml
+10 −3 CMakeLists.txt
+3 −2,262 Doxyfile
+69 −68 RF24Mesh.cpp
+29 −25 RF24Mesh.h
+6 −7 RF24Mesh_config.h
+56 −0 cmake/AutoConfig_RF24_DRIVER.cmake
+12 −26 docs/sphinx/_static/custom_material.css
+2 −2 docs/sphinx/classRF24Mesh.rst
+18 −13 docs/sphinx/conf.py
+145 −0 examples/.clang-format
+14 −7 examples/RF24Mesh_Example/RF24Mesh_Example.ino
+10 −4 examples/RF24Mesh_Example_Master/RF24Mesh_Example_Master.ino
+8 −4 examples/RF24Mesh_Example_Master_Statics/RF24Mesh_Example_Master_Statics.ino
+6 −7 examples/RF24Mesh_Example_Master_To_Nodes/RF24Mesh_Example_Master_To_Nodes.ino
+20 −12 examples/RF24Mesh_Example_Node2Node/RF24Mesh_Example_Node2Node.ino
+20 −11 examples/RF24Mesh_Example_Node2NodeExtra/RF24Mesh_Example_Node2NodeExtra.ino
+11 −5 examples/RF24Mesh_SerialConfig/RF24Mesh_SerialConfig.ino
+0 −31 examples/examples_formatter.conf
+43 −3 examples_RPi/CMakeLists.txt
+45 −37 examples_RPi/RF24Mesh_Example.cpp
+46 −32 examples_RPi/RF24Mesh_Example.py
+39 −38 examples_RPi/RF24Mesh_Example_Master.cpp
+21 −20 examples_RPi/RF24Mesh_Example_Master.py
+4 −4 examples_RPi/ncurses/CMakeLists.txt
+230 −130 examples_RPi/ncurses/RF24Mesh_Ncurses_Master.cpp
+20 −12 examples_pico/RF24Mesh_Example.cpp
+8 −9 examples_pico/RF24Mesh_Example_Master.cpp
+16 −17 examples_pico/defaultPins.h
+ images/RF24Mesh_Ncurses.JPG
+1 −1 library.json
+1 −1 library.properties
+7 −8 pyRF24Mesh/pyRF24Mesh.cpp
+1 −0 pyRF24Mesh/setup.py
2 changes: 1 addition & 1 deletion RF24Network
Submodule RF24Network updated 43 files
+165 −0 .clang-format
+61 −15 .github/workflows/build_arduino.yml
+21 −13 .github/workflows/build_platformIO.yml
+27 −1 .github/workflows/build_rp2xxx.yml
+13 −5 .github/workflows/doxygen.yml
+29 −2 .github/workflows/linux_build.yml
+3 −2 .readthedocs.yaml
+10 −2 CMakeLists.txt
+0 −2,306 Doxyfile
+176 −160 RF24Network.cpp
+74 −75 RF24Network.h
+122 −126 RF24Network_config.h
+0 −56 RPi/pyRF24Network/examples/dev_test.py
+13 −17 RPi/pyRF24Network/examples/helloworld_rx.py
+14 −10 RPi/pyRF24Network/examples/helloworld_tx.py
+20 −20 RPi/pyRF24Network/pyRF24Network.cpp
+2 −1 RPi/pyRF24Network/setup.py
+56 −0 cmake/AutoConfig_RF24_DRIVER.cmake
+1 −3 docs/main_page.md
+15 −24 docs/sphinx/_static/custom_material.css
+6 −0 docs/sphinx/classRF24Network.rst
+19 −13 docs/sphinx/conf.py
+1 −1 docs/sphinx/examples/Arduino/Network_Ping_Sleep.rst
+145 −0 examples/.clang-format
+25 −25 examples/Network_Ping/Network_Ping.ino
+46 −38 examples/Network_Ping_Sleep/Network_Ping_Sleep.ino
+12 −12 examples/Network_Priority_RX/Network_Priority_RX.ino
+7 −7 examples/Network_Priority_TX/Network_Priority_TX.ino
+0 −31 examples/examples_formatter.conf
+8 −8 examples/helloworld_rx/helloworld_rx.ino
+13 −13 examples/helloworld_rx_advanced/helloworld_rx_advanced.ino
+9 −9 examples/helloworld_tx/helloworld_tx.ino
+14 −14 examples/helloworld_tx_advanced/helloworld_tx_advanced.ino
+42 −4 examples_RPi/CMakeLists.txt
+0 −1 examples_RPi/Makefile
+3 −3 examples_RPi/helloworld_rx.cpp
+3 −2 examples_RPi/helloworld_tx.cpp
+22 −21 examples_RPi/rx-test.cpp
+16 −17 examples_pico/defaultPins.h
+7 −8 examples_pico/helloworld_rx.cpp
+7 −8 examples_pico/helloworld_tx.cpp
+1 −1 library.json
+1 −1 library.properties
8 changes: 7 additions & 1 deletion cmake/using_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ option(DISABLE_DYNAMIC_PAYLOADS "force usage of static payload size for RF24Netw
option(MESH_NOMASTER "exclude compiling code that is strictly for master nodes for RF24Mesh lib" OFF)
option(MESH_DEBUG "enable/disable debugging output for RF24Mesh lib" OFF)
option(MESH_DEBUG_MINIMAL "enable/disable minimal debugging output for RF24Mesh lib" OFF)

# Disabling IRQ support should be always done because
# IRQ support can be handled in python with different libs.
option(RF24_NO_INTERRUPT "disable IRQ support (dependent on pigpio)" ON)
# does not affect pigpio driver though

###############################################
# function to apply flags to applicable targets
function(apply_flags target)
# apply RF24 flags to all targets
if(RF24_NO_INTERRUPT)
target_compile_definitions(${target} PUBLIC RF24_NO_INTERRUPT)
endif()
if(RF24_DEBUG)
message(STATUS "RF24_DEBUG asserted for ${target}")
target_compile_definitions(${target} PUBLIC SERIAL_DEBUG)
Expand Down
Loading