Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Jinja name from PyPI URL (using f-string instead) #548

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jakirkham
Copy link
Member

Description

Instead of using Jinja to add name into the PyPI URL. Just use an f-string to template the URL. This removes name from the PyPI URL entirely and lets users more easily change this as needed.

Alternative to PR: #460

@jakirkham jakirkham requested a review from a team as a code owner August 13, 2024 01:56
@jakirkham
Copy link
Member Author

jakirkham commented Aug 13, 2024

It seems like it should be possible to drop this logic as well

if package_metadata["name"].lower() == config.name.lower():
if config.from_local_sdist:
# Initial name set in the recipe came from the sdist filename
set_global_jinja_var(recipe, "name", package_metadata["name"])
package_metadata.pop("name")
else:
package_metadata["name"] = package_metadata["name"].replace(
config.name, "<{ name|lower }}"
)

Though please let me know if I'm missing something

@@ -288,7 +288,7 @@ def get_pypi_metadata(config: Configuration) -> dict:
"url": info.get("home_page"),
"license": info.get("license"),
"source": {
"url": config.url_pypi + "/packages/source/{{ name[0] }}/{{ name }}/"
"url": config.url_pypi + f"/packages/source/{config.name[0]}/{config.name}/"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will always be normalized (even for historic builds), with the most-widely used implementation being packaging.utils.canonicalize_name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a good idea, grayskull still tries to canonicalize the names, but having that implementation to use out of the box might be better indeed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be stored as a key for reuse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants