You are not logged in.

#1 2020-09-22 13:36:13

ryan_greenblatt
Member
Registered: 2020-09-22
Posts: 5

PKGBUILD review request: python-sympy-git

I made a package for installing sympy (https://github.com/sympy/sympy) from source (latest git). The python-sympy package installs the latest release. I thought this might be useful to someone else. This is my first PKGBUILD, so please tell me everything I am doing wrong.

# Maintainer: Ryan Greenblatt <ryan_greenblatt at brown dot edu>

pkgname=python-sympy-git
_pkgname=python-sympy-git
pkgver=sympy.1.6.r1717.ga24d96d03e
pkgrel=1
pkgdesc="Computer algebra system (CAS) in Python, written in pure Python - git version"
arch=('any')
license=(BSD)
url='https://sympy.org/en/index.html'
license=('BSD')
depends=('python-mpmath')
conflicts=('python-sympy')
provides=('python-sympy')
optdepends=('ipython: user friendly interface for isympy')
makedepends=('python-setuptools' 'git')
source=("$pkgname::git+https://github.com/sympy/sympy.git"
  "LICENSE::https://raw.githubusercontent.com/sympy/sympy/master/LICENSE")
sha256sums=('SKIP' 'SKIP')

if [ -n "$VIRTUAL_ENV" ]; then
  echo "Warning: You're building within a virtualenv. Use"
  echo "a shell without virtualenv to build this package!"
  exit 1
fi

pkgver() {
  cd "$pkgname"
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd "$_pkgname"
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:

Offline

#2 2020-09-22 14:45:30

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,932
Website

Re: PKGBUILD review request: python-sympy-git

Since _pkgname has the same value as pkgname, the former is redundant and may be deleted.

Offline

#3 2020-09-22 14:57:28

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,466

Re: PKGBUILD review request: python-sympy-git

The license array is duplicated
The license appears to already be in the repo, why download it separately?
'sympy.' should be stripped from the pkgver in the pkgver function
Why are you renaming the dir when downloading the repo?

Offline

#4 2020-09-23 03:22:57

ryan_greenblatt
Member
Registered: 2020-09-22
Posts: 5

Re: PKGBUILD review request: python-sympy-git

Thanks for the feedback.

I think that the dir needs to renamed to avoid potential name conflicts in the SRCDEST.
See https://wiki.archlinux.org/index.php/PKGBUILD#Sources.
I think "python-sympy-git" would be less likely to have conflicts than "sympy".
Maybe it should even include the version in the dir name.
Perhaps I misunderstand when name conflicts can occur.

Also, I changed to pkgver regex to filter out "sympy-". I considered instead using "\w\+-" but I decided being specific was better.

I have updated the PKGBUILD to this:

# Maintainer: Ryan Greenblatt <ryan_greenblatt at brown dot edu>

pkgname=python-sympy-git
pkgver=1.6.r1717.ga24d96d03e
pkgrel=1
pkgdesc="Computer algebra system (CAS) in Python, written in pure Python - git version"
arch=('any')
url='https://sympy.org/en/index.html'
license=('BSD')
depends=('python-mpmath')
conflicts=('python-sympy')
provides=('python-sympy')
optdepends=('ipython: user friendly interface for isympy')
makedepends=('python-setuptools' 'git')
source=("$pkgname::git+https://github.com/sympy/sympy.git")
sha256sums=('SKIP')

if [ -n "$VIRTUAL_ENV" ]; then
  echo "Warning: You're building within a virtualenv. Use"
  echo "a shell without virtualenv to build this package!"
  exit 1
fi

pkgver() {
  cd "$pkgname"
  git describe --long --tags | sed 's/sympy-\(.*\)/\1/g;s/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd "$pkgname"
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:

Offline

#5 2020-09-23 03:35:45

ryan_greenblatt
Member
Registered: 2020-09-22
Posts: 5

Re: PKGBUILD review request: python-sympy-git

Offline

#6 2020-09-23 04:11:19

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: PKGBUILD review request: python-sympy-git

ryan_greenblatt wrote:

Thanks for the feedback.

I think that the dir needs to renamed to avoid potential name conflicts in the SRCDEST.
See https://wiki.archlinux.org/index.php/PKGBUILD#Sources.
I think "python-sympy-git" would be less likely to have conflicts than "sympy".
Maybe it should even include the version in the dir name.
Perhaps I misunderstand when name conflicts can occur.

Name conflicts occur when generic names are used, which are very likely to clash. For example, the filename "v1.0.tar.gz"

I think it's very unlikely that someone else is downloading a PKGBUILD source git repo named "sympy" which is something other than the well-known SymPy software. Note the "py" is for "python" already. And the "-git" at the end is literally meaningless as by the same logic, every git repo source would include "-git", so this imaginary sympy alternative software would also include a "-git" and thus clash once more.

You're utterly forbidden from including the $pkgver in the dir name, since the pkgver() function would then update the expected dir name after prepare() and pkgver(), but before build(), and then it would not be able to find the old dir name.

Versions in source names are only for stable files e.g. tarballs and are used in PKGBUILDs that do *not* include a pkgver() function.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2020-09-23 13:07:36

ryan_greenblatt
Member
Registered: 2020-09-22
Posts: 5

Re: PKGBUILD review request: python-sympy-git

eschwartz wrote:

I think it's very unlikely that someone else is downloading a PKGBUILD source git repo named "sympy" which is something other than the well-known SymPy software. Note the "py" is for "python" already. And the "-git" at the end is literally meaningless as by the same logic, every git repo source would include "-git", so this imaginary sympy alternative software would also include a "-git" and thus clash once more.

You're utterly forbidden from including the $pkgver in the dir name, since the pkgver() function would then update the expected dir name after prepare() and pkgver(), but before build(), and then it would not be able to find the old dir name.

Versions in source names are only for stable files e.g. tarballs and are used in PKGBUILDs that do *not* include a pkgver() function.

Ok, makes sense. I have switched the repo directory name to sympy.

Offline

Board footer

Powered by FluxBB