~sircmpwn/sr.ht-dev

scm.sr.ht: Preparations for PEP440 support v1 APPLIED

Conrad Hoffmann: 1
 Preparations for PEP440 support

 4 files changed, 26 insertions(+), 3 deletions(-)
#1228363 alpine.yml success
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/~sircmpwn/sr.ht-dev/patches/52862/mbox | git am -3
Learn more about email & git

[PATCH scm.sr.ht] Preparations for PEP440 support Export this patch

Currrently, builds for patches are broken because the version numbers
generated for them are not valid according to PEP 440 [1].

This has to be solved in several steps, in coordination with the
packaging code. Just as was done with core.sr.ht, the plan is:

1. Add a pyproject.toml without touching setup.py (this commit)
2. Switch APKBUILD from `python setup.py build` to `python -m build`
3. Reduce setup.py to a stub, encoding all relevant information in
   pyproject.toml

With this commit, this module can be build with both `python setup.py
build` and `python -m build`, if, _and only if_ the PKGVER environment
variable is set, which is true for all our tooling.

As the version passed in via the environment is still not
PEP440-compatible, packaging non-tagged versions will remain broken
until step three above is executed.

The .gitattributes and .git_archival files are included for the future
setup. Since packages are built from `git-archive` tarballs, the commit
information has to be transported into the tarballs. The setuptools-scm
package specifies a mechanism for this [3]. Note, that in order to avoid
a hilarious bug [4] the checked in `.git_archival.txt` differs from the
template found in the documentation. The git version on git.sr.ht is new
enough that the `describe-name` will be expanded, and if present it is
the only information that setuptools-scm really requires.

Includes minor cleanups in setup.py itself.

[1] https://peps.python.org/pep-0440
[2] https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/50784
[3]: https://setuptools-scm.readthedocs.io/en/latest/usage/#git-archives
[4]: https://github.com/pypa/setuptools_scm/issues/806
---
 .git_archival.txt |  1 +
 .gitattributes    |  1 +
 pyproject.toml    | 23 +++++++++++++++++++++++
 setup.py          |  4 +---
 4 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 .git_archival.txt
 create mode 100644 .gitattributes
 create mode 100644 pyproject.toml

diff --git a/.git_archival.txt b/.git_archival.txt
new file mode 100644
index 0000000..2a6ca7c
--- /dev/null
+++ b/.git_archival.txt
@@ -0,0 +1 @@
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..00a7b00
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
.git_archival.txt  export-subst
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..e5e86f8
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,23 @@
[build-system]
requires = ["setuptools", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[project]
name = "scmsrht"
dynamic = ["version"]
description = "scm.sr.ht library"
authors = [{name = "Ludovic Chabant", email = "ludovic@chabant.com"}]
dependencies = [
      "srht",
]
license.text = "AGPL-3.0-only"

[project.urls]
repository = "https://git.sr.ht/~sircmpwn/scm.sr.ht"

[tool.setuptools]
packages = [
    "scmsrht",
]

[tool.setuptools_scm]
diff --git a/setup.py b/setup.py
index 7315468..17c9434 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python3
from distutils.core import setup
from setuptools import setup
import subprocess
import os
import site
import sys

ver = os.environ.get("PKGVER") or subprocess.run(['git', 'describe', '--tags'],
      stdout=subprocess.PIPE).stdout.decode().strip()
-- 
2.45.1
scm.sr.ht/patches/alpine.yml: SUCCESS in 22s

[Preparations for PEP440 support][0] from [Conrad Hoffmann][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/52862
[1]: mailto:ch@bitfehler.net

✓ #1228363 SUCCESS scm.sr.ht/patches/alpine.yml https://builds.sr.ht/~sircmpwn/job/1228363
Thanks!

To git@git.sr.ht:~sircmpwn/scm.sr.ht
   37e5f61..30dfb43  master -> master