From b7138b9b727925ad2e7cc742c253f0d83593dc0d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 27 Sep 2024 09:52:55 +0200 Subject: [PATCH] py/start --- py.pi.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 py.pi.sh diff --git a/py.pi.sh b/py.pi.sh new file mode 100755 index 0000000..b9e608b --- /dev/null +++ b/py.pi.sh @@ -0,0 +1,84 @@ +#! /usr/bin/env sh + +set \ +"pip" \ +"setuptools" \ +"uv" \ +"wheel" \ +\ +"pelican" \ +\ +"hatch" \ +\ +"Sphinx" \ +"sphinx-rtd-theme" \ +\ +"gitlint" \ +\ +"pydoclint" \ +"pylint" \ +"ruff" \ +\ +"pytest" \ +\ +"toml" \ +\ +"twine" \ +\ +"mypy" \ +"pyright" \ +\ +"ruamel.yaml" \ +"PyYAML" \ +"types-PyYAML" \ + +root="/sw/python/pypi" +tmp="${root}/tmp" + +rm --force --recursive \ +~/.cache/pip "${root}" + +python3 -m pip \ +download \ +--dest "${root}" \ +"${@}" + +prefix="Name: " +for wheel in "${root}/"*; do + echo + echo "${wheel}" + file="$(basename "${wheel}")" + case "${file}" in + *.tar.gz) + short="${file%.*}" + short="${short%.*}" + ;; + *.whl) + short="${file%.*}" + ;; + esac + file_name="$(echo "${short}" | cut -d "-" -f 1)" + file_version="$(echo "${short}" | cut -d "-" -f 2)" + case "${file}" in + *.tar.gz) + meta_data="${file_name}-${file_version}/${file_name}.egg-info/PKG-INFO" + tar xf "${wheel}" -C "${tmp}" "${meta_data}" + ;; + *.whl) + meta_data="${file_name}-${file_version}.dist-info/METADATA" + unzip "${wheel}" "${meta_data}" -d "${tmp}" + ;; + esac + name="$(grep "${prefix}" "${tmp}/${meta_data}" | sed "s|${prefix}||")" + echo "${name}" + name="$(echo "${name}" | tr "[:upper:]" "[:lower:]")" + name="$(echo "${name}" | tr "." "-")" + name="$(echo "${name}" | tr "_" "-")" + name="$(echo "${name}" | tr -d "\r")" + echo "${name}" + sub="${root}/simple/${name}" + mkdir --parents "${sub}" + mv -i "${root}/${file_name}-"* "${sub}/" +done + +rm --force --recursive "${tmp}"