PEP-751 Packages.sdist.name & Packages.wheels.name Purpose?
Introduction
When working with Python packages, it's essential to understand the purpose of packages.sdist.name
and packages.wheels.name
in the context of PEP-751. These fields are used to specify the name of the package, but their usage and purpose can be unclear. In this article, we'll delve into the details of these fields and explore their intended use cases.
What are packages.sdist.name and packages.wheels.name?
packages.sdist.name
and packages.wheels.name
are fields used to specify the name of a package in the context of PEP-751. These fields are used to provide a human-readable name for the package, which can be used in various situations, such as displaying the package name in a user interface or using it as a filename when downloading the package.
Required?
According to PEP-751, packages.sdist.name
and packages.wheels.name
are not required when the last component of the path
or url
would be the same value. This means that if the package name is the same as the last component of the path or URL, then these fields are not necessary.
When does the "would be" derive from?
The "would be" in the context of PEP-751 refers to the scenario where the last component of the path
or url
is the same as the package name. This can occur in various situations, such as:
- When the package name is the same as the filename of the package.
- When the package name is the same as the last component of the URL.
Example Scenario
Let's consider an example scenario where packages.sdist.name
and packages.wheels.name
are used:
sdist = {name = "foo-1.2.3.tar.gz", url = "https://my.index/foo-1.2.3.tar.gz/content" ...}
In this scenario, the package name is "foo-1.2.3.tar.gz", and the URL is "https://my.index/foo-1.2.3.tar.gz/content". The last component of the URL is "foo-1.2.3.tar.gz", which is the same as the package name. In this case, packages.sdist.name
and packages.wheels.name
are not required.
UV's Use Case
However, as mentioned in the original question, uv
's use case is different. In this case, the name
field is used to store the normalized wheel name when the index URL basename is a non-normalized version of the name. For example:
{ name = "pyyaml-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", url = "https://files.pythonhosted.org/packages/9b/95/a3fac87cb7158e231b5a6012e438c647e1a87f09f8e0d123acec8ab8bf71/PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl" ...}
In this scenario, the `` field is used to store the normalized wheel name, which is "pyyaml-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl". This is different from the original example scenario, where the package name is the same as the last component of the URL.
Conclusion
In conclusion, packages.sdist.name
and packages.wheels.name
are fields used to specify the name of a package in the context of PEP-751. These fields are not required when the last component of the path
or url
would be the same value. The "would be" in the context of PEP-751 refers to the scenario where the last component of the path
or url
is the same as the package name. However, uv
's use case is different, and the name
field is used to store the normalized wheel name when the index URL basename is a non-normalized version of the name.
Recommendations
Based on the analysis above, we recommend the following:
- When the last component of the
path
orurl
is the same as the package name, thenpackages.sdist.name
andpackages.wheels.name
are not required. - When the
name
field is used to store the normalized wheel name, then it should be used in conjunction with the index URL basename to determine the correct package name. - When in doubt, it's always best to ignore the
name
field and use the last component of thepath
orurl
as the package name.
Future Work
To clarify the purpose of packages.sdist.name
and packages.wheels.name
, we recommend updating PEP-751 to include more detailed information about their usage and purpose. Additionally, we recommend updating the documentation for uv
to reflect its use case for the name
field.
Conclusion
Q: What is the purpose of packages.sdist.name and packages.wheels.name in PEP-751?
A: The purpose of packages.sdist.name
and packages.wheels.name
is to specify the name of a package in the context of PEP-751. These fields are used to provide a human-readable name for the package, which can be used in various situations, such as displaying the package name in a user interface or using it as a filename when downloading the package.
Q: Are packages.sdist.name and packages.wheels.name required?
A: No, packages.sdist.name
and packages.wheels.name
are not required when the last component of the path
or url
would be the same value. This means that if the package name is the same as the last component of the path or URL, then these fields are not necessary.
Q: When does the "would be" derive from?
A: The "would be" in the context of PEP-751 refers to the scenario where the last component of the path
or url
is the same as the package name. This can occur in various situations, such as:
- When the package name is the same as the filename of the package.
- When the package name is the same as the last component of the URL.
Q: What is the difference between packages.sdist.name and packages.wheels.name?
A: packages.sdist.name
and packages.wheels.name
are used to specify the name of a package in the context of PEP-751. However, packages.wheels.name
is used specifically for wheel packages, while packages.sdist.name
is used for source distribution packages.
Q: How do I determine the correct package name to use in packages.sdist.name and packages.wheels.name?
A: To determine the correct package name to use in packages.sdist.name
and packages.wheels.name
, you should follow these steps:
- Check if the last component of the
path
orurl
is the same as the package name. If it is, thenpackages.sdist.name
andpackages.wheels.name
are not required. - If the last component of the
path
orurl
is not the same as the package name, then use the package name specified inpackages.sdist.name
andpackages.wheels.name
. - If you are using a wheel package, then use the normalized wheel name specified in
packages.wheels.name
.
Q: What is the recommended approach for handling packages.sdist.name and packages.wheels.name?
A: The recommended approach for handling packages.sdist.name
and packages.wheels.name
is to:
- Ignore
packages.sdist.name
andpackages.wheels.name
when the last component of thepath
orurl
is the same as the package name. - Use the package name specified in
packages.sdist.name
andpackages.wheels.name
when the last component of thepath
orurl
is not the same as the name. - Use the normalized wheel name specified in
packages.wheels.name
when working with wheel packages.
Q: How can I contribute to the clarification of packages.sdist.name and packages.wheels.name?
A: You can contribute to the clarification of packages.sdist.name
and packages.wheels.name
by:
- Reviewing the PEP-751 documentation and providing feedback on the usage and purpose of these fields.
- Updating the documentation for
uv
to reflect its use case for thename
field. - Submitting a pull request to update PEP-751 to include more detailed information about the usage and purpose of
packages.sdist.name
andpackages.wheels.name
.
Conclusion
In conclusion, packages.sdist.name
and packages.wheels.name
are fields used to specify the name of a package in the context of PEP-751. While they are not required in all scenarios, their usage and purpose can be unclear. By understanding their intended use cases and following the recommendations above, we can ensure that our package management systems are working correctly and efficiently.