From 059773e24f928926eae23843255ab632f7e7a893 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Mon, 14 Oct 2024 08:52:28 -0700 Subject: [PATCH 1/4] release: 2.0.1 * Fix license as classifier (Thanks, @sevdog!) #170 --- setup.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index f8756d1..112e754 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import find_packages, setup -__version__ = "2.0.0" +__version__ = "2.0.1" def read_from(file): @@ -44,6 +44,7 @@ def read_from(file): "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python", "Programming Language :: Python :: 3", + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", ], keywords="push webpush publication", author="JR Conlin", @@ -58,8 +59,6 @@ def read_from(file): # be created, and still will if you run # `python setup.py develop` entry_points={ - "console_scripts": [ - "pywebpush=pywebpush.__main__:main" - ], - } + "console_scripts": ["pywebpush=pywebpush.__main__:main"], + }, ) From d81acfd8e1e34664298f4a1a8203b5463e0bbdef Mon Sep 17 00:00:00 2001 From: jrconlin Date: Mon, 14 Oct 2024 08:57:12 -0700 Subject: [PATCH 2/4] chore: tag 2.0.1 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0999302..31531a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # I am terrible at keeping this up-to-date. +## 2.0.1 (2024-10-14) +docs: Use License classifiers in pyproject.toml (thanks @sevdog) + ## 2.0.0 (2024-01-02) chore: Update to modern python practices * include pyproject.toml file From c59bf166f1a4dcbebfae43967ab460aecce19da7 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Mon, 5 Jan 2026 09:06:11 -0800 Subject: [PATCH 3/4] update README.rst --- README.rst | 60 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index 7584bf0..77e8af4 100644 --- a/README.rst +++ b/README.rst @@ -14,12 +14,8 @@ make of that what you will. Installation ------------ -You’ll need to run ``python -m venv venv``. Then - -.. code:: bash - - venv/bin/pip install -r requirements.txt - venv/bin/python -m pip install -e . +To work with this repo locally, you’ll need to run +``python -m venv venv``. Then ``venv/bin/pip install --editable .`` Usage ----- @@ -35,7 +31,10 @@ As illustration, a ``subscription_info`` object may look like: .. code:: json - {"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth": "k8J...", "p256dh": "BOr..."}} + { + "endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...", + "keys": { "auth": "k8J...", "p256dh": "BOr..." } + } How you send the PushSubscription data to your backend, store it referenced to the user who requested it, and recall it when there’s a @@ -60,7 +59,8 @@ This will encode ``data``, add the appropriate VAPID auth headers if required and send it to the push server identified in the ``subscription_info`` block. -**Parameters** +Parameters +'''''''''' *subscription_info* - The ``dict`` of the subscription info (described above). @@ -78,7 +78,9 @@ standard form. authorization (See `py_vapid `__ for more details). If ``aud`` is not specified, pywebpush will attempt -to auto-fill from the ``endpoint``. +to auto-fill from the ``endpoint``. If ``exp`` is not specified or set +in the past, it will be set to 12 hours from now. In both cases, the +passed ``dict`` **will be mutated** after the call. *vapid_private_key* - Either a path to a VAPID EC2 private key PEM file, or a string containing the DER representation. (See @@ -93,7 +95,8 @@ e.g. the output of: openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem -**Example** +Example +''''''' .. code:: python @@ -140,7 +143,10 @@ The following methods are available: Send the data using additional parameters. On error, returns a ``WebPushException`` -**Parameters** +.. _parameters-1: + +Parameters +'''''''''' *data* Binary string of data to send @@ -165,7 +171,10 @@ purposes. *timeout* timeout for requests POST query. See `requests documentation `__. -**Example** +.. _example-1: + +Example +''''''' to send from Chrome using the old GCM mode: @@ -179,13 +188,24 @@ to send from Chrome using the old GCM mode: Encode the ``data`` for future use. On error, returns a ``WebPushException`` -**Parameters** +.. _parameters-2: + +Parameters +'''''''''' *data* Binary string of data to send *content_encoding* ECE content encoding type (defaults to “aes128gcm”) -**Example** +*Note* This will return a ``NoData`` exception if the data is not +present or empty. It is completely valid to send a WebPush notification +with no data, but encoding is a no-op in that case. Best not to call it +if you don’t have data. + +.. _example-2: + +Example +''''''' .. code:: python @@ -207,11 +227,13 @@ This uses two files: .. code:: json - {"endpoint": "https://push...", - "keys": { - "auth": "ab01...", - "p256dh": "aa02..." - }} + { + "endpoint": "https://push...", + "keys": { + "auth": "ab01...", + "p256dh": "aa02..." + } + } If you’re interested in just testing your applications WebPush interface, you could use the Command Line: From a5e40bee8e0382a8895fc4fbe2039ed5f18a3499 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Mon, 10 Aug 2026 15:35:43 -0700 Subject: [PATCH 4/4] feat: Update github actions Based on discovery from action_playground --- .github/workflows/python-lint.yml | 6 +-- .github/workflows/python-package.yml | 57 ++++++---------------------- 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 08fff8c..c5bc03e 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -20,17 +20,15 @@ jobs: python-version: ["3.10", "3.11", "3.13", "3.14"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install black pytest python -m pip install ".[dev]" - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e998dc9..10e6bcd 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -4,50 +4,21 @@ name: Python package on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_run: + workflows: + - "Python lint" + types: + - completed + branches: + - main jobs: - lint_and_test: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # PYTHON_VER - python-version: ["3.10", "3.11", "3.13", "3.14"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install black pytest - python -m pip install ".[dev]" - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint - run: | - # stop the build if there are Python syntax errors or undefined names - black --quiet --diff --config pyproject.toml --check pywebpush - bandit --quiet -c pyproject.toml pywebpush - - name: Test with pytest - run: | - pytest pywebpush - release-build: runs-on: ubuntu-latest - needs: lint_and_test - + if: ${{ github.event.workflow_run.conclusion == 'success'}} && !startsWith({{ github.event.ref_name }}, "doc/") steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 with: python-version: "3.x" @@ -66,18 +37,14 @@ jobs: pypi-publish: # Remember, matching strings need to be in single quotes. - if: ${{ github.event_name == 'push' && ( github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/') ) }} runs-on: ubuntu-latest - needs: - - release-build permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write - # Dedicated environments with protections for publishing are strongly recommended. # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules environment: - name: pypi + name: pypi-publish # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: url: https://pypi.org/p/pywebpush # @@ -87,7 +54,7 @@ jobs: steps: - name: Retrieve release distributions - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: release-dists path: dist/