Skip to main content

m4cmpy

CI PyPI

M4 Circuit Macros Python automation script to create standalone PDF, PNG, JPG, SVG and EPS pictures with ease (see m4cmpy.wordpress.com).

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 My 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
My Examples example .m4cm files and template
My LaTeX Style Files sansserifmath.sty, used by the example template
Syntax Highlighting Notepad++, Kate and Programmer's Notepad definitions
Additional Scripts animation and syntax-definition helpers
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.0

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.0
File Size Uploaded Provenance
m4cmpy-4.0.0.tar.gz 26.8 kB With provenance Details

Built distribution (wheel)

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

Total release size: 50.2 kB

Release files / m4cmpy-4.0.0.tar.gz

Download URL m4cmpy-4.0.0.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
653d62fe14665db842a3a97affc4ccd159f43b888bb7daed93900ebd5511453f
BLAKE2b-256 checksum
How to use checksums
38257575662e5faaacb060798e87a96cd4074c28255da778c369abf9b1e9c01e
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 log

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

Download URL m4cmpy-4.0.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3577ee290450365b24731e95cc8abf537a4c50e25f15dd43efb456cfbf51417b
BLAKE2b-256 checksum
How to use checksums
3c2063f4865a3641067188e1214bb9fbf62ae506701e0e33d106f79b28852a09
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 log

Security for m4cmpy 4.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.

Select from 2 files

Attestation for m4cmpy-4.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 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.0 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