srmp/py.pypi.sh

106 lines
2 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" \
\
2024-09-30 06:11:29 +00:00
"Cython" \
\
2024-09-28 19:18:02 +00:00
"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}")"
2024-09-28 20:32:04 +00:00
root="${root}/root/py/pypi"
2024-09-27 07:52:55 +00:00
tmp="${root}/tmp"
2024-09-29 18:13:55 +00:00
rm --force --recursive "${root}"
2024-09-27 07:52:55 +00:00
2024-09-29 20:25:40 +00:00
for version in "os" "3.12" "3.11" "3.10" "pypy3.10"; do
2024-09-29 15:52:47 +00:00
export VIRTUAL_ENV="/prj/venv/${version}"
export OLD_PATH="${PATH}"
export PATH="${VIRTUAL_ENV}/bin:${PATH}"
2024-09-30 06:26:06 +00:00
sub="${root}"
# sub="${root}/${version}"
2024-09-29 16:14:47 +00:00
2024-09-29 16:52:05 +00:00
python3 -m pip \
2024-09-29 16:08:39 +00:00
download \
2024-09-29 16:14:47 +00:00
--dest "${sub}" \
2024-09-29 16:08:39 +00:00
"${@}"
2024-09-27 07:52:55 +00:00
2024-09-30 06:26:06 +00:00
export PATH="${OLD_PATH}"
unset OLD_PATH VIRTUAL_ENV
done
2024-09-29 16:08:39 +00:00
prefix="Name: "
2024-09-29 16:14:47 +00:00
for wheel in "${sub}/"*; do
2024-09-29 16:08:39 +00:00
rm --force --recursive "${tmp}"
2024-09-29 18:13:55 +00:00
mkdir --parents "${tmp}"
2024-09-29 16:08:39 +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"
2024-09-29 21:14:09 +00:00
if ! tar xf "${wheel}" -C "${tmp}" "${meta_data}"; then
meta_data="${file_name}-${file_version}/PKG-INFO"
tar xf "${wheel}" -C "${tmp}" "${meta_data}" || exit
fi
2024-09-29 16:08:39 +00:00
;;
*.whl)
meta_data="${file_name}-${file_version}.dist-info/METADATA"
2024-09-29 21:14:09 +00:00
unzip "${wheel}" "${meta_data}" -d "${tmp}" || exit
2024-09-29 16:08:39 +00:00
;;
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}"
2024-09-29 16:14:47 +00:00
simple="${sub}/simple/${name}"
2024-09-29 16:11:16 +00:00
mkdir --parents "${simple}"
2024-09-30 06:26:06 +00:00
mv -i "${wheel}" "${simple}/"
2024-09-29 16:08:39 +00:00
done
2024-09-27 07:52:55 +00:00
rm --force --recursive "${tmp}"