Skip to content

Commit b766092

Browse files
committed
chore: migrate to pyproject.toml
1 parent b933572 commit b766092

6 files changed

Lines changed: 144 additions & 156 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exclude: ^(octoprint_file_check/translations|extras/|translations/|.*\.css|.*\.svg)
1+
exclude: ^(octoprint_mfa_totp/translations|extras/|translations/|.*\.css|.*\.svg)
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
44
rev: v4.4.0

Taskfile.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Taskfile to be used with task: https://taskfile.dev
2+
#
3+
# A copy of task gets automatically installed as a "develop" dependency this plugin:
4+
#
5+
# pip install .[develop]
6+
# go-task --list-all
7+
#
8+
9+
version: "3"
10+
11+
env:
12+
LOCALES: ["de"] # list your included locales here, e.g. ["de", "fr"]
13+
TRANSLATIONS: "octoprint_mfa_totp/translations" # translations folder
14+
15+
tasks:
16+
install:
17+
desc: Installs the plugin into the current venv
18+
cmds:
19+
- "python -m pip install -e .[develop]"
20+
21+
### Build related
22+
23+
build:
24+
desc: Builds sdist & wheel
25+
cmds:
26+
- python -m build --sdist --wheel
27+
28+
build-sdist:
29+
desc: Builds sdist
30+
cmds:
31+
- python -m build --sdist
32+
33+
build-wheel:
34+
desc: Builds wheel
35+
cmds:
36+
- python -m build --wheel
37+
38+
### Translation related
39+
40+
babel-new:
41+
desc: Create a new translation for a locale
42+
cmds:
43+
- task: babel-extract
44+
- pybabel init --input-file=translations/messages.pot --output-dir=translations --locale="{{ .CLI_ARGS }}"
45+
46+
babel-extract:
47+
desc: Update pot file from source
48+
cmds:
49+
- pybabel extract --mapping-file=babel.cfg --output-file=translations/messages.pot --msgid-bugs-address=i18n@octoprint.org --copyright-holder="The OctoPrint Project" .
50+
51+
babel-update:
52+
desc: Update translation files from pot file
53+
cmds:
54+
- for:
55+
var: LOCALES
56+
cmd: pybabel update --input-file=translations/messages.pot --output-dir=translations --locale={{ .ITEM }}
57+
58+
babel-refresh:
59+
desc: Update translation files from source
60+
cmds:
61+
- task: babel-extract
62+
- task: babel-update
63+
64+
babel-compile:
65+
desc: Compile translation files
66+
cmds:
67+
- pybabel compile --directory=translations
68+
69+
babel-bundle:
70+
desc: Bundle translations
71+
preconditions:
72+
- test -d {{ .TRANSLATIONS }}
73+
cmds:
74+
- for:
75+
var: LOCALES
76+
cmd: |
77+
locale="{{ .ITEM }}"
78+
source="translations/${locale}"
79+
target="{{ .TRANSLATIONS }}/${locale}"
80+
81+
[ ! -d "${target}" ] || rm -r "${target}"
82+
83+
echo "Copying translations for locale ${locale} from ${source} to ${target}..."
84+
cp -r "${source}" "${target}"

pyproject.toml

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
[build-system]
2-
requires = ["setuptools>=40.8.0", "wheel", "octoprint-setuptools"]
2+
requires = [
3+
"setuptools>=68"
4+
]
35
build-backend = "setuptools.build_meta"
46

7+
[project]
8+
name = "OctoPrint-MfaTotp"
9+
version = "1.0.0"
10+
description = "Plugin to support TOTP based Two Factor Authentication in OctoPrint."
11+
authors = [
12+
{ name = "Gina Häußge", email = "gina@octoprint.org" },
13+
]
14+
requires-python = ">=3.7,<4"
15+
dependencies = [
16+
"pyotp>=2.9.0,<3",
17+
]
18+
dynamic = [
19+
"license",
20+
]
21+
22+
[project.entry-points."octoprint.plugin"]
23+
mfa_totp = "octoprint_mfa_totp"
24+
25+
[project.urls]
26+
Homepage = "https://github.com/OctoPrint/OctoPrint-MfaTotp"
27+
28+
[project.optional-dependencies]
29+
develop = [
30+
"go-task-bin",
31+
]
32+
33+
[project.readme]
34+
file = "README.md"
35+
content-type = "text/markdown"
36+
37+
[tool.setuptools]
38+
include-package-data = true
39+
40+
[tool.setuptools.packages.find]
41+
include = [
42+
"octoprint_mfa_totp",
43+
"octoprint_mfa_totp.*",
44+
]
45+
546
[tool.ruff]
647
exclude = [
7-
# standard stuff
848
".bzr",
949
".direnv",
1050
".eggs",
@@ -32,15 +72,20 @@ exclude = [
3272
"site-packages",
3373
"venv",
3474
]
35-
3675
line-length = 90
3776
indent-width = 4
38-
39-
# Assume Python 3.7
4077
target-version = "py37"
4178

4279
[tool.ruff.lint]
43-
select = ["B", "C", "E", "F", "I", "W", "B9"]
80+
select = [
81+
"B",
82+
"C",
83+
"E",
84+
"F",
85+
"I",
86+
"W",
87+
"B9",
88+
]
4489
ignore = [
4590
"E203",
4691
"E231",
@@ -53,9 +98,11 @@ ignore = [
5398
"W605",
5499
"C901",
55100
]
56-
fixable = ["I", "C4", "E"]
57-
58-
# Allow unused variables when underscore-prefixed.
101+
fixable = [
102+
"I",
103+
"C4",
104+
"E",
105+
]
59106
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
60107

61108
[tool.ruff.lint.isort]
@@ -68,17 +115,5 @@ quote-style = "double"
68115
indent-style = "space"
69116
skip-magic-trailing-comma = false
70117
line-ending = "lf"
71-
72-
# Enable auto-formatting of code examples in docstrings. Markdown,
73-
# reStructuredText code/literal blocks and doctests are all supported.
74-
#
75-
# This is currently disabled by default, but it is planned for this
76-
# to be opt-out in the future.
77118
docstring-code-format = false
78-
79-
# Set the line length limit used when formatting code snippets in
80-
# docstrings.
81-
#
82-
# This only has an effect when the `docstring-code-format` setting is
83-
# enabled.
84119
docstring-code-line-length = "dynamic"

requirements.txt

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

setup.cfg

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

setup.py

Lines changed: 3 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,4 @@
1-
########################################################################################################################
2-
### Do not forget to adjust the following variables to your own plugin.
1+
import setuptools
32

4-
# The plugin's identifier, has to be unique
5-
plugin_identifier = "mfa_totp"
6-
7-
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
8-
plugin_package = "octoprint_mfa_totp"
9-
10-
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
11-
# plugin module
12-
plugin_name = "OctoPrint-MfaTotp"
13-
14-
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
15-
plugin_version = "1.0.0"
16-
17-
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
18-
# module
19-
plugin_description = (
20-
"""Plugin to support TOTP based Two Factor Authentication in OctoPrint."""
21-
)
22-
23-
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
24-
plugin_author = "Gina Häußge"
25-
26-
# The plugin's author's mail address.
27-
plugin_author_email = "gina@octoprint.org"
28-
29-
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
30-
plugin_url = "https://github.com/OctoPrint/OctoPrint-MfaTotp"
31-
32-
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
33-
plugin_license = "AGPLv3"
34-
35-
# Any additional requirements besides OctoPrint should be listed here
36-
plugin_requires = ["pyotp>=2.9.0,<3"]
37-
38-
### --------------------------------------------------------------------------------------------------------------------
39-
### More advanced options that you usually shouldn't have to touch follow after this point
40-
### --------------------------------------------------------------------------------------------------------------------
41-
42-
# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will
43-
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
44-
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
45-
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
46-
plugin_additional_data = []
47-
48-
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
49-
plugin_additional_packages = []
50-
51-
# Any python packages within <plugin_package>.* you do NOT want to install with your plugin
52-
plugin_ignored_packages = []
53-
54-
# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points,
55-
# define dependency links or other things like that, this is the place to go. Will be merged recursively with the
56-
# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using
57-
# octoprint.util.dict_merge.
58-
#
59-
# Example:
60-
# plugin_requires = ["someDependency==dev"]
61-
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]}
62-
# "python_requires": ">=3,<4" blocks installation on Python 2 systems, to prevent confused users and provide a helpful error.
63-
# Remove it if you would like to support Python 2 as well as 3 (not recommended).
64-
additional_setup_parameters = {"python_requires": ">=3,<4"}
65-
66-
########################################################################################################################
67-
68-
from setuptools import setup # noqa: I001
69-
70-
try:
71-
import octoprint_setuptools
72-
except: # noqa: E722
73-
print(
74-
"Could not import OctoPrint's setuptools, are you sure you are running that under "
75-
"the same python installation that OctoPrint is installed under?"
76-
)
77-
import sys
78-
79-
sys.exit(-1)
80-
81-
setup_parameters = octoprint_setuptools.create_plugin_setup_parameters(
82-
identifier=plugin_identifier,
83-
package=plugin_package,
84-
name=plugin_name,
85-
version=plugin_version,
86-
description=plugin_description,
87-
author=plugin_author,
88-
mail=plugin_author_email,
89-
url=plugin_url,
90-
license=plugin_license,
91-
requires=plugin_requires,
92-
additional_packages=plugin_additional_packages,
93-
ignored_packages=plugin_ignored_packages,
94-
additional_data=plugin_additional_data,
95-
)
96-
97-
if len(additional_setup_parameters):
98-
99-
def leaf_merge(a, b):
100-
for k, v in b.items():
101-
if k in a and isinstance(a[k], dict) and isinstance(v, dict):
102-
leaf_merge(a[k], v)
103-
else:
104-
a[k] = v
105-
106-
leaf_merge(setup_parameters, additional_setup_parameters)
107-
108-
setup(**setup_parameters)
3+
# we define the license string like this to be backwards compatible to setuptools<77
4+
setuptools.setup(license="AGPL-3.0-or-later")

0 commit comments

Comments
 (0)