Skip to content

Commit

Permalink
ENH Add minimal support for spin as a developer tool (scikit-learn#29012
Browse files Browse the repository at this point in the history
)

Co-authored-by: Tim Head <[email protected]>
  • Loading branch information
lesteve and betatim authored Jul 22, 2024
1 parent 6f5dac0 commit e19d410
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .spin/cmds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import shutil
import sys

import click
from spin.cmds import util


@click.command()
def clean():
"""🪥 Clean build folder.
Very rarely needed since meson-python recompiles as needed when sklearn is
imported.
One known use case where "spin clean" is useful: avoid compilation errors
when switching from numpy<2 to numpy>=2 in the same conda environment or
virtualenv.
"""
util.run([sys.executable, "-m", "pip", "uninstall", "scikit-learn", "-y"])
default_meson_build_dir = (
f"build/cp{sys.version_info.major}{sys.version_info.minor}"
)
click.secho(
f"removing default Meson build dir: {default_meson_build_dir}",
bold=True,
fg="bright_blue",
)

shutil.rmtree(default_meson_build_dir, ignore_errors=True)
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,16 @@ exclude= '''
sdist-only = []
git-only = [".*", "asv_benchmarks", "azure-pipelines.yml", "benchmarks", "build_tools", "maint_tools"]
default-ignore = false

[tool.spin]
package = "sklearn" # name of your package

[tool.spin.commands]
"Build" = [
"spin.cmds.pip.install",
"spin.cmds.meson.test",
".spin/cmds.py:clean",
]
"Documentation" = [
"spin.cmds.meson.docs"
]

0 comments on commit e19d410

Please sign in to comment.