pkgname=python-pip
_name=${pkgname#python-}
pkgver=25.3
pkgdesc="The PyPA recommended tool for installing Python packages"
homepage="https://pip.pypa.io/"
license=('MIT')
sources=("${_name}-${pkgver}.tar.gz")
urls=("https://pypi.org/packages/source/p/${_name}/${sources[0]}")
md5sums=("31f52f428372020b80cd7518862fbbee")

src_prepare() {
  tar -xf "${distdir}/${sources[0]}" --strip-components=1
}

src_build() {
  export PYTHONPYCACHEPREFIX="$PWD/.pycache"
  export TMPDIR="$PWD/.tmp"
  export PIP_CACHE_DIR="$PWD/.pipcache"
  export PIP_DISABLE_PIP_VERSION_CHECK=1

  mkdir -p "$PYTHONPYCACHEPREFIX" "$TMPDIR" "$PIP_CACHE_DIR"

  export PYTHONDONTWRITEBYTECODE=1
  pip3 wheel \
    -w dist \
    --no-cache-dir \
    --no-build-isolation \
    --no-deps \
    "$PWD"
}

src_install() {
  export PYTHONPYCACHEPREFIX="$PWD/.pycache"
  export PIP_DISABLE_PIP_VERSION_CHECK=1

  pip3 install \
    --no-deps \
    --no-warn-script-location \
    --no-index \
    --no-cache-dir \
    --no-user \
    --ignore-installed \
    --root "${pkgdir}" \
    --find-links dist \
    --root-user-action=ignore \
    pip
}

