Skip to content

Commit

Permalink
Fix package name based on local sdist archive
Browse files Browse the repository at this point in the history
When using a local sdist as source, the package name of the conda recipe
was based on the sdist filename.
This used to be the same but since setuptools 69.3.0, the sdist filename is now normalized.
For example, if a package name contains a dash, it's converted to underscore.

The package name should be extracted from the metadata and not the sdist filename.
  • Loading branch information
beenje committed Apr 15, 2024
1 parent 0da218f commit 40ac6b9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion grayskull/strategy/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,14 @@ def get_metadata(recipe, config) -> dict:
"""Method responsible to get the whole metadata available. It will
merge metadata from multiple sources (pypi, setup.py, setup.cfg)
"""
name = config.name
sdist_metadata, pypi_metadata = get_origin_wise_metadata(config)
metadata = merge_pypi_sdist_metadata(pypi_metadata, sdist_metadata, config)
if config.from_local_sdist:
# Overwrite package name from sdist filename with name from metadata
# sdist filename is normalized by setuptools since version 69.3.0
# See https://github.com/pypa/setuptools/issues/3593
config.name = metadata["name"]
name = config.name
log.debug(f"Data merged from pypi, setup.cfg and setup.py: {metadata}")
if metadata.get("scripts") is not None:
config.is_arch = True
Expand Down Expand Up @@ -505,6 +510,9 @@ def update_recipe(recipe: Recipe, config: Configuration, all_sections: List[str]
if section == "package":
package_metadata = dict(metadata[section])
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(
Expand Down

0 comments on commit 40ac6b9

Please sign in to comment.