srmp/py.pi.sh

88 lines
1.5 KiB
Bash
Raw Normal View History

2024-09-27 07:52:55 +00:00
#! /usr/bin/env sh
set \
2024-09-28 19:18:02 +00:00
"pip" \
"setuptools" \
"wheel" \
\
"uv" \
\
"pelican" \
\
"hatch" \
\
"Sphinx" \
"sphinx-rtd-theme" \
\
"gitlint" \
\
"pydoclint" \
"pylint" \
"ruff" \
\
"pytest" \
\
"toml" \
\
"twine" \
\
"mypy" \
"pyright" \
\
"ruamel.yaml" \
"PyYAML" \
"types-PyYAML"
2024-09-27 07:52:55 +00:00
2024-09-28 18:10:06 +00:00
file="$(readlink --canonicalize-existing "${0}")"
root="$(dirname "${file}")"
root="${root}/root/py/pi"
2024-09-27 07:52:55 +00:00
tmp="${root}/tmp"
rm --force --recursive \
2024-09-28 19:18:02 +00:00
~/.cache/pip "${root}"
2024-09-27 07:52:55 +00:00
python3 -m pip \
2024-09-28 19:18:02 +00:00
download \
--dest "${root}" \
"${@}"
2024-09-27 07:52:55 +00:00
prefix="Name: "
for wheel in "${root}/"*; do
2024-09-28 19:15:42 +00:00
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}/"
2024-09-27 07:52:55 +00:00
done
rm --force --recursive "${tmp}"