Skip to content

Add pip packaging (scikit-build-core) and an ASE neighbour-list plugin - #2

Merged
pastewka merged 1 commit into
mainfrom
add-ase-plugin-and-pip-packaging
Jun 21, 2026
Merged

Add pip packaging (scikit-build-core) and an ASE neighbour-list plugin#2
pastewka merged 1 commit into
mainfrom
add-ase-plugin-and-pip-packaging

Conversation

@jameskermode

Copy link
Copy Markdown
Member

Summary

Makes matscipy-neighbours pip-installable and registers its neighbour list as an ASE neighbour-list backend, so:

pip install .          # builds the C extension into a wheel
from ase.neighborlist import get_neighbor_list, available_neighbor_list_backends
available_neighbor_list_backends()        # {'ase': True, 'matscipy-neighbours': True, ...}
nl = get_neighbor_list("matscipy-neighbours")
i, j, d, D, S = nl("ijdDS", atoms, 5.0)

Selection is explicit and never automatic — this only makes the backend available under the name matscipy-neighbours.

What's here

  • pyproject.toml (new) — a scikit-build-core build backend driving the existing CMake. Builds a CPU-only wheel by default (BUILD_TESTING/BUILD_BENCHMARKS/BUILD_EXAMPLES off, so the GoogleTest fetch is skipped); GPU stays an explicit opt-in (-C cmake.define.ENABLE_CUDA=ON / ENABLE_HIP=ON). Declares the ase.plugins entry point. ase is an optional extra.
  • language_bindings/python/CMakeLists.txt — adds an install(TARGETS _matscipy_neighbours … DESTINATION matscipy_neighbours) rule so the extension lands inside the package in the wheel; the existing relative-import fallback in neighbours.py (from . import _matscipy_neighbours) then resolves with no source change.
  • language_bindings/python/matscipy_neighbours/_ase_plugin.py (new) — a thin adapter matching ASE's NeighborListFunction contract. neighbour_list already returns the same (i, j, d, D, S) letters and D = r[j]-r[i]+S@cell; the adapter only adds the self_interaction keyword, rejecting self_interaction=True (unsupported by the kernel) rather than silently differing.

Notes

  • Targets ASE's in-flight v4 plugin system (the ase.plugins entry-point group + NeighborListPlugin). The __ase_plugins__ registration is guarded — on an ASE without that API it registers nothing instead of breaking plugin discovery — so this is safe to merge ahead of the ASE side landing, and a no-op for current released ASE.
  • version = "0.1.0" is a static placeholder (the repo has no version metadata today); maintainers may prefer a dynamic/scm version.

Validation

Built and installed with pip install . (cp312 wheel, extension installed inside the package). Against an ASE branch carrying the v4 NeighborListPlugin: matscipy-neighbours edge sets are byte-identical to ASE's reference backend across fcc / hcp / mixed-pbc slab systems (cutoffs 3 and 5 Å; D agrees to ~1e-15). In a neighbour-list backend benchmark it was the fastest CPU backend measured (e.g. ~3× faster than matscipy.neighbours and ~55× faster than ASE's default at 108k atoms) with the lowest peak memory.

🤖 Generated with Claude Code

Make matscipy-neighbours pip-installable and register its neighbour list as an
ASE neighbour-list backend, so `pip install .` builds the C extension and ASE
can select it via ase.neighborlist.get_neighbor_list("matscipy-neighbours").

- pyproject.toml (new): scikit-build-core build backend; CPU-only wheel
  (BUILD_TESTING/BENCHMARKS/EXAMPLES off); ase.plugins entry point. GPU stays an
  opt-in build (-C cmake.define.ENABLE_CUDA=ON / ENABLE_HIP=ON).
- language_bindings/python/CMakeLists.txt: install the _matscipy_neighbours
  extension into the package dir so the wheel's relative import resolves.
- language_bindings/python/matscipy_neighbours/_ase_plugin.py (new): adapter
  matching ASE's NeighborListFunction contract (rejects self_interaction=True,
  which the kernel does not support) plus a guarded __ase_plugins__ that
  registers nothing on an ASE without the v4 plugin API, so plugin discovery
  never breaks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pastewka

Copy link
Copy Markdown
Contributor

Thanks @jameskermode!

@pastewka
pastewka merged commit fe628a4 into main Jun 21, 2026
13 checks passed
@pastewka
pastewka deleted the add-ase-plugin-and-pip-packaging branch June 21, 2026 18:25
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.

2 participants