matplotlib package for Python 3.12?

Falk Tannhäuser via Cygwin <[email protected]>
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
Cygwin provides python3x-matplotlib packages for Python 3.6 to 3.9, but 
not for Python 3.12.
I was able to build and install matplotlib 3.10.8 (tested using attached 
Python script)
from source using pip3.12 after applying a small patch to the build 
script (see attached Bash script)
and installing the most recent Cygwin packages python312-tkinter and 
tcl-tk-devel
(not sure if both are needed).
It would be very convenient to have a Cygwin package 
python312-matplotlib, but I'm not knowledgable enough
to generate such a package myself. Are there any plans to provide such a 
package?
Falk


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
install_matplotlib_on_cygwin.sh (text/plain, 1.9 KB)
#!/usr/bin/bash
# This script builds and installs matplotlib from source on Windows using Cygwin.
# Tested with: Cygwin 3.6.6, g++ 13.4.0, Python 3.12.12, pip 26.0.1, matplotlib 3.10.8
# It assumes that Python 3.12 and the matching pip are already installed and available in the PATH.
# It also assumes that the user has downloaded the matplotlib source archive and placed it in his Downloads folder.
# The script applies a patch to the meson.build file to disable LTO and use gnu++17, which is necessary for compatibility with the current Cygwin toolchain.
# Without this patch (i.e. when simply calling 'pip3 install matplotlib'), the build would fail with the following errors:
# - Compilation using 'c++17' without GNU extensions: missing typedef for 'u_int' and missing 'strdup()' function
# - Linking using LTO: "cannot export XXX: symbol wrong type (4 vs 3)" for many symbols corresponding to C++ lambda functions
# TODO: Check if it is possible to keep LTO enabled using other linker flags (e.g. -fno-use-linker-plugin ???)
set -euo pipefail
uname -a
g++ --version
python --version
pip3 --version
download_dir=$(cygpath "${USERPROFILE}")/Downloads
mpl_archive=matplotlib-3.10.8.tar.gz
if [ ! -f ${download_dir}/${mpl_archive} ]; then
    echo "Please download ${mpl_archive} from https://pypi.org/project/matplotlib/#files and place it in ${download_dir}" >&2
    exit 1
fi
build_dir=/tmp/$(basename ${mpl_archive} .tar.gz)
if [ ! -d ${build_dir} ]; then
    tar xf ${download_dir}/${mpl_archive} -C /tmp
fi
cd ${build_dir}
patch <<EOF
--- meson.build~        2025-11-13 03:07:31.000000000 +0100
+++ meson.build 2026-02-12 16:09:08.092178800 +0100
@@ -25,8 +25,8 @@
   ],
   meson_version: '>=1.1.0',
   default_options: [
-    'b_lto=true',
-    'cpp_std=c++17',
+    'b_lto=false',
+    'cpp_std=gnu++17',
     'auto_features=disabled',  # Force FreeType to avoid extra dependencies.
   ],
 )
EOF
pip3 install -U .
test_matplotlib.py (text/plain, 891 B)
#!/usr/bin/env python3
# NOTE: This script is intended to be run in a Cygwin environment on Windows,
# where matplotlib has been installed using the provided bash script.
# It demonstrates a simple plot of sine and cosine functions using matplotlib.
# Cygwin-X / XWin Server must be installed and running and the DISPLAY environment
# variable shall be properly set (":0" should work on most systems) to display the plot.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np

print(f'Found: {matplotlib.__version__=} ; {np.__version__=}')
x = np.linspace(0, 10*np.pi, 1000)
plt.plot(x, np.sin(x), x, np.cos(x))
plt.grid()

try:
    import pandas as pd
    print(f'Found: {pd.__version__=} ; {pd.options.plotting.backend=}')
    fig = pd.DataFrame(np.random.random_sample((100, 2)), columns=['A', 'B']).hist()
except ImportError:
    print('pandas not installed')

plt.show()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.