{"id":6891,"library":"spin","title":"spin","description":"spin is a developer tool designed to simplify common tasks for scientific Python libraries, such as environment setup, testing, and documentation builds. It focuses on standardizing development workflows using `pyproject.toml`. Current version is 0.18, with releases occurring periodically to add features and fix bugs.","status":"active","version":"0.18","language":"en","source_language":"en","source_url":"https://github.com/scientific-python/spin","tags":["developer-tool","build-tool","task-runner","scientific-python","cli"],"install":[{"cmd":"pip install spin","lang":"bash","label":"Install spin"}],"dependencies":[],"imports":[{"note":"This is the primary programmatic entry point for invoking spin commands, typically used for testing or integrating spin into automated workflows rather than general application usage. Note that `run_spin` often calls `sys.exit()`.","symbol":"run_spin","correct":"from spin.app import run_spin"}],"quickstart":{"code":"import os\nimport subprocess\nimport sys\nimport tempfile\nfrom pathlib import Path\n\n# Create a temporary project directory to run spin in\nwith tempfile.TemporaryDirectory() as tmpdir_name:\n    project_path = Path(tmpdir_name)\n    os.chdir(project_path)\n\n    # Define a simple pyproject.toml with a 'hello' task\n    pyproject_content = \"\"\"\n[project]\nname = \"my-spin-project\"\nversion = \"0.1.0\"\n\n[tool.spin]\ntasks.hello = \"echo Hello from spin!\"\n\"\"\"\n    (project_path / \"pyproject.toml\").write_text(pyproject_content)\n\n    print(f\"Temporary project created at: {project_path}\")\n    print(\"Attempting to run 'spin hello' via subprocess...\")\n\n    try:\n        # Invoke spin using `python -m spin` to simulate CLI execution\n        # and allow the Python script to continue after spin completes.\n        result = subprocess.run([sys.executable, '-m', 'spin', 'hello'],\n                                capture_output=True, text=True, check=True)\n        \n        print(\"\\n--- spin output ---\")\n        print(result.stdout.strip())\n        print(\"--- end spin output ---\")\n        \n        assert \"Hello from spin!\" in result.stdout\n        print(\"Quickstart successful: 'spin hello' task executed and verified.\")\n\n    except subprocess.CalledProcessError as e:\n        print(f\"Error running spin command (exit code {e.returncode}):\")\n        print(f\"Stdout: {e.stdout}\")\n        print(f\"Stderr: {e.stderr}\")\n        sys.exit(1)\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n        sys.exit(1)\n","lang":"python","description":"This quickstart demonstrates how to set up a minimal `spin` project (a `pyproject.toml` with a task) and then programmatically invoke a `spin` command using `subprocess`. While `spin` has a Python API (`spin.app.run_spin`), direct `subprocess` invocation is often more robust for quickstarts and automation, as `run_spin` can cause `sys.exit()`."},"warnings":[{"fix":"Migrate your project's build backend and metadata from `setup.py` to `pyproject.toml` (PEP 517/621). Ensure all `[tool.spin]` configurations are defined in `pyproject.toml`.","message":"Support for `setup.py` was completely removed in version 0.16.0. All project configuration and `spin` task definitions must now reside in `pyproject.toml`.","severity":"breaking","affected_versions":">=0.16.0"},{"fix":"Review any `spin` task definitions that process command-line arguments. Update the task implementation in `pyproject.toml` (e.g., in a script) to correctly parse or utilize a list of string arguments.","message":"The way arguments are passed to tasks changed significantly in version 0.10.0. Tasks now receive arguments as a list of strings directly, rather than a single concatenated string.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"If you require a specific environment manager, explicitly configure it in your `pyproject.toml` under `[tool.spin.install]`, for example, `manager = \"pip\"` or `manager = \"conda\"`. Ensure the chosen manager is installed and accessible.","message":"By default, `spin install` attempts to use `conda` for environment creation if a `conda` executable is found in the system's PATH. If `conda` is not available, it falls back to `pip`.","severity":"gotcha","affected_versions":">=0.15.0"},{"fix":"Always change your current working directory to the project root before running any `spin` commands. Verify your `pyproject.toml` includes a `[tool.spin]` table with at least one defined task or configuration.","message":"spin commands must be executed from the root directory of a project that contains a `pyproject.toml` file with a valid `[tool.spin]` section. Running `spin` from a subdirectory or without this configuration will lead to errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}