Skip to content

PLY generated table handling is a pain #1112

Closed

Description

@eteq

I noticed just now that a recent change (I think #1050 ? It seems to be PLY-related, anyway, @mdboom) led to astropy now producing a parsetab.py file that gets installed into the base namespace. So we would namespace-collide with any existing parsetab package or module, which presumably is a very bad thing (TM).

So we should figure out how to move parsetab.py back into astropy/extern/* where it belongs.

Activity

  1. embray commented on May 19, 2013

    @embray
    Member

    Okay. I've seen that happening too. Glad I'm not going crazy. This probably needs to be fixed before we release 0.2.2 :(

  2. added a commit that references this issue on May 19, 2013
    a705dd8
  3. astrofrog commented on May 19, 2013

    @astrofrog
    Member

    @eteq @iguananaut - see #1113 for a possible fix

  4. taldcroft commented on May 19, 2013

    @taldcroft
    Member

    Yes, I was wondering where those parsetab.py files were coming from! I guess there is a reason I should be cautious doing "production" work with astropy master.

  5. embray commented on May 19, 2013

    @embray
    Member

    I've got a solution to this that works rather well EXCEPT in Python 3. The problem is that the parsetab files need to be generated at install time too, and currently that isn't possible in Python 3 due to SyntaxErrors when trying to import them.

    For now we could just disable the optimizations for Python 3. Or I could come up with a slightly more involved reorg.

    I think that for v0.2.2, in the interest of getting the release out the door, I'll go with just including the generated files in the repo since they don't need to updated anyways. Thoughts?

  6. embray commented on May 19, 2013

    @embray
    Member

    For anyone who's interested, here's what I've got so far: https://github.com/iguananaut/astropy/compare/issue-1112

    Basically, the PLY lex and yacc interfaces are a little kludgy at the moment (surprising considering who wrote it) but they do both accept passing in a module object for lextab and parsetab modules. So if they already exist we can just import them and pass them to lex.lex() and yacc.yacc(). Otherwise we just provide those functions the name we want for the modules and what directory they should be output to, and it will generate them (making them importable next time).

    This works fine, but for the purpose of generating them at install time I'm still not sure what best to do :/

  7. eteq commented on May 20, 2013

    @eteq
    MemberAuthor

    @iguananaut - I think this may have been what you were saying in #1113, but can we just provide them in astropy/extern/ply in the source code, or does parsetabs get generated even if we have it already there? I guess from your diff I don't understand what's controlling what gets generated at install time (or are you saying you're not sure either?)

  8. mdboom commented on May 20, 2013

    @mdboom
    Contributor

    Yeah -- the way this is all done is a terrible kludge. Sorry I hadn't noticed the parsetab thing when I was first evaluating PLY.

    Personally, I'm fine with just not generating the files. We already take care to not create the parsers unless they actually get used (i.e. not on import time), and the construction time (since our grammars are not enormous) isn't really that bad. That just generally seems safer to get something out the door now.

    Then for 0.3, we could consider doing something like @iguananaut's branch.

    @eteq: To answer your question about putting these in astropy/extern/ply: Each parser needs its own table, and we have three of them (for now), so these tables should go next to the parser implementation, not in astropy/extern/ply.

  9. embray commented on May 20, 2013

    @embray
    Member

    It does get generated at import time depending on what you're importing. No, nothing happens if you import astropy, but soon as you import astropy.units for example at least one of them gets generated.

    As a short-term fix I'm more toward leaving the generated files in the repository. They're small and easy enough to update, and that won't be much of an issue for 0.2.2 anyways.

  10. mdboom commented on May 20, 2013

    @mdboom
    Contributor

    @iguananaut: Oh, yes, I guess that's true since we parse some units always anyway...

    Storing them in the repo is fine -- and that certainly solves the use case when installing to a read-only location (such as /usr).

  11. embray commented on May 20, 2013

    @embray
    Member

    Exactly. I think for now I'll leave this issue open, but put the files in the repo as a temporary fix.

  12. added a commit that references this issue on May 20, 2013
  13. astrofrog commented on May 20, 2013

    @astrofrog
    Member

    Should this issue be reported upstream btw? (even though it's not really a bug, just sub-optimal behavior)

  14. embray commented on May 20, 2013

    @embray
    Member

    No, I don't see why. I mean, the behavior is documented. I guess it could be done better but I don't have any specific ideas in mind for how to improve it.

  15. added 2 commits that reference this issue on May 20, 2013
  16. eteq commented on Jun 11, 2013

    @eteq
    MemberAuthor

    @iguananaut - so what needs to be imporved on from #1116 before this can be closed? Is the main thing figuring out how to auto-generate the grammars instead of having them in the source tree?

  17. embray commented on Jun 28, 2013

    @embray
    Member

    I believe that was it, but it's a huge hassle and I'm not inclined to prioritize that right now. I think there's some discussion going on in #1202 about making the code compatible across Python 2/3 which would make things a lot easier though.

  18. mdboom commented on Sep 20, 2013

    @mdboom
    Contributor

    So, this whole way that PLY generates its files is annoying, and I think we're keeping this issue open to address that at some point. But the title of the issue is no longer really true, thanks to #1116. Renaming issue.

  19. modified the milestones: Future, v0.4.0 on May 3, 2014
  20. bsipocz commented on Dec 2, 2016

    @bsipocz
    Member

    @eteq - I was totally new to the parsing tables, but with ~10mins of digging around I could figure out how to update them along with the updating the ply library. Since we only need to do this once in every ~2 years, probably this issue can be close now?

  21. added
    Close?Tell stale bot that this issue/PR is stale
    on Dec 2, 2016
  22. bsipocz commented on Feb 9, 2017

    @bsipocz
    Member

    Exercising my newly minted rights, I'm closing this as an issue that will probably be never addressed. As a temp solution the files got included in the repo, and as I said in the previous comment, figuring out how that works is not that difficult.

    Please reopen if you think we need another solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClose?Tell stale bot that this issue/PR is staleinstallation

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions