Skip to content

Commit

Permalink
Do not run the code generator if PYERFA_USE_SYSTEM_LIBERFA=1
Browse files Browse the repository at this point in the history
  • Loading branch information
avalentino committed Jul 6, 2020
1 parent 85a3794 commit a3e528e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit a3e528e

Please sign in to comment.