Merge pull request #248516 from thiagokokada/remove-version-from-python-relax-deps-hook

pythonRelaxDepsHook: remove version from pkg_name
This commit is contained in:
Thiago Kenji Okada
2023-08-12 00:57:55 +00:00
committed by GitHub
@@ -78,24 +78,25 @@ pythonRelaxDepsHook() {
pushd dist
# See https://peps.python.org/pep-0491/#escaping-and-unicode
local -r pkg_name="${pname//[^[:alnum:].]/_}-$version"
local -r pkg_name="${pname//[^[:alnum:].]/_}"
local -r unpack_dir="unpacked"
local -r metadata_file="$unpack_dir/$pkg_name/$pkg_name.dist-info/METADATA"
local -r metadata_file="$unpack_dir/$pkg_name*/$pkg_name*.dist-info/METADATA"
# We generally shouldn't have multiple wheel files, but let's be safer here
for wheel in "$pkg_name"*".whl"; do
@pythonInterpreter@ -m wheel unpack --dest "$unpack_dir" "$wheel"
rm -rf "$wheel"
_pythonRelaxDeps "$metadata_file"
_pythonRemoveDeps "$metadata_file"
# Using no quotes on purpose since we need to expand the glob from `$metadata_file`
_pythonRelaxDeps $metadata_file
_pythonRemoveDeps $metadata_file
if (( "${NIX_DEBUG:-0}" >= 1 )); then
echo "pythonRelaxDepsHook: resulting METADATA for '$wheel':"
cat "$unpack_dir/$pkg_name/$pkg_name.dist-info/METADATA"
cat $metadata_file
fi
@pythonInterpreter@ -m wheel pack "$unpack_dir/$pkg_name"
@pythonInterpreter@ -m wheel pack "$unpack_dir/$pkg_name"*
done
# Remove the folder since it will otherwise be in the dist output.