Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ install:
- export CONDA_INSTALL="conda install -c astropy-ci-extras --yes python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY_VERSION"

# CORE DEPENDENCIES
- if [[ $SETUP_CMD == test* || $SETUP_CMD == build_sphinx* ]]; then $CONDA_INSTALL pytest pip Cython psutil; fi
- if [[ $SETUP_CMD == test* || $SETUP_CMD == build_sphinx* ]]; then $CONDA_INSTALL pytest pip Cython jinja2 psutil; fi

# OPTIONAL DEPENDENCIES
- if $OPTIONAL_DEPS; then $CONDA_INSTALL scipy h5py; fi
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ Other Changes and Additions
- The list of modules displayed in the pytest header can now be customized.
[#3157]

- `jinja2 <http://jinja.pocoo.org/docs/dev/>`_ is now required to build the
source code from the git repository, in order to allow the ERFA wrappers to
be generated. [#3166]

0.4.3 (unreleased)
------------------

Expand Down
19 changes: 13 additions & 6 deletions astropy/erfa/cython_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ def __repr__(self):



def main(srcdir, outfn, templateloc):
def main(srcdir, outfn, templateloc, verbose=True):
from jinja2 import Environment, FileSystemLoader

if verbose:
print_ = lambda *args, **kwargs: print(*args, **kwargs)
else:
print_ = lambda *args, **kwargs: None

#Prepare the jinja2 templating environment
env = Environment(loader=FileSystemLoader(templateloc))

Expand Down Expand Up @@ -369,11 +374,11 @@ def surround(a_list, pre, post):
section_subsection_functions = re.findall('/\* (\w*)/(\w*) \*/\n(.*?)\n\n',
erfa_h, flags=re.DOTALL|re.MULTILINE)
for section, subsection, functions in section_subsection_functions:
print("{0}.{1}".format(section, subsection))
print_("{0}.{1}".format(section, subsection))
if section == "Astronomy":
func_names = re.findall(' (\w+)\(.*?\);', functions, flags=re.DOTALL)
for name in func_names:
print("{0}.{1}.{2}...".format(section, subsection, name))
print_("{0}.{1}.{2}...".format(section, subsection, name))
if multifilserc:
# easy because it just looks in the file itself
funcs.append(Function(name, srcdir))
Expand All @@ -398,18 +403,18 @@ def surround(a_list, pre, post):
"spawned it. This should be "
"impossible!")

print("Rendering template")
print_("Rendering template")
erfa_pyx = erfa_pyx_in.render(funcs=funcs)
erfa_py = erfa_py_in.render(funcs=funcs)

if outfn is not None:
print("Saving to", outfn)
print_("Saving to", outfn)
with open(outfn, "w") as f:
f.write(erfa_py)
with open(outfn+"x", "w") as f:
f.write(erfa_pyx)

print("Done!")
print_("Done!")

return erfa_pyx, funcs

Expand All @@ -433,6 +438,8 @@ def surround(a_list, pre, post):
default=DEFAULT_TEMPLATE_LOC,
help='the location where the "erfa.pyx.templ" '
'template can be found.')
ap.add_argument('-q', '--quiet', action='store_false', dest='verbose',
help='Suppress output normally printed to stdout.')

args = ap.parse_args()
main(args.srcdir, args.output, args.template_loc)
Loading