14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-12-22 23:41:30 +01:00

Build: fix range error for missing module 'past'

On systems without `future`, there would issues with missing `past`.

        from past.builtins import xrange
    ModuleNotFoundError: No module named 'past'

Installing `future` like `pip install future` can help, but it bothers.

Changing `xrange` to `range` can be OK since python3 has no `xrange`
anymore, while both 2 and 3 can have `range`.

The performance impact with python2 should be minor.

Tested OK on latest Debian bullseye/bookworm, Ubuntu jammy, and
Archlinux, with python2 linked to 2.7.18, or 2.7.3, while python linked
to 3.10.8, 3.10.6, or 3.9.2.
This commit is contained in:
Aaron Shang 2022-12-02 17:41:54 +08:00
parent 996150820b
commit c8fbf13b96

View File

@ -3,8 +3,6 @@
# LICENSE: MIT # LICENSE: MIT
# vim: sts=4 sw=4 ts=4 et # vim: sts=4 sw=4 ts=4 et
from past.builtins import xrange
import fontforge import fontforge
from itertools import compress from itertools import compress
import os import os
@ -72,9 +70,9 @@ def permutations():
bitmap_max = 1 << count bitmap_max = 1 << count
# Iterate over all possible permutations # Iterate over all possible permutations
for i in xrange(bitmap_max): for i in range(bitmap_max):
# Map the iteration's permutations using a bitmap # Map the iteration's permutations using a bitmap
bitmap = [i >> n & 1 for n in xrange(count)] bitmap = [i >> n & 1 for n in range(count)]
for opts in _expand_options(bitmap): for opts in _expand_options(bitmap):
yield(int(float(i)/bitmap_max*100), opts) yield(int(float(i)/bitmap_max*100), opts)