Skip to content

Commit ae571b3

Browse files
committed
remove distutils helper for cython fail handle
1 parent 3a5e839 commit ae571b3

File tree

2 files changed

+10
-68
lines changed

2 files changed

+10
-68
lines changed

doc/source/logwrap.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ API: Decorators: `LogWrap` class and `logwrap` function.
66
.. py:module:: logwrap
77
.. py:currentmodule:: logwrap
88
9-
.. py:class:: LogWrap(object)
9+
.. py:class:: LogWrap
1010
1111
Log function calls and return values.
1212

@@ -15,7 +15,7 @@ API: Decorators: `LogWrap` class and `logwrap` function.
1515
.. py:method:: __init__(*, log=None, log_level=logging.DEBUG, exc_level=logging.ERROR, max_indent=20, blacklisted_names=None, blacklisted_exceptions=None, log_call_args=True, log_call_args_on_exc=True, log_traceback=True, log_result_obj=True, )
1616
1717
:param log: logger object for decorator, by default trying to use logger from target module. Fallback: 'logwrap'
18-
:type log: typing.Optional[logging.Logger]
18+
:type log: logging.Logger | None
1919
:param log_level: log level for successful calls
2020
:type log_level: int
2121
:param exc_level: log level for exception cases
@@ -24,11 +24,11 @@ API: Decorators: `LogWrap` class and `logwrap` function.
2424
:type max_indent: int
2525
:param blacklisted_names: Blacklisted argument names.
2626
Arguments with this names will be skipped in log.
27-
:type blacklisted_names: typing.Optional[typing.Iterable[str]]
27+
:type blacklisted_names: Iterable[str] | None
2828
:param blacklisted_exceptions: list of exception,
2929
which should be re-raised without
3030
producing traceback and text log record.
31-
:type blacklisted_exceptions: typing.Optional[typing.Iterable[typing.Type[Exception]]]
31+
:type blacklisted_exceptions: Iterable[type[Exception]] | None
3232
:param log_call_args: log call arguments before executing wrapped function.
3333
:type log_call_args: bool
3434
:param log_call_args_on_exc: log call arguments if exception raised.
@@ -105,18 +105,18 @@ API: Decorators: `LogWrap` class and `logwrap` function.
105105
:param func: function to wrap
106106
:type func: typing.Optional[typing.Callable]
107107
:param log: logger object for decorator, by default trying to use logger from target module. Fallback: 'logwrap'
108-
:type log: typing.Optional[logging.Logger]
108+
:type log: logging.Logger | None
109109
:param log_level: log level for successful calls
110110
:type log_level: int
111111
:param exc_level: log level for exception cases
112112
:type exc_level: int
113113
:param max_indent: maximum indent before classic `repr()` call.
114114
:type max_indent: int
115115
:param blacklisted_names: Blacklisted argument names. Arguments with this names will be skipped in log.
116-
:type blacklisted_names: typing.Optional[typing.Iterable[str]]
116+
:type blacklisted_names: Iterable[str] | None
117117
:param blacklisted_exceptions: list of exceptions, which should be re-raised
118118
without producing traceback and text log record.
119-
:type blacklisted_exceptions: typing.Optional[typing.Iterable[typing.Type[Exception]]]
119+
:type blacklisted_exceptions: Iterable[type[Exception]] | None
120120
:param log_call_args: log call arguments before executing wrapped function.
121121
:type log_call_args: bool
122122
:param log_call_args_on_exc: log call arguments if exception raised.

setup.py

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020

2121
# Standard Library
2222
import ast
23-
import distutils.errors
2423
import os.path
25-
import shutil
2624
import sys
27-
from distutils.command import build_ext
2825

2926
# External Dependencies
3027
import setuptools
@@ -64,6 +61,7 @@
6461

6562
EXT_MODULES = cythonize(
6663
module_list=REQUIRES_OPTIMIZATION,
64+
exclude_failures=True,
6765
compiler_directives={
6866
"always_allow_keywords": True,
6967
"binding": True,
@@ -78,55 +76,6 @@
7876
EXT_MODULES = []
7977

8078

81-
class BuildFailedError(Exception):
82-
"""For install clear scripts."""
83-
84-
85-
class AllowFailRepair(build_ext.build_ext):
86-
"""This class allows C extension building to fail and repairs init."""
87-
88-
def run(self) -> None:
89-
"""Run.
90-
91-
:raises BuildFailedError: Build is failed and clean python code should be used.
92-
"""
93-
try:
94-
build_ext.build_ext.run(self)
95-
96-
# Copy __init__.py back to repair package.
97-
build_dir = os.path.abspath(self.build_lib)
98-
root_dir = os.path.abspath(os.path.join(__file__, ".."))
99-
target_dir = build_dir if not self.inplace else root_dir
100-
101-
src_file = os.path.join(PACKAGE_NAME, "__init__.py")
102-
103-
src = os.path.join(root_dir, src_file)
104-
dst = os.path.join(target_dir, src_file)
105-
106-
if src != dst:
107-
shutil.copyfile(src, dst)
108-
except (
109-
distutils.errors.DistutilsPlatformError,
110-
FileNotFoundError,
111-
) as exc:
112-
raise BuildFailedError() from exc
113-
114-
def build_extension(self, ext) -> None:
115-
"""build_extension.
116-
117-
:raises BuildFailedError: Build is failed and clean python code should be used.
118-
"""
119-
try:
120-
build_ext.build_ext.build_extension(self, ext)
121-
except (
122-
distutils.errors.CCompilerError,
123-
distutils.errors.DistutilsExecError,
124-
distutils.errors.DistutilsPlatformError,
125-
ValueError,
126-
) as exc:
127-
raise BuildFailedError() from exc
128-
129-
13079
# noinspection PyUnresolvedReferences
13180
def get_simple_vars_from_src(
13281
src: str,
@@ -246,13 +195,6 @@ def get_simple_vars_from_src(
246195
)
247196
if cythonize is not None:
248197
SETUP_ARGS["ext_modules"] = EXT_MODULES
249-
SETUP_ARGS["cmdclass"] = dict(build_ext=AllowFailRepair)
250198

251-
try:
252-
setuptools.setup(**SETUP_ARGS)
253-
except BuildFailedError:
254-
print("*" * 80 + "\n* Build Failed!\n* Use clear scripts version.\n" + "*" * 80 + "\n")
255-
del SETUP_ARGS["ext_modules"]
256-
del SETUP_ARGS["cmdclass"]
257-
SETUP_ARGS["package_data"][PACKAGE_NAME] = ["py.typed"]
258-
setuptools.setup(**SETUP_ARGS)
199+
200+
setuptools.setup(**SETUP_ARGS)

0 commit comments

Comments
 (0)