Skip to content

Gazelle: Sanitize distribution names in modules mapping / manifest, not at runtime #1939

@wingsofovnia

Description

@wingsofovnia

🚀 feature request

Relevant Rules

  • modules_mapping
  • gazelle_python_manifest
  • gazelle

Description

Gazelle plugin uses gazelle_python.yaml (gazelle:python_manifest_file_name) to derive deps for py targets. One might expect that a dependency label will be ${manifest.pip_repository}//${manifest.modules_mapping.some.import}, however, Gazelle does extra sanitisation right before using the mapping value here.

Although it is not a big deal when used with rules_python, it makes harder to reuse Gazelle plugin with other python rules, more specifically rules_pycross, which has a different target naming convention, which is aligned with Python normalised names. In this ticket, there is an approach (or hack really) described for patching gazelle_python.yaml but further sanitisation that happens inside the plugin itself makes it impossible to use.

I do understand that compatibility with other rules most likely isn't of highest priority, here are some other reasons:

  • It would be slightly less confusing when target name derivation (normalisation / alignment) happens in once place, rather than in modules_mapping and/or gazelle_python_manifest and/or plugin itself.
  • Given that there are ongoing efforts to Pull rules_pycross into rules_python #1360, it might be a good improvement going forward.

Describe the solution you'd like

  • Do not SanitizeDistribution in pythonconfig.Config#FindThirdPartyDependency, take the value as is.
  • Do SanitizeDistribution in modules_mapping, or gazelle_python_manifest. I'd say modules_mapping is best but please advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gazelleGazelle plugin related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions