-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Generate ERFA wrappers on-the-fly #3170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…or a release tarball
b4ffbed to
a7cb7ab
Compare
|
The reason Travis is failing is because |
|
@astrofrog wrote:
Why not include the template files in sdist? We include .pyx files already. It should still be possible to do development from a tarball (even if a git checkout is the sanest way to go). I think the important thing is that the generated files are in the tarball, but I would explicitly include the template files also. |
b93d245 to
8a406bc
Compare
|
@mdboom - ok, sounds good, I added it back (note that there was a typo in that before, so it wasn't including the |
|
@mdboom - what do you think is the right approach re: |
astropy/erfa/setup_package.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @mdboom that the template files should be in the release (if only to ensure the poor Debian packagers don't have to put it back ;-). If so, this if statement can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will remove that :)
|
@astrofrog - looks good! And I think it passes @eteq's condiment test.... |
|
As for the |
|
|
|
I will add that what is currently written to SOURCES.txt is not even accurate anyways. That's something to be fixed, but it's not really a showstopper either. |
|
Actually, this is all about generating some C sources anyways right? That shouldn't have anything to do with |
|
@mdboom - #3166 implements this as a separate step (thought I have to backport changes from this PR to there) but @embray was opposed to having the separate step since it means modifying One idea would be to go with what this PR implements, but create a custom type of |
|
I'm going to go ahead and try and implement |
|
@mdboom @embray - check out the so my approach is to make This works correctly with So just to clarify, it's a hack, but it's a hack we have control over because we are the ones who decide to access |
|
(debugging Travis but still open to comments in mean time) |
|
@astrofrog - I like this approach. I just issued a PR against your branch (astrofrog#50) that adds an option to suppress the output from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This same thing is defined further down inside the line that starts with erfafns=, so you can reuse it there (and you may also want to follow that and add ERFAPKGDIR as the starting point of the ERFA_SRC path - I'm not sure if that's necessary, but it might be safer?).
add option to silence cython_generator
astropy/erfa/setup_package.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize you're doing this right now for testing, but in the end you might leave these in as distuitls.log.debug calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and it wouldn't hurt to have an INFO call to say that we're generating the ERFA wrappers if we do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, definitely.
|
@eteq - does this work locally for you if you run build? (just trying to understand if the Travis issue is Travis-specific) |
|
@astrofrog - Nope, I get: It doesn't seem to ever reach the generating code at all... |
|
@astrofrog - I think I may see the problem... |
|
See http://nbviewer.ipython.org/gist/eteq/3134913ecac69b93912f for a demonstration of the problem. AFAICT old-style classes work only with property getters, not setters. I'm guessing you can do something in the |
|
|
|
Ok, so I got one step further and the extension stuff works. BUT - At this point I don't think we can do anything without modifying astropy-helpers. Maybe something like #3166 ain't so bad after all. |
|
Note that if we didn't have the separate .py and .pyx files, this would work. Ironic! :-/ |
|
Can somebody explain to me, like I'm 5, why this is desirable at all? How often do these templates need to be updated? Is this something we can just include in the source? Also, on closer inspection, I don't think the generated .py file is needed at all (the Cython/C code, sure). But most of the functions in the Python module could instead be generated on-the-fly as needed. It would be nice if we just included a dump of the parsed erfa.h as like a JSON file or something, and that would provide all the information needed to return new Python functions if/when needed. If that sounds appealing I can submit a PR. It won't require Jinja or anything like that. |
|
@embray - the generated files are ~1Mb. Every time we modify something in the template (a) we have to remember to re-generate the files, and (b) we increase the size of the repository quickly and (c) the diffs in PRs are too large. The approach here is too complicated but in #3166 is pretty simple. I'm not sure that the solution you are suggesting is any simpler, and may also introduce performance penalties, right? |
|
I like the idea of generating the python parts of the wrapper on the fly -- |
|
I'm going to close this specific issue because this was a dead-end. Any subsequent conversation should be continued on #3166 which is still up for consideration. |
|
@mhvk We're already building this huge Python file, though most of the code in it could be vastly simplified such that a single function, plus a little introspection, could implement the wrapper for all the ERFA functions. The information needed for the introspection has to come from somewhere, which is why I suggested a JSON file. Though it could just as easily be a Python module with a dict in it--I just suggested JSON because it could be used for other purposes as well--it's just metadata about the ERFA API, basically. Generating the Python functions on the fly, as needed, would have a small impact. As I said, for the most part they can be generated by wrapping a single function. Once a particular function is loaded it doesn't have to be re-generated either, so it's a one-time cost. The generated Cython file on the other hand comes in at 133 kB, and how often does it really need to be regenerated? If we switch to just using C directly instead of Cython, as I've heard suggested, it will probably be a little larger, but only a little. So I don't see the big deal. |
|
@embray - I can see the appeal with the JSON approach, so it's just a question of whether someone has the time to develop this 😄. I agree that with the current Cython/Python split in the wrappers the Cython/C part is not really a big deal. At the end of the day, if we can find a way to do without having to generate or auto-generate that doesn't take too much space and doesn't have a big performance impact, I'm all for it. |
|
Sounds fine - I'll go ahead and close this then, although if we end up thinking this is a better way after all it can always be re-opened. |
|
I'm working on it (my suggestion). |
|
@embray - in case this rolls into the changes you're working on right now, I am firmly against the idea of keeping the C checked in - that was always intended as a temporary measure. The reality is that people forget to do this when they update the templates, so they're out-of-sync with the generated source for a lot of the commit history, and that makes for headaches. Although I have no objections to some sort of on-the-fly intospection/generation on the python side. |
(This is an alternative to #3166)
With this PR, which starts from one of @jwoillez's branches, ERFA files are generated on-the-fly, but only if any of the input files or scripts have been modified since the files were generated.
This does not require any changes to astropy-helpers and makes use of the current infrastructure.
I also made sure that
sdistdoes not include the template files, and this also allows us to determine whether we are in release mode.One change that could be made would be to just move the contents of
cython_generate.pyinsidesetup_package.pybut I'll let @eteq decide on this.cc @jwoillez @embray @mdboom @eteq @mhvk @taldcroft