pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.78k stars 1.86k forks source link

Normalize package names in Pipfile #4699

Open fridex opened 3 years ago

fridex commented 3 years ago

Issue description

From a consistency point of view, it would be great if Pipenv normalizes package names stored in Pipfile - especially when computing hash on Pipfile.

When running Pipenv with the following Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
Sphinx = "*"

Pipenv produces a Pipfile.lock which holds the following hash of Pipfile: c99365b83495db0f676ba97f11db58b35955f8f5e7da5b56495dbf7044d303bf

When the package name is normalized:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
sphinx = "*"

Pipenv produces Pipfile.lock with Pipfile hash d993d725f2bfe31e06c4a1f3716caf2d4b1a9a5d8cb8d24a140b58eabe90a3e3.

As semantically, Pipfile hasn't changed, it would be great if Pipenv would be consistent in these cases.

Expected result

Pipfile hash is unified. Ideally, Pipfile should hold normalized names.

Steps to replicate

cat << EOF > Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
Sphinx = "*"
EOF
pipenv install
cat Pipfile.lock | jq "._meta.hash"
# {
#   "sha256": "c99365b83495db0f676ba97f11db58b35955f8f5e7da5b56495dbf7044d303bf"
# }
cat << EOF > Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
sphinx = "*"
EOF
rm Pipfile.lock
pipenv install
cat Pipfile.lock | jq "._meta.hash"
# {
#   "sha256": "d993d725f2bfe31e06c4a1f3716caf2d4b1a9a5d8cb8d24a140b58eabe90a3e3"
# }
pipenv --version
# pipenv, version 2020.11.15
matteius commented 2 years ago

Nice issue report @fridex, I was able to reproduce it on the latest version 2021.11.23 as well:

mdavis@matt-VirtualBox:~/shared-projects/pipenv-4699$ diff Pipfile.lock Pipfile.lock.original 
4c4
<             "sha256": "d993d725f2bfe31e06c4a1f3716caf2d4b1a9a5d8cb8d24a140b58eabe90a3e3"
---
>             "sha256": "c99365b83495db0f676ba97f11db58b35955f8f5e7da5b56495dbf7044d303bf"