{"id":2985,"library":"libsass","title":"Sass for Python (libsass)","description":"Libsass is a Python binding for LibSass, the C/C++ port of the original Sass CSS preprocessor. It allows Python developers to compile Sass/SCSS files to CSS without needing a Ruby or Node.js runtime. While the `libsass-python` wrapper is actively maintained and currently at version 0.23.0 (released January 6, 2024), the underlying LibSass C/C++ library reached its official End-of-Life in October 2025 and is no longer receiving updates.","status":"maintenance","version":"0.23.0","language":"en","source_language":"en","source_url":"https://github.com/sass/libsass-python","tags":["sass","scss","css preprocessor","compiler","libsass","stylesheet"],"install":[{"cmd":"pip install libsass","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The primary function to compile Sass/SCSS to CSS.","symbol":"compile","correct":"from sass import compile"},{"note":"Exception raised on compilation errors.","symbol":"CompileError","correct":"from sass import CompileError"}],"quickstart":{"code":"import sass\n\nscss_code = \"\"\"\n$primary-color: #337ab7;\n\n.container {\n  h1 {\n    color: $primary-color;\n  }\n  p {\n    font-size: 1.2em;\n  }\n}\n\"\"\"\n\ntry:\n    css_output = sass.compile(string=scss_code, output_style='compressed')\n    print(css_output)\nexcept sass.CompileError as e:\n    print(f\"Sass compilation error: {e}\")","lang":"python","description":"Compiles a SCSS string to a compressed CSS string. The `compile` function can also take `filename` or `dirname` arguments for file-based compilation."},"warnings":[{"fix":"Migrate to `sass-embedded-python` (or another Dart Sass wrapper) for future-proof Sass compilation.","message":"The upstream LibSass C/C++ library, which `libsass-python` wraps, reached its End-of-Life in October 2025 and is no longer maintained. It will not receive feature updates or compatibility with new CSS/Sass features. Users are strongly advised to migrate to Dart Sass or a Python binding for Dart Sass, such as `sass-embedded-python`.","severity":"breaking","affected_versions":"All versions (due to upstream dependency)"},{"fix":"Ensure your project runs on Python 3.8 or newer (as required by PyPI metadata).","message":"Python 2.x support was removed in version 0.22.0.","severity":"deprecated","affected_versions":">=0.22.0"},{"fix":"Use the `pysassc` command-line tool, which provides SassC-compliant functionality, or use the `sass.compile()` API directly.","message":"The `sassc` command-line interface, previously shipped with libsass-python, was removed in version 0.22.0.","severity":"deprecated","affected_versions":">=0.22.0"},{"fix":"Ensure a compatible C++ compiler is installed and configured in your build environment (e.g., `build-essential` on Debian/Ubuntu, Xcode Command Line Tools on macOS, Visual Studio Build Tools on Windows).","message":"Installation of `libsass` may require a C++ compiler (like GCC, Clang, or MSVC) on your system, especially if pre-built wheels are not available for your specific platform or Python version. It requires a compiler that supports recent C++ standards (C++11 or newer).","severity":"gotcha","affected_versions":"All versions, especially on non-standard environments"},{"fix":"Review the Sass documentation on LibSass migration to understand potential behavioral differences when using `libsass-python` vs. Dart Sass. Consider using the Sass migrator tools if transitioning.","message":"LibSass has known incompatibilities and differences in behavior compared to Dart Sass (the current reference implementation), particularly regarding `@import` vs `@use`, `/` for division, custom property parsing, and `@extend` rules with complex selectors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use boolean values (`True` or `False`) for the `source_comments` parameter. String values are deprecated and will be obsolete.","message":"The `source_comments` parameter for `sass.compile()` changed its accepted values. Historically, it could take strings like 'none', 'line_numbers', 'map'. As of 0.6.0, it primarily accepts boolean values (`True`/`False`).","severity":"gotcha","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}