Date: Monday, January 2, 2023 @ 07:41:54
  Author: grawlinson
Revision: 1372864

upgpkg: reuse 1.1.0-1; new upstream release

* New upstream release.
* Hacky workaround, reported upstream.

Added:
  reuse/trunk/ftbfs-build.py.patch
Modified:
  reuse/trunk/PKGBUILD

----------------------+
 PKGBUILD             |   52 +++++++++++++++------
 ftbfs-build.py.patch |  116 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+), 16 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2023-01-02 03:47:31 UTC (rev 1372863)
+++ PKGBUILD    2023-01-02 07:41:54 UTC (rev 1372864)
@@ -4,17 +4,15 @@
 # SPDX-License-Identifier: CC0-1.0
 
 pkgname=reuse
-_pkgname=reuse-tool
-pkgver=1.0.0
-pkgrel=2
+pkgver=1.1.0
+pkgrel=1
 pkgdesc='Helper tool for providing and confirming copyright and licensing 
information'
 arch=('any')
-url='https://github.com/fsfe/reuse-tool'
-license=('GPL3' 'Apache' 'custom:CC-BY-SA-4.0' 'custom:CC0-1.0')
+url='https://reuse.software/'
+license=('GPL3' 'Apache' 'custom:CC0-1.0')
 depends=(
   'python'
   'python-debian'
-  'python-requests'
   'python-license-expression'
   'python-boolean.py'
   'python-jinja'
@@ -23,7 +21,10 @@
 )
 makedepends=(
   'git'
-  'python-setuptools-scm'
+  'python-build'
+  'python-installer'
+  'python-wheel'
+  'python-poetry-core'
 )
 checkdepends=('python-pytest')
 optdepends=(
@@ -30,9 +31,13 @@
   'git: git repository support'
   'mercurial: mercurial repository support'
 )
-_commit='b0fd725328e42d98f6c8e60d2d3587dd728bbcc7'
-source=("$pkgname::git+$url#commit=$_commit")
-b2sums=('SKIP')
+_commit='1cd6ec56c825ba62e097a95b743edde76d4398ca'
+source=(
+  "$pkgname::git+https://github.com/fsfe/reuse-tool#commit=$_commit";
+  'ftbfs-build.py.patch'
+)
+b2sums=('SKIP'
+        
'52794da4f1c871591a0be306388aff4973ca0a90ad43162b8762c8c8c283122943ed8e383e1424307dff8e8112267f02ea6f5c66b28d45f6afb6ec583bd27a0d')
 
 pkgver() {
   cd "$pkgname"
@@ -43,23 +48,38 @@
 build() {
   cd "$pkgname"
 
-  python setup.py build
+  # https://github.com/fsfe/reuse-tool/issues/640
+  # why does this look horrible?
+  # let me count the ways:
+
+  # 1. this creates the locale files, but not the rest of the actual package!
+  python -m build --wheel --no-isolation
+
+  # 2. this removes the problem
+  patch -p1 -i "$srcdir/ftbfs-build.py.patch"
+
+  # 3. this builds the rest of the actual package
+  python -m build --wheel --no-isolation
 }
 
 check() {
   cd "$pkgname"
 
-  pytest
+  pytest -v
 }
 
 package() {
   cd "$pkgname"
 
-  python setup.py install \
-    --root="$pkgdir" \
-    --optimize=1 \
-    --skip-build
+  python -m installer --destdir="$pkgdir" dist/*.whl
 
+  # NFI what poetry is doing, it's installing stuff to the wrong directory
+  local site_packages=$(python -c "import site; 
print(site.getsitepackages()[0])")
+  pushd "$pkgdir/$site_packages"
+  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" AUTHORS.rst CHANGELOG.md 
README.md
+  rm -rf AUTHORS.rst CHANGELOG.md README.md
+  popd
+
   # licenses
   install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSES/*
 

Added: ftbfs-build.py.patch
===================================================================
--- ftbfs-build.py.patch                                (rev 0)
+++ ftbfs-build.py.patch        2023-01-02 07:41:54 UTC (rev 1372864)
@@ -0,0 +1,116 @@
+--- a/build.py
++++ /dev/null
+@@ -1,103 +0,0 @@
+-#!/usr/bin/env python3
+-#
+-# SPDX-FileCopyrightText: 2017 Free Software Foundation Europe e.V. 
<https://fsfe.org>
+-# SPDX-FileCopyrightText: 2022 Carmen Bianca Bakker <[email protected]>
+-#
+-# SPDX-License-Identifier: GPL-3.0-or-later
+-
+-"""Script called by poetry. The API used by poetry is unstable, but let's hope
+-this stays functional.
+-"""
+-
+-import glob
+-import os
+-import shutil
+-import subprocess
+-from pathlib import Path
+-from warnings import warn
+-
+-from setuptools import Distribution
+-from setuptools.command.build_py import build_py
+-
+-# pylint: disable=attribute-defined-outside-init
+-
+-
+-class Build(build_py):
+-    """Redefined build."""
+-
+-    def initialize_options(self):
+-        super().initialize_options()
+-        self.po_files = None
+-        self.msgfmt = None
+-        self.mo_outputs = []
+-
+-    def finalize_options(self):
+-        super().finalize_options()
+-        self.po_files = glob.glob("po/*.po")
+-        for msgfmt in ["msgfmt", "msgfmt.py", "msgfmt3.py"]:
+-            self.msgfmt = shutil.which(msgfmt)
+-            if self.msgfmt:
+-                break
+-
+-    def run(self):
+-        super().run()
+-        if self.msgfmt:
+-            for po_file in self.po_files:
+-                self.announce(f"compiling {po_file}")
+-                lang_dir = str(
+-                    Path(self.build_lib)
+-                    / "reuse/locale"
+-                    / Path(po_file).stem
+-                    / "LC_MESSAGES"
+-                )
+-                destination = str(Path(lang_dir) / "reuse.mo")
+-                compile_func = lambda msgfmt, in_file, out: subprocess.run(
+-                    [msgfmt, in_file, "-o", out],
+-                    check=True,
+-                )
+-
+-                self.mkpath(lang_dir)
+-                self.make_file(
+-                    po_file,
+-                    destination,
+-                    compile_func,
+-                    (self.msgfmt, po_file, destination),
+-                )
+-                self.mo_outputs.append(destination)
+-
+-        else:
+-            warn("msgfmt is not installed. Translations will not be 
included.")
+-
+-    def get_outputs(self, include_bytecode=1):
+-        return (
+-            super().get_outputs(include_bytecode=include_bytecode)
+-            + self.mo_outputs
+-        )
+-
+-
+-def build():
+-    """Main function that runs the compilation."""
+-    distribution = Distribution(
+-        {
+-            "package_dir": {"": "src"},
+-        }
+-    )
+-    cmd = Build(distribution)
+-    cmd.inplace = 1
+-    cmd.ensure_finalized()
+-    cmd.run()
+-
+-    # Copy into src/. This appears to be the thing that actually does all the
+-    # heavy lifting. I'm not sure why I'm bothering with all the
+-    # setuptools-specific logic above.
+-    #
+-    # In summary: Get .mo files from build directory and put them into
+-    # src/reuse/locale/{lang}/LC_MESSAGES/reuse.mo.
+-    for output in cmd.get_outputs():
+-        relative = Path("src") / os.path.relpath(output, cmd.build_lib)
+-        relative.parent.mkdir(parents=True, exist_ok=True)
+-        shutil.copyfile(output, relative)
+-
+-
+-if __name__ == "__main__":
+-    build()
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -68,7 +68,6 @@ reuse = 'reuse._main:main'
+ 
+ [tool.poetry.build]
+ generate-setup-file = false
+-script = "build.py"
+ 
+ [build-system]
+ requires = ["poetry-core>=1.1.0", "setuptools"]

Reply via email to