The simplest way (and with considerably better performance) is using Pyrut.
install with
pip install PyRut
from pyrut import validate_rut validate_rut("12345678")