diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml
new file mode 100644
index 00000000..4a1fe659
--- /dev/null
+++ b/.github/workflows/pypi.yml
@@ -0,0 +1,32 @@
+name: Publish Python Package to Pypi.org
+
+on:
+ release:
+ types: [published]
+
+permissions:
+ id-token: write
+
+jobs:
+ pypi-publish:
+ name: Release Python Package on Pypi.org
+ runs-on: ubuntu-latest
+ environment:
+ name: pypi
+ url: https://pypi.org/p/openwisp-utils
+ permissions:
+ id-token: write
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - name: Install dependencies
+ run: |
+ pip install -U pip
+ pip install build
+ - name: Build package
+ run: python -m build
+ - name: Publish package distributions to PyPI
+ uses: pypa/gh-action-pypi-publish@v1.9.0
diff --git a/openwisp_utils/metric_collection/migrations/0001_initial.py b/openwisp_utils/metric_collection/migrations/0001_initial.py
index 845a5da9..25152d14 100644
--- a/openwisp_utils/metric_collection/migrations/0001_initial.py
+++ b/openwisp_utils/metric_collection/migrations/0001_initial.py
@@ -45,7 +45,12 @@ class Migration(migrations.Migration):
"user_consented",
models.BooleanField(
default=True,
- help_text='Allow OpenWISP to collect and share anonymous usage metrics to improve the software. Before opting-out kindly consider reading why we collect metrics.',
+ help_text=(
+ 'Allow OpenWISP to collect and share anonymous usage metrics to improve'
+ ' the software. Before opting-out kindly consider reading'
+ ' why we collect metrics.'
+ ),
verbose_name="Allow collecting anonymous usage metrics",
),
),
diff --git a/setup.cfg b/setup.cfg
index 386ce3d4..74312533 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -12,7 +12,4 @@ use_parentheses=True
line_length=88
[flake8]
-exclude = *migrations/0*,,
- ./tests/*settings*.py,
- ./*setup*.py
max-line-length = 110
diff --git a/setup.py b/setup.py
index c7842fc3..bc4bbf2f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,23 +1,7 @@
#!/usr/bin/env python
-import os
-import sys
-
from openwisp_utils import get_version
from setuptools import find_packages, setup
-if sys.argv[-1] == 'publish':
- # delete any *.pyc, *.pyo and __pycache__
- os.system('find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf')
- os.system("python setup.py sdist bdist_wheel")
- os.system("twine upload -s dist/*")
- os.system("rm -rf dist build")
- args = {'version': get_version()}
- print("You probably want to also tag the version now:")
- print(" git tag -a %(version)s -m 'version %(version)s'" % args)
- print(" git push --tags")
- sys.exit()
-
-
setup(
name='openwisp-utils',
version=get_version(),
diff --git a/tests/openwisp2/settings.py b/tests/openwisp2/settings.py
index 44bea680..17d4e58a 100644
--- a/tests/openwisp2/settings.py
+++ b/tests/openwisp2/settings.py
@@ -131,6 +131,6 @@
# local settings must be imported before test runner otherwise they'll be ignored
try:
- from local_settings import *
+ from local_settings import * # noqa
except ImportError:
pass