Skip to content

Commit

Permalink
Stop the build from failing when a C compiler cannot be found.
Browse files Browse the repository at this point in the history
  • Loading branch information
teknico committed Apr 20, 2020
1 parent f69a1b7 commit 62326dc
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions decred/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,34 @@
It uses a currently undocumented Poetry feature, see:
https://github.com/python-poetry/poetry/issues/11#issuecomment-379484540
If Cython or a C compiler cannot be found, we skip the compilation
of the C extension, and the Python code will be used.
The shared library can also be built manually using the command:
$ cythonize -X language_level=3 -a -i ./decred/crypto/secp256k1/field.py
"""

# fmt: off
try:
from Cython.Build import cythonize
except ImportError:
def build(setup_kwargs):
from distutils.command.build_ext import build_ext


class BuildExt(build_ext):
def build_extensions(self):
try:
super().build_extensions()
except Exception:
pass


def build(setup_kwargs):
try:
from Cython.Build import cythonize
except ImportError:
pass
else:
def build(setup_kwargs):
else:
setup_kwargs.update(
{"ext_modules": cythonize(["decred/crypto/secp256k1/field.py"])}
dict(
cmdclass=dict(build_ext=BuildExt),
ext_modules=cythonize(["decred/crypto/secp256k1/field.py"]),

This comment has been minimized.

Copy link
@buck54321

buck54321 Apr 20, 2020

Member

I want to catch any exception from Cython, including from it's functions like cythonize. There should be no reason Cython causes our install to fail ever, so I don't really care where the exception is happening in Cython, and I'm not going to try to predict where a failure will occur when the environment is wrong. If we have an issue with Cython, it should fall back to pure-Python. This is part of the reason I'm saying that the use of else: is not appropriate here. It's like saying that it's okay to fail in some places but not others. It should fail gracefully regardless of where the exception actually occurs.

)
)
# fmt: on

0 comments on commit 62326dc

Please sign in to comment.