Skip to content

Commit a52ad36

Browse files
authored
feat: reduce size of wheels (#105)
1 parent 34cfda2 commit a52ad36

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

build_ext.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@
55
from distutils.command.build_ext import build_ext
66
from typing import Any
77

8+
try:
9+
from setuptools import Extension
10+
except ImportError:
11+
from distutils.core import Extension
12+
13+
14+
TO_CYTHONIZE = ["src/bleak_esphome/backend/scanner.py"]
15+
16+
EXTENSIONS = [
17+
Extension(
18+
ext.removeprefix("src/").removesuffix(".py").replace("/", "."),
19+
[ext],
20+
language="c",
21+
extra_compile_args=["-O3", "-g0"],
22+
)
23+
for ext in TO_CYTHONIZE
24+
]
25+
26+
827
_LOGGER = logging.getLogger(__name__)
928

1029

@@ -30,9 +49,7 @@ def build(setup_kwargs: Any) -> None:
3049
setup_kwargs.update(
3150
{
3251
"ext_modules": cythonize(
33-
[
34-
"src/bleak_esphome/backend/scanner.py",
35-
],
52+
EXTENSIONS,
3653
compiler_directives={"language_level": "3"}, # Python 3
3754
),
3855
"cmdclass": {"build_ext": BuildExt},

0 commit comments

Comments
 (0)