File: use_setuptools.py

package info (click to toggle)
python-tomli 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,296 kB
  • sloc: python: 1,154; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Script that switches build backend to setuptools with mypyc support.

Overwrites pyproject.toml. Does not create a backup.
"""

from pathlib import Path
import tomllib

import tomli_w  # type: ignore[import-not-found]


def use_setuptools() -> None:
    pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
    data = tomllib.loads(pyproject_path.read_bytes().decode())
    data["build-system"] = {
        "requires": ["setuptools>=77.0.3", "mypy[mypyc]>=1.15"],
        "build-backend": "setuptools.build_meta",
    }
    pyproject_path.write_bytes(tomli_w.dumps(data).encode())


if __name__ == "__main__":
    use_setuptools()