Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
PR #1792: update bundled Lark
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaudill authored Jan 18, 2024
1 parent 07f5a45 commit 3a1ba2e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
16 changes: 13 additions & 3 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

set -e
lark_version=0.11.3
lark_version=1.1.9

while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -70,9 +70,14 @@ rm -Rf Makefile.in \
bin/config.h.in \
build-aux \
configure
# Remove Lark, but only if requested.
# Remove Lark if requested or the installed version does not match.
lark_found=$( shopt -s nullglob; \
echo lib/lark*.dist-info | sed -E 's/^.*-([0-9.]+)\..*$/\1/' )
if [[ $lark_found && $lark_found != "$lark_version" ]]; then
lark_shovel=yes
fi
if [[ $lark_shovel ]]; then
rm -Rfv lib/lark lib/lark-stubs lib/lark*.dist-info lib/lark*.egg-info
rm -Rf lib/lark lib/lark-stubs lib/lark*.dist-info lib/lark*.egg-info
fi

# Create configure and friends.
Expand All @@ -91,6 +96,11 @@ if [[ -z $clean ]]; then
# Also remove Lark’s installer stuff.
rm lib/lark/__pyinstaller/*.py
rmdir lib/lark/__pyinstaller
# Some versions of pip install this file, while others don’t [1]. We
# don’t care about it, so remove it to avoid Make errors if it’s
# listed in Makefile.am and then an older pip is used to build.
# [1]: https://github.com/pypa/pip/pull/8026
rm -f lib/lark-${lark_version}.dist-info/REQUESTED
fi
if [[ -e lib/lark \
&& ! -e lib/lark-${lark_version}.dist-info/INSTALLER ]]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/ch-test
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ if [[ ! -f ${ch_base}/VERSION ]]; then
else
# build dir
CHTEST_INSTALLED=
if [[ -d ${ch_base}/.git ]]; then
if [[ -e ${ch_base}/.git ]]; then
CHTEST_GITWD=yes
else
CHTEST_GITWD=
Expand Down
4 changes: 2 additions & 2 deletions doc/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1574,11 +1574,11 @@ Updating bundled Lark parser
----------------------------

In order to change the version of the bundled lark parser you must modify
multiple files. To find them, e.g. for version 0.11.3 (the regex is hairy to
multiple files. To find them, e.g. for version 1.1.9 (the regex is hairy to
catch both dot notation and tuples, but not the list of filenames in
:code:`lib/Makefile.am`)::

$ misc/grep -E '0(\.|, )11(\.|, )3($|\s|\))'
$ misc/grep -E '1(\.|, )1(\.|, )9($|\s|\))'

What to do in each location should either be obvious or commented.

Expand Down
34 changes: 13 additions & 21 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,29 @@ mylib_DATA = contributors.bash \
version.sh \
version.txt

# Bundled Lark (currently version 0.11.3); Automake does not support wildcards
# Bundled Lark (currently version 1.1.9); Automake does not support wildcards
# [1], so list the files. Note it's version-specific. Hopefully if a new
# version of Lark adds a file and we omit it here by mistake, the tests will
# catch it. To get this list:
#
# $ (cd lib && find lark lark-stubs lark-*.dist-info -xtype f) | LC_ALL=C sort | sed -E 's/$/ \\/'
# $ (cd lib && find lark lark-*.dist-info -xtype f) | LC_ALL=C sort | sed -E 's/$/ \\/'
#
# Then, copy-n-paste & remove the last backslash. PROOFREAD YOUR DIFF!!!

LARK = \
lark-0.11.3.dist-info/INSTALLER \
lark-0.11.3.dist-info/LICENSE \
lark-0.11.3.dist-info/METADATA \
lark-0.11.3.dist-info/RECORD \
lark-0.11.3.dist-info/WHEEL \
lark-0.11.3.dist-info/entry_points.txt \
lark-0.11.3.dist-info/top_level.txt \
lark-stubs/__init__.pyi \
lark-stubs/ast_utils.pyi \
lark-stubs/exceptions.pyi \
lark-stubs/grammar.pyi \
lark-stubs/indenter.pyi \
lark-stubs/lark.pyi \
lark-stubs/lexer.pyi \
lark-stubs/load_grammar.pyi \
lark-stubs/reconstruct.pyi \
lark-stubs/tree.pyi \
lark-stubs/visitors.pyi \
lark-1.1.9.dist-info/INSTALLER \
lark-1.1.9.dist-info/LICENSE \
lark-1.1.9.dist-info/METADATA \
lark-1.1.9.dist-info/RECORD \
lark-1.1.9.dist-info/WHEEL \
lark-1.1.9.dist-info/entry_points.txt \
lark-1.1.9.dist-info/top_level.txt \
lark/__init__.py \
lark/ast_utils.py \
lark/common.py \
lark/exceptions.py \
lark/grammar.py \
lark/grammars/__init__.py \
lark/grammars/common.lark \
lark/grammars/lark.lark \
lark/grammars/python.lark \
Expand All @@ -73,15 +63,17 @@ lark/parsers/grammar_analysis.py \
lark/parsers/lalr_analysis.py \
lark/parsers/lalr_interactive_parser.py \
lark/parsers/lalr_parser.py \
lark/parsers/lalr_puppet.py \
lark/parsers/lalr_parser_state.py \
lark/parsers/xearley.py \
lark/py.typed \
lark/reconstruct.py \
lark/tools/__init__.py \
lark/tools/nearley.py \
lark/tools/serialize.py \
lark/tools/standalone.py \
lark/tree.py \
lark/tree_matcher.py \
lark/tree_templates.py \
lark/utils.py \
lark/visitors.py
if ENABLE_LARK
Expand Down
4 changes: 2 additions & 2 deletions lib/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

## Imports not in standard library ##

# See charliecloud.py for the messy import of this.
# See image.py for the messy import of this.
lark = im.lark


Expand Down Expand Up @@ -1228,7 +1228,7 @@ class Rsync_G(Copy):
def __init__(self, *args):
super().__init__(*args)
self.from_ = None # not supported yet
line_no = self.tree.line
line_no = self.tree.meta.line
st = self.tree.child("option_plus")
self.plus_option = "l" if st is None else st.terminal("OPTION_LETTER")
options_done = False
Expand Down
5 changes: 2 additions & 3 deletions packaging/fedora/charliecloud.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Requires: %{name}
Requires: python3
Requires: python%{python3_pkgversion}-lark-parser
Requires: python%{python3_pkgversion}-requests
Provides: bundled(python%{python3_pkgversion}-lark-parser) = 0.11.3
Provides: bundled(python%{python3_pkgversion}-lark-parser) = 1.1.9

%description builder
This package provides ch-image, Charliecloud's completely unprivileged container
Expand Down Expand Up @@ -151,8 +151,7 @@ ln -s "${sphinxdir}/js" %{buildroot}%{_pkgdocdir}/html/_static/js
%{_prefix}/lib/%{name}/force.py
%{_prefix}/lib/%{name}/image.py
%{_prefix}/lib/%{name}/lark
%{_prefix}/lib/%{name}/lark-0.11.3.dist-info
%{_prefix}/lib/%{name}/lark-stubs
%{_prefix}/lib/%{name}/lark-1.1.9.dist-info
%{_prefix}/lib/%{name}/misc.py
%{_prefix}/lib/%{name}/pull.py
%{_prefix}/lib/%{name}/push.py
Expand Down
2 changes: 1 addition & 1 deletion packaging/fedora/upstream.spec
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ln -s "${sphinxdir}/js" %{buildroot}%{_pkgdocdir}/html/_static/js
%{_prefix}/lib/%{name}/charliecloud.py
%{_prefix}/lib/%{name}/fakeroot.py
%{_prefix}/lib/%{name}/lark
%{_prefix}/lib/%{name}/lark-0.11.3.dist-info
%{_prefix}/lib/%{name}/lark-1.1.8.dist-info
%{_prefix}/lib/%{name}/lark-stubs
%{_prefix}/lib/%{name}/misc.py
%{_prefix}/lib/%{name}/pull.py
Expand Down

0 comments on commit 3a1ba2e

Please sign in to comment.