diff options
author | Bao Trinh | 2023-06-27 07:53:18 -0500 |
---|---|---|
committer | Bao Trinh | 2023-06-27 07:56:13 -0500 |
commit | 3c5f157f783847d9651898532f03cd2d3167a6e0 (patch) | |
tree | 2071427f1492c550d1712fce811d06a22eea665c | |
parent | 455d628d562872ebddb70875d64a6f45bf337fe4 (diff) | |
download | aur-3c5f157f783847d9651898532f03cd2d3167a6e0.tar.gz |
Fix for python-xdg-base-dirs
the AUR package python-xdg actually installs the pypi package `xdg-base-dirs`
rather than the `xdg` package. There is no package on the AUR currently
that handles that requirement. So a patch is required to adapt
xdg-base-dirs for use with autoimport
-rw-r--r-- | .SRCINFO | 23 | ||||
-rw-r--r-- | PKGBUILD | 52 | ||||
-rw-r--r-- | xdg-base-dirs.patch | 57 |
3 files changed, 113 insertions, 19 deletions
@@ -1,17 +1,28 @@ pkgbase = python-autoimport pkgdesc = Autoimport automatically fixes wrong import statements - pkgver = 0.7.3 + pkgver = 1.3.3 pkgrel = 1 - url = https://github.com/lyz-code/autoimport/ + url = https://github.com/lyz-code/autoimport arch = any - license = GPL - makedepends = python-setuptools + license = GPL3 + checkdepends = python-pytest + checkdepends = python-pytest-xdist + checkdepends = python-pytest-freezegun + makedepends = python-build + makedepends = python-installer + makedepends = python-pdm-pep517 + makedepends = python-wheel depends = python depends = python-autoflake depends = python-click + depends = python-maison + depends = python-pyflakes depends = python-pyprojroot depends = python-sh - source = python-autoimport-0.7.3.tar.gz::https://github.com/lyz-code/autoimport/archive/refs/tags/0.7.3.tar.gz - sha512sums = c2917dc07065f0842a691eeec1cfdb83e09ddbf618f5c51c294404eb64a55f06a694d1c279140ccaf09c59dbbbcef6dc5648879aa7f7bce327e197d2c0bf787c + depends = python-xdg-base-dirs + source = python-autoimport-1.3.3.tar.gz::https://github.com/lyz-code/autoimport/archive/refs/tags/1.3.3.tar.gz + source = xdg-base-dirs.patch + sha512sums = 6a80396ab16ef33db92eff97114a4f4897da111442bf54198a37cc8e60ab0570d2fbae924432a443f177f8d48883ed98adde8bcc9db6518d41f6f335b806a6cb + sha512sums = 2aa603866fef80cbe2fbeb2e8896db688dd4f29517fb4a0a696777abff7eb9c8c162815d5adf3b800f101282d2848030c3147ee0461ce3e14a0db319bbfee43c pkgname = python-autoimport @@ -1,29 +1,55 @@ # Maintainer: Bao Trinh <qubidt at gmail dot com> pkgname=python-autoimport -pkgver=0.7.3 +_pkgname="${pkgname#python-}" +pkgver=1.3.3 pkgrel=1 pkgdesc='Autoimport automatically fixes wrong import statements' arch=('any') -url=https://github.com/lyz-code/autoimport/ -license=('GPL') +url=https://github.com/lyz-code/autoimport +license=('GPL3') depends=('python' 'python-autoflake' 'python-click' + 'python-maison' + 'python-pyflakes' 'python-pyprojroot' - 'python-sh') -makedepends=('python-setuptools') -source=("$pkgname-$pkgver.tar.gz::https://github.com/lyz-code/autoimport/archive/refs/tags/${pkgver}.tar.gz") -sha512sums=('c2917dc07065f0842a691eeec1cfdb83e09ddbf618f5c51c294404eb64a55f06a694d1c279140ccaf09c59dbbbcef6dc5648879aa7f7bce327e197d2c0bf787c') + 'python-sh' + 'python-xdg-base-dirs') +checkdepends=( + "python-pytest" + "python-pytest-xdist" + "python-pytest-freezegun") +makedepends=('python-build' 'python-installer' 'python-pdm-pep517' 'python-wheel') +source=("${pkgname}-${pkgver}.tar.gz::https://github.com/lyz-code/autoimport/archive/refs/tags/${pkgver}.tar.gz" + "xdg-base-dirs.patch") +sha512sums=('6a80396ab16ef33db92eff97114a4f4897da111442bf54198a37cc8e60ab0570d2fbae924432a443f177f8d48883ed98adde8bcc9db6518d41f6f335b806a6cb' + '2aa603866fef80cbe2fbeb2e8896db688dd4f29517fb4a0a696777abff7eb9c8c162815d5adf3b800f101282d2848030c3147ee0461ce3e14a0db319bbfee43c') + +prepare() { + cd "${_pkgname}-${pkgver}" + patch -Np1 -i "${srcdir}/xdg-base-dirs.patch" +} build() { - cd "autoimport-$pkgver" - python setup.py build + cd "${_pkgname}-${pkgver}" + python -m build --wheel --no-isolation +} + +check() { + python3 -m venv --system-site-packages "${srcdir}/testing-venv" + + cd "${_pkgname}-${pkgver}" + "${srcdir}/testing-venv/bin/python" -m pip install --no-deps . + + # TODO: these 2 tests seem to fail when the proj directory name does not equal the package name + "${srcdir}/testing-venv/bin/python" -m pytest \ + -k 'not (test_fix_autoimports_objects_defined_in_the_root_of_the_package or test_fix_autoimports_objects_defined_in___all__special_variable)' } package() { - cd "autoimport-$pkgver" - python setup.py install --optimize=1 --root="$pkgdir" --skip-build - install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}" - install -vDm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}" + cd "${_pkgname}-${pkgver}" + python -m installer --destdir="${pkgdir}" dist/*.whl + install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + install -Dm644 -t "${pkgdir}/usr/share/doc/${pkgname}" "README.md" "CHANGELOG.md" } diff --git a/xdg-base-dirs.patch b/xdg-base-dirs.patch new file mode 100644 index 000000000000..51a92ee47778 --- /dev/null +++ b/xdg-base-dirs.patch @@ -0,0 +1,57 @@ +diff --git a/pyproject.toml b/pyproject.toml +index 7bb1dfd..b1bf31b 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -24,14 +24,14 @@ authors = [ + {name = "Lyz", email = "lyz@riseup.net"}, + ] + license = {text = "GPL-3.0-only"} +-requires-python = ">=3.7" ++requires-python = ">=3.10" + dependencies = [ + "click>=8.1.3", + "autoflake>=1.4", + "pyprojroot>=0.2.0", + "sh>=1.14.2", + "maison>=1.4.0", +- "xdg>=5.1.1", ++ "xdg-base-dirs>=6.0.0", + ] + name = "autoimport" + description = "Autoimport missing python libraries." +@@ -379,6 +379,6 @@ module = [ + "pyprojroot", + "sh", + "virtualenv", +- "xdg", ++ "xdg_base_dirs", + ] + ignore_missing_imports = true +diff --git a/src/autoimport/entrypoints/cli.py b/src/autoimport/entrypoints/cli.py +index 17663fa..061df27 100644 +--- a/src/autoimport/entrypoints/cli.py ++++ b/src/autoimport/entrypoints/cli.py +@@ -6,7 +6,7 @@ from pathlib import Path + from typing import Any, List, Optional, Sequence, Tuple, Union + + import click +-import xdg ++import xdg_base_dirs as xdg + from maison.config import ProjectConfig + + from autoimport import services, version +diff --git a/src/autoimport/model.py b/src/autoimport/model.py +index 2e79264..573a983 100644 +--- a/src/autoimport/model.py ++++ b/src/autoimport/model.py +@@ -358,8 +358,8 @@ class SourceCode: # noqa: R090 + # Find the package name + try: + project_package = os.path.basename(here()).replace("-", "_") +- except RecursionError: # pragma: no cover +- # I don't know how to make a test that raises this error :( ++ except RuntimeError: # pragma: no cover ++ # I don't know how to make a test that raises it :( + # To manually reproduce, follow the steps of + # https://github.com/lyz-code/autoimport/issues/131 + return None |