|
3 | 3 | import io |
4 | 4 | import os |
5 | 5 | import platform |
| 6 | +import logging |
6 | 7 |
|
7 | 8 | import sys |
8 | 9 | from setuptools import setup, find_packages, Extension |
9 | 10 |
|
| 11 | + |
| 12 | +logging.basicConfig(level=logging.INFO) |
| 13 | + |
10 | 14 | with io.open("README.md", mode="rt", encoding="utf-8") as readme_file: |
11 | 15 | readme = readme_file.read() |
12 | 16 |
|
|
15 | 19 | USE_CYTHON = False |
16 | 20 | PLATFORM = "windows_nt" if platform.system() == "Windows" else "posix" |
17 | 21 | INCLUDE_LEXBOR = bool(os.environ.get("USE_LEXBOR", True)) |
| 22 | +INCLUDE_MODEST = bool(os.environ.get("USE_MODEST", True)) |
| 23 | + |
18 | 24 | ARCH = platform.architecture()[0] |
19 | 25 |
|
20 | 26 | try: |
|
33 | 39 | INCLUDE_LEXBOR = True |
34 | 40 | sys.argv.remove("--lexbor") |
35 | 41 |
|
| 42 | +if "--disable-modest" in sys.argv: |
| 43 | + INCLUDE_MODEST = False |
| 44 | + sys.argv.remove("--disable-modest") |
| 45 | + |
36 | 46 | if "--cython" in sys.argv: |
37 | 47 | if HAS_CYTHON: |
38 | 48 | USE_CYTHON = True |
@@ -78,30 +88,40 @@ def find_modest_files(modest_path="modest/source"): |
78 | 88 |
|
79 | 89 |
|
80 | 90 | def make_extensions(): |
| 91 | + logging.info(f"USE_CYTHON: {USE_CYTHON}") |
| 92 | + logging.info(f"INCLUDE_LEXBOR: {INCLUDE_LEXBOR}") |
| 93 | + logging.info(f"INCLUDE_MODEST: {INCLUDE_MODEST}") |
| 94 | + logging.info(f"USE_STATIC: {USE_STATIC}") |
| 95 | + |
81 | 96 | files_to_compile_lxb = [] |
| 97 | + files_to_compile = [] |
82 | 98 | extra_objects_lxb, extra_objects = [], [] |
83 | 99 |
|
84 | 100 | if USE_CYTHON: |
85 | | - files_to_compile = [ |
86 | | - "selectolax/parser.pyx", |
87 | | - ] |
| 101 | + if INCLUDE_MODEST: |
| 102 | + files_to_compile = [ |
| 103 | + "selectolax/parser.pyx", |
| 104 | + ] |
88 | 105 | if INCLUDE_LEXBOR: |
89 | 106 | files_to_compile_lxb = [ |
90 | 107 | "selectolax/lexbor.pyx", |
91 | 108 | ] |
92 | 109 | else: |
93 | | - files_to_compile = ["selectolax/parser.c"] |
| 110 | + if INCLUDE_MODEST: |
| 111 | + files_to_compile = ["selectolax/parser.c"] |
94 | 112 | if INCLUDE_LEXBOR: |
95 | 113 | files_to_compile_lxb = [ |
96 | 114 | "selectolax/lexbor.c", |
97 | 115 | ] |
98 | 116 |
|
99 | 117 | if USE_STATIC: |
100 | | - extra_objects = ["modest/lib/libmodest_static.a"] |
| 118 | + if INCLUDE_MODEST: |
| 119 | + extra_objects = ["modest/lib/libmodest_static.a"] |
101 | 120 | if INCLUDE_LEXBOR: |
102 | 121 | extra_objects_lxb = ["lexbor/liblexbor_static.a"] |
103 | 122 | else: |
104 | | - files_to_compile.extend(find_modest_files("modest/source")) |
| 123 | + if INCLUDE_MODEST: |
| 124 | + files_to_compile.extend(find_modest_files("modest/source")) |
105 | 125 | if INCLUDE_LEXBOR: |
106 | 126 | files_to_compile_lxb.extend(find_modest_files("lexbor/source")) |
107 | 127 |
|
@@ -135,18 +155,21 @@ def make_extensions(): |
135 | 155 | ] |
136 | 156 | ) |
137 | 157 |
|
138 | | - extensions = [ |
139 | | - Extension( |
140 | | - "selectolax.parser", |
141 | | - files_to_compile, |
142 | | - language="c", |
143 | | - include_dirs=[ |
144 | | - "modest/include/", |
145 | | - ], |
146 | | - extra_objects=extra_objects, |
147 | | - extra_compile_args=compile_arguments, |
148 | | - ), |
149 | | - ] |
| 158 | + extensions = [] |
| 159 | + if INCLUDE_MODEST: |
| 160 | + extensions.append( |
| 161 | + Extension( |
| 162 | + "selectolax.parser", |
| 163 | + files_to_compile, |
| 164 | + language="c", |
| 165 | + include_dirs=[ |
| 166 | + "modest/include/", |
| 167 | + ], |
| 168 | + extra_objects=extra_objects, |
| 169 | + extra_compile_args=compile_arguments, |
| 170 | + ) |
| 171 | + ) |
| 172 | + |
150 | 173 | if INCLUDE_LEXBOR: |
151 | 174 | extensions.append( |
152 | 175 | Extension( |
|
0 commit comments