Skip to content

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

Closed
jakirkham wants to merge 2 commits intoconda:mainfrom
jakirkham:drop_url_name_jinja
Closed

Drop Jinja name from PyPI URL (using f-string instead)#548
jakirkham wants to merge 2 commits intoconda:mainfrom
jakirkham:drop_url_name_jinja

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 jakirkham force-pushed the drop_url_name_jinja branch from 67c4007 to d037674 Compare August 13, 2024 02:01
@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

"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?

@mgorny
Copy link
Contributor

mgorny commented Jan 13, 2026

xref conda-forge/conda-forge.github.io#2712

Looks like the conclusion there is to remove the name from Jinja variables entirely. I suppose doing the same here also would make sense, given that FWIU it would now only be used once (for recipe name).

@mgorny
Copy link
Contributor

mgorny commented Jan 13, 2026

Oh, i See #598 is doing the same thing.

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.

4 participants