From a3e528e9d2c6461c47562432d821c4f38b001c2a Mon Sep 17 00:00:00 2001 From: Antonio Valentino Date: Sun, 10 May 2020 19:08:43 +0200 Subject: [PATCH] Do not run the code generator if PYERFA_USE_SYSTEM_LIBERFA=1 --- setup.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 224641a..1bebc65 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,10 @@ LIBERFADIR = os.path.join('liberfa', 'erfa') ERFA_SRC = os.path.join(LIBERFADIR, 'src') +GEN_FILES = [ + os.path.join('erfa', 'core.py'), + os.path.join('erfa', 'ufunc.c'), +] # https://mail.python.org/pipermail/distutils-sig/2007-September/008253.html @@ -27,18 +31,25 @@ def include_dirs(self, include_dirs): def get_extensions(): - cmd = [sys.executable, 'erfa_generator.py', ERFA_SRC, '--quiet'] - subprocess.run(cmd, check=True) - sources = [os.path.join('erfa', 'ufunc.c')] - include_dirs = [] - libraries = [] if int(os.environ.get('PYERFA_USE_SYSTEM_LIBERFA', 0)): libraries.append('erfa') + + if not all(os.path.isfile(fn) for fn in GEN_FILES): + raise RuntimeError( + 'Missing "liberfa" source files, unable to generate ' + '"erfa/ufunc.c" and "erfa/core.py". ' + 'Please check your source tree. ' + 'Maybe "git submodule update" could help.') + else: + print('Run "erfa_generator.py"') + cmd = [sys.executable, 'erfa_generator.py', ERFA_SRC, '--quiet'] + subprocess.run(cmd, check=True) + # get all of the .c files in the liberfa/erfa/src directory erfafns = os.listdir(ERFA_SRC) sources.extend([os.path.join(ERFA_SRC, fn)