Skip to content
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
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ jobs:
- name: Report the coverage
working-directory: tests
run: |
python -m coverage lcov --omit=test*,_version*
python -m coverage report --show-missing --omit=test*,_version*
python -m coverage lcov --omit=test*
python -m coverage report --show-missing --omit=test*
- name: Coveralls
uses: coverallsapp/github-action@v2
continue-on-error: true
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ jobs:
path: ${{ steps.pipCache.outputs.dir }}
key: ${{ runner.os }}-release-cache-pip
- name: Install distribution dependencies
run: pip install --upgrade wheel setuptools pip
run: pip install build
- name: Install OctoPrint
run: pip install octoprint~=${{ env.OCTOPRINT_VERSION }}.0
### Packing
- name: Build distribution package
run: python setup.py sdist --formats=zip
run: python -m build --sdist
## Required for backward compatibility, see UPDATES_CONFIG, todo: reconsider in v6
- name: Repack as ZIP
run: |
mkdir -p repack
tar -xzf dist/octorelay-*.tar.gz -C repack
rm -rf dist/*
cd repack && zip -r ../dist/release.zip .
cd .. && rm -rf repack
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
Expand Down Expand Up @@ -111,7 +119,7 @@ jobs:
# see https://community.octoprint.org/t/setuptools-error-while-installing-plugin-octoklipper-on-manual-op-installation/51387
run: pip install wheel
- name: Install the distributed package
run: pip install dist/octorelay-*.zip
run: pip install dist/release.zip

attach:
name: Attaching asset to the release
Expand All @@ -125,9 +133,7 @@ jobs:
with:
name: dist
path: dist
- name: Rename to release.zip
run: cp dist/octorelay-*.zip release.zip
- name: Attach the asset
uses: softprops/action-gh-release@v2
with:
files: release.zip
files: dist/release.zip
2 changes: 0 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ ignore-paths=
# The regex matches against base names, not paths. The default value ignores
# Emacs file locks
ignore-patterns=^\.#,
_static_version\.py,
_version\.py

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Version 5

### 5.4.0

- Modernized the build system: no longer use `setup.py`, now using `pyproject.toml` solely;
- Plugin versioning switched from `miniver` to `setuptools-scm`;
- Release file format remains `.zip` for automatic updates, but may be changed in the future v6;
- Explicitly enabled the plugin API protection: authentication required (`X-Api-Key`);
- Explicitly enabled template autoescaping to prevent potential XSS vulnerabilities.

### 5.3.0

- Adds `pyproject.toml` file to the distribution:
Expand Down
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ recursive-include octoprint_octorelay/static *
exclude octoprint_octorelay/static/js/.gitkeep
exclude octoprint_octorelay/static/css/.gitkeep
prune tests
prune ui
prune .github
prune .devcontainer
prune img
exclude .gitignore
exclude .pylintrc
exclude mypy.ini
exclude *.sh
exclude setup.cfg
exclude babel.cfg
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ ignore_missing_imports = True

[mypy-flask.*]
ignore_missing_imports = True

[mypy-octoprint_octorelay._version]
ignore_errors = True
12 changes: 10 additions & 2 deletions octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from functools import reduce
import os
import time
from importlib.metadata import version
import flask

import octoprint.plugin
Expand Down Expand Up @@ -92,6 +93,14 @@ def get_api_commands(self):
CANCEL_TASK_COMMAND: [ "subject", "target", "owner" ]
}

def is_api_protected(self):
# https://docs.octoprint.org/en/main/plugins/mixins.html#octoprint.plugin.SimpleApiPlugin.is_api_protected
return True

def is_template_autoescaped(self):
# https://docs.octoprint.org/en/main/plugins/mixins.html#octoprint.plugin.TemplatePlugin.is_template_autoescaped
return True

def get_additional_permissions(self, *args, **kwargs):
return [ SWITCH_PERMISSION ]

Expand Down Expand Up @@ -381,5 +390,4 @@ def input_polling(self):
__plugin_implementation__.process_at_command
}

# pylint: disable=wrong-import-position
from ._version import __version__
__version__ = version("OctoRelay")
12 changes: 0 additions & 12 deletions octoprint_octorelay/_static_version.py

This file was deleted.

196 changes: 0 additions & 196 deletions octoprint_octorelay/_version.py

This file was deleted.

46 changes: 43 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
[build-system]
requires = [
"setuptools",
"wheel",
"octoprint",
"setuptools>=77",
"setuptools-scm>=8",
]
build-backend = "setuptools.build_meta"

[project]
name = "OctoRelay"
dynamic = ["version"]
description = "A plugin that adds buttons to the navbar for toggling GPIO on the RPi. It can be used for turning relays on and off."
authors = [
{ name = "Boris Burgstaller", email = "raspi@burgstaller.net" },
]
requires-python = ">=3.9,<4"
dependencies = [
"gpiozero",
"lgpio",
"RPi.GPIO",
]
license = "AGPL-3.0-or-later"

[project.entry-points."octoprint.plugin"]
octorelay = "octoprint_octorelay"

[project.urls]
Homepage = "https://github.com/borisbu/OctoRelay"

[project.optional-dependencies]
develop = [
"go-task-bin",
]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = [
"octoprint_octorelay",
"octoprint_octorelay.*",
]

[tool.setuptools_scm]
Loading
Loading