Skip to content

Commit

Permalink
Remove EmPy 3 compat.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Jul 19, 2024
1 parent 1b51c91 commit e65fdbd
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions cylc/flow/parsec/empysupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,18 @@ def empyprocess(
os.chdir(dir_)
ftempl = StringIO('\n'.join(flines))
xtempl = StringIO()
# Detect EmPy version by interpreter.file() args.
# TODO: Use importlib.metadata version() once we drop Python 3.7
if 'name' in inspect.signature(em.Interpreter.file).parameters:
# Empy 3
interpreter = em.Interpreter(
output=em.UncloseableFile(xtempl)
)
else:
# Empy 4
# dispatcher = False: raise errors to caller
interpreter = em.Interpreter(
output=em.UncloseableFile(xtempl),
dispatcher=False
)
# Requires EmPy >= 4.1
interpreter = em.Interpreter(
output=em.UncloseableFile(xtempl),
dispatcher=False # raise errors to caller
)

# Add `CYLC_` environment variables to the global namespace.
interpreter.updateGlobals(
get_cylc_env_vars()
)

try:
# These args work for EmPy versions 3 and 4.
interpreter.file(ftempl, locals=template_vars)
except Exception as exc:
lineno = interpreter.contexts[-1].identify()[1]
Expand Down

0 comments on commit e65fdbd

Please sign in to comment.