Skip to main content

m4cmpy

CI PyPI

The M4 Circuit Macros (M4CM) Python automation package simplifies to process to create standalone EPS, PDF, PNG, JPG and SVG pictures from Circuit Macros source, see also peter.randewijk.dk/m4cmpy for examples.

Version 4 needs only Python and a TeX distribution (MiKTeX or TeX Live): GNU m4, dpic and ImageMagick are no longer required.

Package Replaces Role
pym4 GNU m4 m4 → pic
pppic dpic -p pic → PSTricks
m4cmpy m4cm.py 3.3 m4 → PDF / PNG / JPG / SVG / EPS

Install

pip install m4cmpy
m4cm --get-cm

m4cm --get-cm downloads the latest Circuit Macros from CTAN into your user cache folder. Alternatively set M4PATH, pass -I DIR, or rely on the copy in your TeX tree (found with kpsewhich libcct.m4).

The TeX tools come from MiKTeX or TeX Live: latex, dvips, Ghostscript (mgs in MiKTeX, gs elsewhere), epstopdf for PDF and dvisvgm for SVG. MiKTeX does not have to be on PATH; use --tex-bin DIR for other locations.

Use

m4cm -p -n -s ex0.m4cm         # PDF, PNG and SVG (plus EPS)
m4cm -p -d *.m4cm              # PDF only, for every .m4cm file in the folder
m4cm -n -r 192 -o web ex0.m4cm # 192 dpi PNG in the folder "web"
Option Meaning
-e EPS (always made, default)
-p / -n / -j / -s PDF / PNG (transparent) / JPG / SVG
--svg-fonts SVG with embedded WOFF2 fonts instead of outlines
-d delete the EPS afterwards
-r DPI PNG/JPG resolution (default 600)
-b L B R T bounding-box offset in points (default 1 1 1 1)
-a TEXT append TEXT to the output file names
-o DIR output folder
-t FILE LaTeX template (default default.ltx)
-I DIR extra m4 include folder, e.g. for your own macro libraries
-q / -Q quiet / silent

The LaTeX template is looked up in the current folder, then next to the input; without one, a built-in template is used. Templates must contain a line with %dpic_pstricks_output_here%; see Examples/default.ltx.

Repository

Folder Contents
src/m4cmpy the m4cm command
tests unit, toolchain and end-to-end tests: python -m unittest discover -s tests -v
Examples example .m4cm files and template
Sansserif Math LaTeX Style Files sansserifmath.sty, used by the example template
Syntax Highlighting VS Code (.vsix), Notepad++, Kate and Programmer's Notepad definitions
Additional Scripts animation helper, and m4cm_defines.py, which regenerates the syntax highlighting from a Circuit Macros release
legacy/m4cm.py the classic script (version 3.3), which still uses m4, dpic and ImageMagick

CI runs the tests on Windows, macOS and Linux against the latest pym4 and pppic, and builds the example with TeX Live (the figures are kept as a build artifact).

Licence

GPL-3.0-or-later; see LICENSE. Circuit Macros and dpic are by J. D. Aplevich.

Metadata

Release files for m4cmpy 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for m4cmpy 4.0.1
File Size Uploaded Provenance Actions
m4cmpy-4.0.1.tar.gz 27.2 kB With provenance Details for m4cmpy-4.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for m4cmpy 4.0.1
File Interpreter ABI Platform Actions
m4cmpy-4.0.1-py3-none-any.whl Python 3 none any Details for m4cmpy-4.0.1-py3-none-any.whl

Total release size: 50.8 kB

Release files / m4cmpy-4.0.1.tar.gz

Download URL m4cmpy-4.0.1.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f1cfaba5e6f1010dc271bcdcdf6b951cb68672a760bbe2c753fcd64a6ff9688
BLAKE2b-256 checksum
How to use checksums
f09102ad76bd5518b505d8574640c215f38311f87da7983b7c76550dd2b7342d
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 Nov 4, 2026.

Transparency log

Release files / m4cmpy-4.0.1-py3-none-any.whl

Download URL m4cmpy-4.0.1-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2cc52eb6662176800478c44197d238ee8ed62bb81fa4fa4c21b5c63ee775ae47
BLAKE2b-256 checksum
How to use checksums
5e0264b7adc83d7b490ebc012afa42c67c9b2b6dbb01b9b66720b9863601e980
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 Nov 4, 2026.

Transparency log

Security for m4cmpy 4.0.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for m4cmpy-4.0.1.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 Nov 4, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page