Re: m4p: an implementation of GNU m4 in Python
Nikolaos Chatzikonstantinou <[email protected]> Sat, 10 May 2025 16:45:26 -0400
| Newsgroups | gmane.comp.gnu.m4.general,gmane.comp.sysutils.automake.general |
|---|---|
| Message-ID | <CAAQmekdOkAWeM_xS2RaUhk-f8RvjXWLEct-VDrGTMeBPxKx-2A@mail.gmail.com> |
--00000000000041f3150634ce2abb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 10, 2025, 4:43=E2=80=AFPM Nikolaos Chatzikonstantinou < [email protected]> wrote: > On Sat, May 10, 2025, 4:35=E2=80=AFPM Eric Blake <[email protected]> wrot= e: > >> On Fri, May 09, 2025 at 04:33:44PM -0400, Nikolaos Chatzikonstantinou >> wrote: >> > Hello lists, >> > >> > I rewrote GNU m4 in Python. Long story short, I wanted to learn m4 to >> > fix some issues I had with GNU Guile and Autotools, and after >> > realizing m4 1.4 is ~8000 lines of code and reading e.g. >> > <https://www.owlfolio.org/development/autoconf-swot/> which claims >> > "Feature gaps in GNU M4 hold back development of Autoconf." I thought >> > I'd rewrite it in Rust. (It turned out to be more beneficial to >> > rewrite in Python due to faster prototyping for the time being.) >> > Eventually I plan to get back to my original purpose of fixing the >> > integration of GNU Guile and Autotools. >> > >> > You can find the project home page here, >> > <https://codeberg.org/annoyingusername/m4p> and you can install with >> > pip via `pip install m4p`. >> >> I've checked out the repository, but the README.txt was very sparse at >> the command line I should use to build and install the binary into any >> place where I can quickly use it. I'd rather run it from git than >> from a pip checkout (so that I can experiment with patching your code >> and instantly testing those results, rather than having to wait for >> the next release to land on pip). >> >> My initial attempt, 'python m4p', fails: >> >> $ python m4p >> /usr/bin/python: can't find '__main__' module in '/home/eblake/m4p/m4p' >> >> and this also fails: >> >> $ python m4p/main.py >> /home/eblake/m4p/m4p/main.py:18: DeprecationWarning: pkg_resources is >> deprecated as an API. See >> https://setuptools.pypa.io/en/latest/pkg_resources.html >> import pkg_resources >> Traceback (most recent call last): >> File "/home/eblake/m4p/m4p/main.py", line 20, in <module> >> from m4p.stream import Stream >> ModuleNotFoundError: No module named 'm4p' >> >> Maybe it's my naivete with python, but unless I can figure out how to >> run your code, I can't compare it against the C version to spot out >> where you are still incomplete in your implementation. >> > > Try this in the source dir (one time only): > > python3 -m venv .venv > source .venv/bin/activate > pip install -U pip setuptools wheel > pip install -e .[tests] > > Then anytime you want to try the software navigate to the source director= y > and do: > > source .venv/bin/activate > > To activate the environment and use "m4p" directly as a command. Any > changes you make to the source code should be reflected in that m4p scrip= t. > And I forgot that you can run the tests with pytest And select a particular test with pytest -k define E.g. picks tests/resources/define.txt > --00000000000041f3150634ce2abb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><br><br><div class=3D"gmail_quote gmail_quote_container" = dir=3D"auto"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, May 10, 2025, 4:= 43=E2=80=AFPM Nikolaos Chatzikonstantinou <<a href=3D"mailto:nchatz314@g= mail.com">[email protected]</a>> wrote:<br></div><blockquote class=3D"= gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-= left:1ex"><div dir=3D"auto"><div><div class=3D"gmail_quote"><div dir=3D"ltr= " class=3D"gmail_attr">On Sat, May 10, 2025, 4:35=E2=80=AFPM Eric Blake <= ;<a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"noreferrer">= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote"= style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On= Fri, May 09, 2025 at 04:33:44PM -0400, Nikolaos Chatzikonstantinou wrote:<= br> > Hello lists,<br> > <br> > I rewrote GNU m4 in Python. Long story short, I wanted to learn m4 to<= br> > fix some issues I had with GNU Guile and Autotools, and after<br> > realizing m4 1.4 is ~8000 lines of code and reading e.g.<br> > <<a href=3D"https://www.owlfolio.org/development/autoconf-swot/" re= l=3D"noreferrer noreferrer noreferrer" target=3D"_blank">https://www.owlfol= io.org/development/autoconf-swot/</a>> which claims<br> > "Feature gaps in GNU M4 hold back development of Autoconf." = I thought<br> > I'd rewrite it in Rust. (It turned out to be more beneficial to<br= > > rewrite in Python due to faster prototyping for the time being.)<br> > Eventually I plan to get back to my original purpose of fixing the<br> > integration of GNU Guile and Autotools.<br> > <br> > You can find the project home page here,<br> > <<a href=3D"https://codeberg.org/annoyingusername/m4p" rel=3D"noref= errer noreferrer noreferrer" target=3D"_blank">https://codeberg.org/annoyin= gusername/m4p</a>> and you can install with<br> > pip via `pip install m4p`.<br> <br> I've checked out the repository, but the README.txt was very sparse at<= br> the command line I should use to build and install the binary into any<br> place where I can quickly use it.=C2=A0 I'd rather run it from git than= <br> from a pip checkout (so that I can experiment with patching your code<br> and instantly testing those results, rather than having to wait for<br> the next release to land on pip).<br> <br> My initial attempt, 'python m4p', fails:<br> <br> $ python m4p<br> /usr/bin/python: can't find '__main__' module in '/home/ebl= ake/m4p/m4p'<br> <br> and this also fails:<br> <br> $ python m4p/main.py <br> /home/eblake/m4p/m4p/main.py:18: DeprecationWarning: pkg_resources is depre= cated as an API. See <a href=3D"https://setuptools.pypa.io/en/latest/pkg_re= sources.html" rel=3D"noreferrer noreferrer noreferrer" target=3D"_blank">ht= tps://setuptools.pypa.io/en/latest/pkg_resources.html</a><br> =C2=A0 import pkg_resources<br> Traceback (most recent call last):<br> =C2=A0 File "/home/eblake/m4p/m4p/main.py", line 20, in <modul= e><br> =C2=A0 =C2=A0 from m4p.stream import Stream<br> ModuleNotFoundError: No module named 'm4p'<br> <br> Maybe it's my naivete with python, but unless I can figure out how to<b= r> run your code, I can't compare it against the C version to spot out<br> where you are still incomplete in your implementation.<br></blockquote></di= v></div><div dir=3D"auto"><br></div><div dir=3D"auto">Try this in the sourc= e dir (one time only):</div><div dir=3D"auto"><br></div><div dir=3D"auto">p= ython3 -m venv .venv</div><div dir=3D"auto">source .venv/bin/activate</div>= <div dir=3D"auto">pip install -U pip setuptools wheel</div><div dir=3D"auto= ">pip install -e .[tests]</div><div dir=3D"auto"><br></div><div dir=3D"auto= ">Then anytime you want to try the software navigate to the source director= y and do:</div><div dir=3D"auto"><br></div><div dir=3D"auto"><div dir=3D"au= to">source .venv/bin/activate</div><br></div><div dir=3D"auto">To activate = the environment and use "m4p" directly as a command. Any changes = you make to the source code should be reflected in that m4p script.</div><d= iv dir=3D"auto"></div></div></blockquote></div><div dir=3D"auto"><br></div>= <div dir=3D"auto">And I forgot that you can run the tests with</div><div di= r=3D"auto"><br></div><div dir=3D"auto">pytest</div><div dir=3D"auto"><br></= div><div dir=3D"auto">And select a particular test with</div><div dir=3D"au= to"><br></div><div dir=3D"auto">pytest -k define</div><div dir=3D"auto"><br= ></div><div dir=3D"auto">E.g. picks tests/resources/define.txt</div><div cl= ass=3D"gmail_quote gmail_quote_container" dir=3D"auto"><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"><div dir=3D"auto"><div dir=3D"auto"><div class=3D"gmail_quote"><= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex"> </blockquote></div></div></div> </blockquote></div></div> --00000000000041f3150634ce2abb--