Skip to content
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

Move grammar into py file #169

Closed
wants to merge 1 commit into from
Closed

Conversation

mrob95
Copy link
Member

@mrob95 mrob95 commented Nov 17, 2019

There have been a couple of reports of the same error (in the chat and here) loading the lark grammar from a text file.

  File "C:\Python27\lib\site-packages\lark_parser-0.7.8-py2.7.egg\lark\lark.py", line 284, in open
    with open(grammar_filename, encoding='utf8') as f:
IOError: [Errno 2] No such file or directory: 'C:\\Python27\\lib\\site-packages\\dragonfly2-0.18.0-py2.7.egg\\dragonfly\\parsing\\grammar.lark'

I'm slightly perplexed by this, and you may have a better idea of what is causing it or how to fix it than I do. Is the pip install process failing to pick up files which are not .py?

If you don't have a nice fix, then this should work. Having what is essentially data defined inside a Python file isn't ideal but it at least fixes the issue for now.

@LexiconCode
Copy link
Member

LexiconCode commented Nov 17, 2019

Oh you'll need to include non python files (relative path) in a manifest.in for pip to include them in the package. Setup.py will need to be tweaked to use the manifest.in

Ref: https://python-packaging.readthedocs.io/en/latest/non-code-files.html
Example: https://github.com/dictation-toolbox/Caster/blob/master/MANIFEST.in

@drmfinlay
Copy link
Member

I can't remember why this wasn't merged, but it should have been. We define plenty of data in Python files and this grammar is only used once in parser.py.

drmfinlay added a commit that referenced this pull request Jun 15, 2021
Re: #169, #170.

This grammar has been moved from the parsing/grammar.lark file,
which has now been removed.  The grammar is used internally for
parsing Compound element specifications efficiently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants