On Sat, May 10, 2025, 4:43 PM Nikolaos Chatzikonstantinou < nchatz...@gmail.com> wrote:
> On Sat, May 10, 2025, 4:35 PM Eric Blake <ebl...@redhat.com> wrote: > >> 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 directory > 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 script. > 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 >