pym4
A GNU m4 1.4 compatible macro processor written in pure Python: no compiler,
no m4.exe, no dependencies.
pym4 follows GNU m4's expansion model (rescanning, argument collection, quoting,
comments, diversions) and implements the GNU builtins, including eval,
regexp/patsubst with GNU regex semantics, translit, format, include
and M4PATH. The shell builtins syscmd and esyscmd are disabled on purpose.
It was written to run Circuit Macros without installing GNU m4, and is one part of a pure-Python toolchain:
| Package | Replaces | Role |
|---|---|---|
| pym4 | GNU m4 | m4 → pic |
| pppic | dpic -p | pic → PSTricks |
| m4cmpy | m4cm.py | m4 → PDF / PNG / JPG / SVG / EPS |
Install
pip install pym4
Use
Command line (a subset of GNU m4's options):
pym4 [-I DIR] [-D NAME[=VALUE]] [-U NAME] [-Q] [-o OUTPUT] [FILE ...]
pym4 -I path/to/circuit_macros examples/circuit.m4
Python:
from pym4 import M4Lite, expand
print(expand("define(`greet', `Hello, $1!')greet(`world')"))
m4 = M4Lite(include_dirs=["path/to/circuit_macros"])
pic = m4.expand(open("circuit.m4").read(), "circuit.m4")
Tests
python -m unittest discover -s tests -v
CI also checks that pym4 gives the same output as GNU m4 for the files in examples, including a Circuit Macros diagram.
Licence
GPL-3.0-or-later; see LICENSE. pym4 reproduces the behaviour of GNU m4, Copyright (C) Free Software Foundation, Inc.
Metadata
Release files for pym4 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pym4-1.0.0.tar.gz | 29.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pym4-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.8 kB
Release files / pym4-1.0.0.tar.gz
| Download URL | pym4-1.0.0.tar.gz |
|---|---|
| Size | 29.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8022c100be4041855352b5c6a56892c058ad5f6a766d90e45124392610d30001
|
|
BLAKE2b-256 checksum How to use checksums |
0ef3fab860e813a177c5e084ef72066a7df676fddc1d86ba2a66c6a6ffe8602a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / pym4-1.0.0-py3-none-any.whl
| Download URL | pym4-1.0.0-py3-none-any.whl |
|---|---|
| Size | 27.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c95459d783f9cb29112d31bdf2f156a93ec21e68efafef2384b30df125a87da
|
|
BLAKE2b-256 checksum How to use checksums |
8f6910e1add7244d23c89e0ea2ed968ad3ccb12bbca2ac2f96a2a3ea4a8cecda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for pym4 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pym4-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.