summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO23
-rw-r--r--.gitignore17
-rw-r--r--PKGBUILD95
3 files changed, 87 insertions, 48 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 1bb8acc5f68b..612718674ff0 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,17 +1,22 @@
pkgbase = python-magic-git
- pkgdesc = Python 3 packages for alternative (github) implementation of python-magic
- pkgver = 0.4.6
- pkgrel = 5
- url = https://github.com/ahupp/python-magic
+ pkgdesc = File type identification library; compatible with official file/libmagic Python wrapper (git)
+ pkgver = 0.4.27.r22.g54d86fd
+ pkgrel = 3
+ url = https://pypi.org/project/python-magic
arch = any
license = MIT
+ checkdepends = python-pytest
makedepends = git
- makedepends = sed
- makedepends = python
+ makedepends = python-build
+ makedepends = python-installer
+ makedepends = python-setuptools
+ makedepends = python-wheel
+ depends = file
depends = python
+ provides = python-magic=1:0.4.27
conflicts = python-magic
- source = python-magic-git::git+https://github.com/ahupp/python-magic
- md5sums = SKIP
+ conflicts = python-file-magic
+ source = python-magic::git+https://github.com/ahupp/python-magic.git
+ b2sums = SKIP
pkgname = python-magic-git
-
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..e1cc0116832e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+# based on https://github.com/github/gitignore/blob/master/ArchLinuxPackages.gitignore
+*.tar
+*.tar.*
+*.rpm
+*.jar
+*.exe
+*.msi
+*.zip
+*.tgz
+*.log
+*.log.*
+
+*/
+*.orig
+*.bak
+*.backup
+*.kate-swp
diff --git a/PKGBUILD b/PKGBUILD
index a4d5562491ba..c13ca99eb55d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,49 +1,66 @@
-# Maintainer: Richard Neumann aka. rne <r dot neumann at homeinfo fullstop de>
+# Contributor: Marcell Meszaros < marcell.meszaros AT runbox.eu >
+# Contributor: David Runge <dvzrv@archlinux.org>
+# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
+# Contributor: Richard Neumann aka. rne <r dot neumann at homeinfo fullstop de>
-pkgname='python-magic-git'
-pkgver='0.4.6'
-pkgrel=5
-pkgdesc="Python 3 packages for alternative (github) implementation of python-magic"
+_pkgbase=python-magic
+pkgname="${_pkgbase}-git"
+pkgver=0.4.27.r22.g54d86fd
+pkgrel=3
+_stablepkg_epoch=1
+pkgdesc="File type identification library; compatible with official file/libmagic Python wrapper (git)"
arch=('any')
-url='https://github.com/ahupp/python-magic'
+url='https://pypi.org/project/python-magic'
+_repourl='https://github.com/ahupp/python-magic'
license=('MIT')
-depends=('python')
-makedepends=('git' 'sed' 'python')
-conflicts=('python-magic')
-source=("${pkgname}::git+https://github.com/ahupp/python-magic")
-md5sums=('SKIP')
-pkgdir='pkg'
-srcdir='src'
+depends=(
+ 'file'
+ 'python'
+)
+makedepends=(
+ 'git'
+ 'python-build'
+ 'python-installer'
+ 'python-setuptools'
+ 'python-wheel'
+)
+checkdepends=('python-pytest')
+provides=("${_pkgbase}=${_stablepkg_epoch}:${pkgver%.r*}")
+conflicts=(
+ "${_pkgbase}"
+ 'python-file-magic' # official libmagic bindings - https://pypi.org/project/file-magic
+)
+source=("${_pkgbase}::git+${_repourl}.git")
+b2sums=('SKIP')
+pkgver() {
+ cd "${_pkgbase}"
-package() {
- local PYTHON="/usr/bin/env python3"
- local USR_PATH="${pkgdir}/usr"
- local LICENSE_DIR="${USR_PATH}/share/licenses/${pkgname}"
-
- # Set up directories
- install -d -m 755 ${USR_PATH}
- install -d -m 755 ${LICENSE_DIR}
-
- # Clean up build dir
- rm -Rf build
-
- cd "${srcdir}/${pkgname}"
-
- # Fix setup.py for distutils.core
- sed -i 's/\(from setuptools.*\)/#\1/' setup.py
- sed -i 's/#\(from distutils.*\)/\1/' setup.py
+ # Generate git tag based version. Count only proper (v)#.#* [#=number] tags.
+ local _gitversion=$(git describe --long --tags --match '[v0-9][0-9.][0-9.]*' | sed -e 's|^v||' | tr '[:upper:]' '[:lower:]')
- # Install python packages to $pkgdir
- ${PYTHON} setup.py install --prefix ${USR_PATH}
-
- # Install license file
- install -m 644 LICENSE ${LICENSE_DIR}
+ # Format git-based version for pkgver
+ # Expected format: e.g. 1.5.0rc2.r521.g99982a1c
+ # Or in case of 'post': 1.5.0.post1.r521.g99982a1c
+ echo "${_gitversion}" | sed \
+ -e 's;^\([0-9][0-9.]*\)[-_.]\([a-zA-Z]\+\);\1\2;' \
+ -e 's;\([0-9]\+-g\);r\1;' \
+ -e 's;-;.;g' \
+ -e 's;\(post.*\);\.\1;'
+}
- # Make directories accessible for anyone
- find "${USR_PATH}" -type d -exec chmod 755 {} \;
+build() {
+ cd "${_pkgbase}"
+ python -m build --wheel --no-isolation
+}
- # Make library files readable for anyone but not executable
- find "${USR_PATH}" -type f -exec chmod 644 {} \;
+check() {
+ cd "${_pkgbase}"
+ LC_ALL=en_US.UTF-8 pytest -vv "${pytest_options[@]}"
}
+package() {
+ cd "${_pkgbase}"
+ python -m installer --destdir="$pkgdir" dist/*.whl
+ install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
+}