-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cython pxd for base_scanner
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Build optional cython modules.""" | ||
|
||
import logging | ||
import os | ||
from distutils.command.build_ext import build_ext | ||
from typing import Any | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class BuildExt(build_ext): | ||
"""Build extension.""" | ||
|
||
def build_extensions(self) -> None: | ||
"""Build extensions.""" | ||
try: | ||
super().build_extensions() | ||
except Exception as ex: # nosec | ||
_LOGGER.debug("Failed to build extensions: %s", ex, exc_info=True) | ||
pass | ||
|
||
|
||
def build(setup_kwargs: Any) -> None: | ||
"""Build optional cython modules.""" | ||
if os.environ.get("SKIP_CYTHON", False): | ||
return | ||
try: | ||
from Cython.Build import cythonize | ||
|
||
setup_kwargs.update( | ||
{ | ||
"ext_modules": cythonize( | ||
["src/habluetooth/base_scanner.py"], | ||
compiler_directives={"language_level": "3"}, # Python 3 | ||
), | ||
"cmdclass": {"build_ext": BuildExt}, | ||
} | ||
) | ||
setup_kwargs["exclude_package_data"] = { | ||
pkg: ["*.c"] for pkg in setup_kwargs["packages"] | ||
} | ||
except Exception: | ||
if os.environ.get("REQUIRE_CYTHON"): | ||
raise | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters