Metadata-Version: 2.4
Name: lesscpy
Version: 0.15.2
Summary: Python LESS compiler
Author-email: Jóhann T Maríusson <jtm@robot.is>, Sascha Peilicke <sascha@peilicke.de>
License-Expression: MIT
Project-URL: Homepage, https://github.com/lesscpy/lesscpy
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Pre-processors
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: ply
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: flake8; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: ruff; extra == "test"
Provides-Extra: release
Requires-Dist: build; extra == "release"
Requires-Dist: twine; extra == "release"
Provides-Extra: tox
Requires-Dist: tox; extra == "tox"
Dynamic: license-file

# LESSCPY

[![Build Status](https://travis-ci.org/lesscpy/lesscpy.png?branch=master)](https://travis-ci.org/lesscpy/lesscpy)
[![Coverage Status](https://coveralls.io/repos/lesscpy/lesscpy/badge.png)](https://coveralls.io/r/lesscpy/lesscpy)
[![PyPI Downloads](https://img.shields.io/pypi/dm/lesscpy.svg)](https://pypi.python.org/pypi/lesscpy)
[![PyPI Version](https://img.shields.io/pypi/v/lesscpy.svg)](https://pypi.python.org/pypi/lesscpy)
[![Wheel Status](https://img.shields.io/pypi/wheel/lesscpy.svg)](https://pypi.python.org/pypi/lesscpy)
[![License](https://img.shields.io/pypi/l/lesscpy.svg)](https://pypi.python.org/pypi/lesscpy)

Python LESS Compiler.

A compiler written in Python for the LESS language. For those of us not willing
or able to have node.js installed in our environment. Not all features of LESS
are supported. Some features will probably never be supported (JavaScript
evaluation). This program uses PLY (Python Lex-Yacc) to tokenize / parse the
input and is considerably slower than the Node.js compiler.

For more information on LESS:
- http://lesscss.org/
- https://github.com/cloudhead/less.js

Development files:
- https://github.com/lesscpy/lesscpy

## Supported features

- Variables
- String interpolation
- Mixins (nested, calls, closures, recursive)
- Guard expressions
- Parametered mixins (class / id)
- `@arguments`
- Nesting
- Escapes `~/e()`
- Expressions
- Keyframe blocks
- Color functions (lighten, darken, saturate, desaturate, spin, hue, mix, saturation, lightness)
- Other functions (round, increment, decrement, format `'%(...)`)

## Differences from less.js

- All colors are auto-formatted to `#nnnnnn` (for example, `#f7e923`)
- Does not preserve CSS comments

## Not supported

- JavaScript evaluation

## Requirements

- Python 3.11+
- `pip`

## Installation

Install from PyPI:

```bash
pip install lesscpy
```

## Local setup

Create and activate a virtual environment, then install test dependencies from `pyproject.toml`:

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[test]"
```

## Build

Build source and wheel distributions:

```bash
python -m pip install --upgrade build
python -m build
```

Artifacts are created in `dist/`.

## Test

Run unit tests:

```bash
pytest -v
```

Run lint checks:

```bash
flake8
```

## Using tox

`tox` is useful for running the project test workflow in isolated environments and for reproducing the same multi-version checks used in CI.

Run all configured environments:

```bash
python -m pip install -e ".[tox]"
tox
```

Run a single environment:

```bash
tox -e py3.12
tox -e flake8
```

## Compiler script usage

```text
usage: lesscpy [-h] [-v] [-I INCLUDE] [-V] [-C] [-x] [-X] [-t] [-s SPACES]
               [-o OUT] [-r] [-f] [-m] [-D] [-g] [-S] [-L] [-N]
               target [output]
```

## Python usage

```python
from io import StringIO
import lesscpy

print(lesscpy.compile(StringIO("a { border-width: 2px * 3; }"), minify=True))
```

Output:

```text
a{border-width:6px;}
```

## License

See the `LICENSE` file.
