# Description: A tool for installing and managing Python packages.
# URL: https://pypi.python.org/pypi/pip/
# Maintainer: CRUX System Team, core-ports at crux dot nu
# Depends on: python3-tomli

name=python3-pip
version=26.1.2
release=1
source=(https://files.pythonhosted.org/packages/source/${name:8:1}/${name#*-}/${name#*-}-$version.tar.gz
  EXTERNALLY-MANAGED.in)

build() {
  cd ${name#*-}-$version

  /usr/bin/python3 -m build --wheel --skip-dependency-check --no-isolation
  /usr/bin/python3 -m installer --destdir=$PKG dist/*.whl
  rm $PKG/usr/bin/pip

  # again why does this happen?
  find $PKG/usr/lib/python*/site-packages -type f -exec chmod o-w '{}' \+

  _pyver=$(/usr/bin/python3 -c 'import sys; print("%s.%s" % sys.version_info[:2])')
  # again why does this happen?
  find $PKG/usr/lib/python${_pyver}/site-packages -type f \
    -exec chmod o-w '{}' \+

  install -m 644 $SRC/EXTERNALLY-MANAGED.in $PKG/usr/lib/python${_pyver}/EXTERNALLY-MANAGED
}
