~lioploum/offpunk-devel

A bunch of unrelated patches v1 PROPOSED

The first two patches are pyproject.toml metadata updates.

Patch #3 is untested and needs polishing, exchanging secrets etc.

Patch #4 fixes a minor annoyance for LibreSSL users.
Applied, thanks for the patch

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
Applied, thanks for the patch

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
Thanks for that patch. I merged it and added the secret part. 

But I can’t really test it until there’s a release. One option would be 
to remove the "if git_ref" code to test it, acknowledging that the Pypi 
2.6 would not be the true 2.6.

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
Hi Anna,

Could you explain a bit more the context? If I understand this 
correctly, you would like the pypi package to be published automatically 
when pushing a new release?
Am I supposed to get a secret token somewhere? And how can the secret be 
put in the build.yml?
Also, I’m not sure I fully understand the code.
Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
Applied, thanks for the patch!

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
GIT_REF is set by git.sr.ht as the Git reference which triggered the 
build (e.g. refs/heads/master).

This expression uses pattern matching to make sure GIT_REF starts with 
"refs/tags/".

Maybe there should also be a check for repository name, so it isn't run 
on forks.
Next
Remove "dist" if it exists.
Next
Build a source distribution package and a wheel package.
Next
Source PyPI credential from secrets.
Next
Publish built packages to PyPI.
Next
Le 25 mar 09 09:50, Anna  Vyalkova a écrit :
Next
Le 25 mar 10 09:38, Anna  Vyalkova a écrit :
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~lioploum/offpunk-devel/patches/57938/mbox | git am -3
Learn more about email & git

[PATCH 1/4] pyproject: use PEP 639 license metadata Export this patch

License classifiers and "project.license" subkeys are now deprecated.

SPDX expressions should be used instead:
https://peps.python.org/pep-0639/
---
 pyproject.toml | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 2b8af81..cde9e8a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling>=1.5"]
build-backend = "hatchling.build"

[project]
@@ -11,11 +11,12 @@ authors = [
maintainers = [
    {name = "Lionel Dricot (Ploum)", email = "offpunk2@ploum.eu"},
]
license = "AGPL-3.0-or-later"
license-files = ["LICENSE"]
readme = "README.md"
classifiers = [
    "Development Status :: 4 - Beta",
    "Environment :: Console",
    "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3 :: Only",
    "Topic :: Communications",
@@ -25,9 +26,6 @@ keywords = ["gemini", "browser"]
requires-python = ">=3.7"
dynamic = ["version", "description"]

[project.license]
file = "LICENSE"

[project.optional-dependencies]
better-tofu = ["cryptography"]
chardet = ["chardet"]
-- 
2.48.1
Applied, thanks for the patch

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :

[PATCH 2/4] pyproject: add a dependency group for tests Export this patch

Could be used with test runners like Tox.

See: https://peps.python.org/pep-0735/
---
 pyproject.toml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pyproject.toml b/pyproject.toml
index cde9e8a..a2a74ac 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,6 +45,12 @@ netcache = "netcache:main"
ansicat = "ansicat:main"
opnk = "opnk:main"

[dependency-groups]
test = [
    "pytest",
    "pytest-mock",
]

[tool.hatch.version]
path = "offpunk.py" # read __version__

-- 
2.48.1
Applied, thanks for the patch

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :

[PATCH 3/4] build.yml: support publishing to PyPI Export this patch

It needs UV_PUBLISH_TOKEN environment variable configured:
https://docs.astral.sh/uv/guides/package/#publishing-your-package

Commented the publishing part for now, because it requires actual
secrets.
---
 .build.yml | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/.build.yml b/.build.yml
index bac87f3..d9ec6ff 100644
--- a/.build.yml
+++ b/.build.yml
@@ -1,10 +1,24 @@
image: alpine/3.19
image: alpine/latest
oauth: pages.sr.ht/PAGES:RW
packages:
- hut
- uv
#secrets:
#  - insert-uuid-here # pypi credentials
environment:
  site1: offpunk.net
tasks:
- publish-pypi: |
    if [[ ${GIT_REF} != refs/tags/* ]]; then
      echo "Current commit is not a tag; not building anything"
      exit 0
    fi

    rm -rf dist
    uv build

    #. ~/.pypi-credentials
    #uv publish dist/*
- package-gemini: |
    cd offpunk/tutorial
    tar -cvzh . > ../../capsule.tar.gz
-- 
2.48.1
Thanks for that patch. I merged it and added the secret part. 

But I can’t really test it until there’s a release. One option would be 
to remove the "if git_ref" code to test it, acknowledging that the Pypi 
2.6 would not be the true 2.6.


Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :
Hi Anna,

Could you explain a bit more the context? If I understand this 
correctly, you would like the pypi package to be published automatically 
when pushing a new release?

Am I supposed to get a secret token somewhere? And how can the secret be 
put in the build.yml?

Also, I’m not sure I fully understand the code.

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :

[PATCH 4/4] disable a urllib3 warning shown to LibreSSL users Export this patch

Context: https://github.com/urllib3/urllib3/issues/3020
---
 netcache.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/netcache.py b/netcache.py
index da66e7a..c43206b 100755
--- a/netcache.py
+++ b/netcache.py
@@ -11,6 +11,7 @@ import ssl
import sys
import time
import urllib.parse
import warnings
from ssl import CertificateError

import ansicat
@@ -35,7 +36,10 @@ try:
except (ModuleNotFoundError, ImportError):
    _HAS_CRYPTOGRAPHY = False
try:
    import requests
    with warnings.catch_warnings():
        # Disable annoying warning shown to LibreSSL users
        warnings.simplefilter("ignore")
        import requests

    _DO_HTTP = True
except (ModuleNotFoundError, ImportError):
-- 
2.48.1
Applied, thanks for the patch!

Le 25 mar 08 06:12, Anna “CyberTailor” a écrit :