Merge pull request #3106 from lazka/python-wheel

Add python-wheel
This commit is contained in:
Christoph Reiter 2022-07-26 18:29:06 +02:00 committed by GitHub
commit 8b9cbe481d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 0 deletions

34
python-wheel/PKGBUILD Normal file
View File

@ -0,0 +1,34 @@
# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>
_bootstrapping=yes
_realname=wheel
pkgname="python-${_realname}"
pkgver=0.37.1
pkgrel=1
pkgdesc="A built-package format for Python"
arch=('any')
url="https://pypi.python.org/pypi/wheel"
license=('spdx:MIT')
depends=("python")
if [[ "${_bootstrapping}" == "no" ]]; then
makedepends=("python-installer")
fi
source=("https://pypi.debian.net/wheel/wheel-${pkgver}-py2.py3-none-any.whl"
"install_wheel.py")
sha256sums=('4bdcd7d840138086126cd09254dc6195fb4fc6f01c050a1d7236f2630db1d22a'
'668e64f912d6360330c403edb6100b21f6aa6dd6a7803d342fab8c35d8176ad9')
package() {
if [[ "${_bootstrapping}" == "no" ]]; then
python -m installer --destdir="${pkgdir}" *.whl
else
_pythonpath=`python -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
_site_packages="${pkgdir}${_pythonpath}"
mkdir -p "$_site_packages"
python "${srcdir}/install_wheel.py" -i"${_site_packages}" *.whl
python -m compileall -o 0 -o 1 -q "${pkgdir}/usr/lib/python"*
fi
install -Dm644 *.dist-info/LICENSE.txt "${pkgdir}/usr/share/licenses/python-${_realname}/COPYING"
}

View File

@ -0,0 +1,33 @@
import argparse
import sys
import sysconfig
from pathlib import Path
from zipfile import ZipFile
def extract_wheel(whl_path, dest):
print("Installing to", dest)
with ZipFile(whl_path) as zf:
zf.extractall(dest)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
'wheel',
type=Path,
help=f'wheel to install (.whl file)',
)
purelib = Path(sysconfig.get_path('purelib')).resolve()
parser.add_argument(
'--installdir',
'-i',
type=Path,
default=purelib,
help=f'installdir directory (defaults to {purelib})',
)
args = parser.parse_args()
if not args.installdir.is_dir():
sys.exit(f"{args.installdir} is not a directory")
extract_wheel(args.wheel, args.installdir)