Skip to content

Support both ninja python package and ninja_syntax + system ninja#2

Closed
lllangWV wants to merge 0 commit intoFindDefinition:masterfrom
lllangWV:master
Closed

Support both ninja python package and ninja_syntax + system ninja#2
lllangWV wants to merge 0 commit intoFindDefinition:masterfrom
lllangWV:master

Conversation

@lllangWV
Copy link
Copy Markdown

Summary

Add fallback import for ninja_syntax to support both the ninja Python package and system-installed ninja, enabling conda-forge compatibility.

Motivation

I'm working to add spconv to conda-forge, which requires the following dependency chain:

  • spconvcummpccmccimportninja (python-ninja)

The ninja-python package on PyPI vendors its own compiled version of ninja, which violates conda-forge's policy against vendoring. This prevents ccimport from being added to conda-forge in its current form.

Changes

Modified the import statement to try importing from the ninja Python package first, then fall back to system ninja's ninja_syntax module:

try:
    from ninja.ninja_syntax import Writer
except ImportError:
    from ninja_syntax import Writer  # from system ninja

This allows ccimport to work with:

  • The ninja Python package (ninja-python-distributions) on PyPI
  • System-installed ninja (including conda-forge's ninja package)

Benefits

  • Enables ccimport to be packaged for conda-forge
  • Maintains backward compatibility with existing PyPI installations
  • Follows the recommended pattern for ninja detection (similar to scikit-build-core's approach)
  • Unblocks the conda-forge packaging of pccm, cumm, and ultimately spconv

Related Issues

This addresses the conda-forge policy requirement that packages should use system dependencies when available rather than vendored versions.

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.

1 participant