Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ef56df

Browse files
authored
Merge pull request #26621 from QuLogic/meson
Port build system to Meson
2 parents 21ce592 + 01c1ff6 commit 5ef56df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2880
-1366
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ install:
7070
test_script:
7171
# Now build the thing..
7272
- set LINK=/LIBPATH:%cd%\lib
73-
- pip install -ve .
73+
- pip install -v --no-build-isolation --config-settings=setup-args="--vsenv" --editable .[dev]
7474
# this should show no freetype dll...
7575
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
7676
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'

.circleci/config.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ commands:
5555
graphviz \
5656
inkscape \
5757
lmodern \
58+
ninja-build \
5859
optipng \
5960
texlive-fonts-recommended \
6061
texlive-latex-base \
@@ -97,6 +98,7 @@ commands:
9798
- run:
9899
name: Install Python dependencies
99100
command: |
101+
python -m pip install --user meson-python pybind11
100102
python -m pip install --user \
101103
numpy<< parameters.numpy_version >> \
102104
-r requirements/doc/doc-requirements.txt
@@ -114,15 +116,13 @@ commands:
114116
version=${version#v}
115117
python -m pip install matplotlib==${version}
116118
else
117-
python -m pip install --user -ve .
119+
python -m pip install --user --verbose \
120+
--no-build-isolation --editable .[dev]
118121
fi
119122
- save_cache:
120-
key: build-deps-1
123+
key: build-deps-2
121124
paths:
122-
# FreeType 2.6.1 tarball.
123-
- ~/.cache/matplotlib/0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014
124-
# Qhull 2020.2 tarball.
125-
- ~/.cache/matplotlib/b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e
125+
- subprojects/packagecache
126126

127127
doc-build:
128128
steps:
@@ -218,8 +218,8 @@ jobs:
218218
- fonts-install
219219
- pip-install
220220

221-
- mpl-install
222221
- doc-deps-install
222+
- mpl-install
223223

224224
- doc-build
225225
- doc-show-errors-warnings

.flake8

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ exclude =
3131
.eggs
3232

3333
per-file-ignores =
34-
setup.py: E402
35-
3634
lib/matplotlib/__init__.py: E402, F401
3735
lib/matplotlib/_animation_data.py: E501
3836
lib/matplotlib/_api/__init__.py: F401

.github/workflows/cibuildwheel.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,17 @@ jobs:
9191
runs-on: ${{ matrix.os }}
9292
env:
9393
CIBW_BEFORE_BUILD: >-
94-
pip install certifi numpy>=1.25 &&
94+
pip install numpy>=1.25 &&
9595
rm -rf {package}/build
9696
CIBW_BEFORE_BUILD_WINDOWS: >-
97-
pip install certifi delvewheel numpy>=1.25 &&
97+
pip install delvewheel numpy>=1.25 &&
9898
rm -rf {package}/build
9999
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
100100
delvewheel repair -w {dest_dir} {wheel}
101101
CIBW_AFTER_BUILD: >-
102102
twine check {wheel} &&
103103
python {package}/ci/check_wheel_licenses.py {wheel}
104+
CIBW_CONFIG_SETTINGS: setup-args="--vsenv"
104105
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
105106
CIBW_SKIP: "*-musllinux_aarch64"
106107
CIBW_TEST_COMMAND: >-
@@ -144,11 +145,11 @@ jobs:
144145
CIBW_ARCHS: ${{ matrix.cibw_archs }}
145146
# Remove this once NumPy with Python 3.12 wheels is not pre-release.
146147
CIBW_BEFORE_BUILD: >-
147-
pip install certifi "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" &&
148+
pip install "meson-python>=0.13.1" ninja "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" &&
148149
pip install --pre "numpy>=1.25" &&
149150
rm -rf {package}/build
150151
CIBW_BEFORE_BUILD_WINDOWS: >-
151-
pip install certifi delvewheel "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" &&
152+
pip install delvewheel "meson-python>=0.13.1" ninja "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" &&
152153
pip install --pre "numpy>=1.25" &&
153154
rm -rf {package}/build
154155
CIBW_ENVIRONMENT: PIP_NO_BUILD_ISOLATION=0

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
# dependencies so we don't need another copy here.
4242
# https://github.com/jazzband/pip-tools/pull/1681
4343
python -m pip install --upgrade \
44-
certifi contourpy cycler fonttools kiwisolver importlib_resources \
45-
numpy packaging pillow pyparsing python-dateutil setuptools-scm \
46-
pybind11
44+
build contourpy cycler fonttools kiwisolver \
45+
importlib_resources meson-python numpy packaging pillow pybind11 \
46+
pyparsing python-dateutil setuptools-scm
4747
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
4848
4949
- name: Initialize CodeQL
@@ -56,7 +56,7 @@ jobs:
5656
if: matrix.language == 'cpp'
5757
run: |
5858
mkdir ~/.cache/matplotlib
59-
$CODEQL_PYTHON setup.py build
59+
$CODEQL_PYTHON -m build
6060
6161
- name: Perform CodeQL Analysis
6262
uses: github/codeql-action/analyze@v2

.github/workflows/cygwin.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ jobs:
174174
- name: Install Python dependencies
175175
shell: bash.exe -eo pipefail -o igncr "{0}"
176176
run: |
177-
python -m pip install --upgrade pip 'setuptools<60' wheel
178-
python -m pip install kiwisolver 'numpy!=1.21.*' pillow importlib_resources
177+
python -m pip install --upgrade pip setuptools wheel
178+
python -m pip install kiwisolver 'numpy>=1.22,<1.26' pillow importlib_resources
179179
grep -v -F -e psutil requirements/testing/all.txt >requirements_test.txt
180180
python -m pip install meson-python pybind11
181181
export PATH="/usr/local/bin:$PATH"
@@ -203,20 +203,14 @@ jobs:
203203
AUTOCONF: /usr/bin/autoconf-2.69
204204
MAKEFLAGS: dw
205205
run: |
206+
export PATH="/usr/local/bin:$PATH"
206207
ccache -s
207208
git describe
208-
cat <<EOT >> mplsetup.cfg
209-
[rc_options]
210-
backend=Agg
211-
212-
[libs]
213-
system_freetype = False
214-
system_qhull = True
215-
EOT
216-
cat mplsetup.cfg
217209
# All dependencies must have been pre-installed, so that the minver
218210
# constraints are held.
219-
python -m pip install --no-deps -ve .
211+
python -m pip install --no-deps --no-build-isolation --verbose \
212+
--config-settings=setup-args="-DrcParams-backend=Agg" \
213+
--editable .[dev]
220214
221215
- name: Find DLLs to rebase
222216
shell: bash.exe -eo pipefail -o igncr "{0}"

.github/workflows/mypy-stubtest.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
pip3 install -r requirements/testing/mypy.txt \
2424
-r requirements/testing/all.txt
25-
pip3 install -e .
25+
pip3 install .
2626
2727
- name: Set up reviewdog
2828
run: |
@@ -38,6 +38,7 @@ jobs:
3838
run: |
3939
set -o pipefail
4040
MPLBACKEND=agg python tools/stubtest.py | \
41+
sed -e "s!$pythonLocation/lib/python3.9/site-packages!lib!g" | \
4142
reviewdog \
4243
-efm '%Eerror: %m' \
4344
-efm '%CStub: in file %f:%l' \

.github/workflows/tests.yml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
pyside2-ver: '==5.15.1' # oldest version with working Py3.9 wheel.
5757
pyside6-ver: '==6.0.0'
5858
delete-font-cache: true
59-
no-build-isolation: true
6059
- os: ubuntu-20.04
6160
python-version: 3.9
6261
extra-requirements: '-r requirements/testing/extra.txt'
@@ -81,7 +80,6 @@ jobs:
8180
python-version: '3.12-dev'
8281
pyside6-ver: '!=6.5.1'
8382
pre: true
84-
no-build-isolation: true
8583
- os: macos-latest
8684
python-version: 3.9
8785
# https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346
@@ -131,6 +129,7 @@ jobs:
131129
libxcb-render-util0 \
132130
libxcb-xinerama0 \
133131
lmodern \
132+
ninja-build \
134133
pkg-config \
135134
qtbase5-dev \
136135
texlive-fonts-recommended \
@@ -150,7 +149,7 @@ jobs:
150149
macOS)
151150
brew install ccache
152151
brew tap homebrew/cask-fonts
153-
brew install font-noto-sans-cjk gobject-introspection gtk4
152+
brew install font-noto-sans-cjk gobject-introspection gtk4 ninja
154153
;;
155154
esac
156155
@@ -205,17 +204,14 @@ jobs:
205204
fi
206205
207206
# Install dependencies from PyPI.
207+
# Preinstall build requirements to enable no-build-isolation builds.
208208
python -m pip install --upgrade $PRE \
209209
'contourpy>=1.0.1' cycler fonttools kiwisolver importlib_resources \
210210
numpy packaging pillow 'pyparsing!=3.1.0' python-dateutil setuptools-scm \
211+
'meson-python>=0.13.1' 'pybind11>=2.6' \
211212
-r requirements/testing/all.txt \
212213
${{ matrix.extra-requirements }}
213214
214-
# Preinstall pybind11 on no-build-isolation builds.
215-
if [[ "${{ matrix.no-build-isolation }}" == 'true' ]]; then
216-
python -m pip install 'pybind11>=2.6'
217-
fi
218-
219215
# Install optional dependencies from PyPI.
220216
# Sphinx is needed to run sphinxext tests
221217
python -m pip install --upgrade sphinx!=6.1.2
@@ -300,20 +296,9 @@ jobs:
300296
fi
301297
fi
302298
303-
cat <<EOT >> mplsetup.cfg
304-
[rc_options]
305-
backend=Agg
306-
EOT
307-
308-
cat mplsetup.cfg
309-
310-
if [[ "${{ matrix.no-build-isolation }}" == 'true' ]]; then
311-
# Minimum versions run does not use build isolation so that it
312-
# builds against the pre-installed minver dependencies.
313-
python -m pip install --no-deps --no-build-isolation -ve .
314-
else
315-
python -m pip install --no-deps -ve .
316-
fi
299+
python -m pip install --no-deps --no-build-isolation --verbose \
300+
--config-settings=setup-args="-DrcParams-backend=Agg" \
301+
--editable .[dev]
317302
318303
if [[ "${{ runner.os }}" != 'macOS' ]]; then
319304
unset CPPFLAGS

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
# Python files #
3131
################
32-
# setup.py working directory
32+
# meson-python working directory
3333
build
3434

35-
# setup.py dist directory
35+
# meson-python/build frontend dist directory
3636
dist
3737
# Egg metadata
3838
*.egg-info
@@ -41,9 +41,9 @@ dist
4141
pip-wheel-metadata/*
4242
# tox testing tool
4343
.tox
44-
mplsetup.cfg
45-
# generated by setuptools_scm
46-
lib/matplotlib/_version.py
44+
# build subproject files
45+
subprojects/*/
46+
!subprojects/packagefiles/
4747

4848
# OS generated files #
4949
######################

azure-pipelines.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ stages:
9696
cm-super \
9797
dvipng \
9898
ffmpeg \
99+
fonts-freefont-otf \
99100
fonts-noto-cjk \
100101
fonts-wqy-zenhei \
101102
gdb \
@@ -105,23 +106,24 @@ stages:
105106
libcairo2 \
106107
libgirepository-1.0-1 \
107108
lmodern \
108-
fonts-freefont-otf \
109+
ninja-build \
109110
poppler-utils \
110-
texlive-pictures \
111111
texlive-fonts-recommended \
112112
texlive-latex-base \
113113
texlive-latex-extra \
114114
texlive-latex-recommended \
115115
texlive-luatex \
116+
texlive-pictures \
116117
texlive-xetex
117118
;;
118119
darwin)
119120
brew install --cask xquartz
120-
brew install pkg-config ffmpeg imagemagick mplayer ccache
121+
brew install ccache ffmpeg imagemagick mplayer ninja pkg-config
121122
brew tap homebrew/cask-fonts
122123
brew install font-noto-sans-cjk-sc
123124
;;
124125
win32)
126+
choco install ninja
125127
;;
126128
*)
127129
exit 1
@@ -131,12 +133,15 @@ stages:
131133
132134
- bash: |
133135
python -m pip install --upgrade pip
136+
python -m pip install --upgrade meson-python pybind11
134137
python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt ||
135138
[[ "$PYTHON_VERSION" = 'Pre' ]]
136139
displayName: 'Install dependencies with pip'
137140
138141
- bash: |
139-
python -m pip install -ve . ||
142+
python -m pip install \
143+
--no-build-isolation --config-settings=setup-args="--vsenv" \
144+
--verbose --editable .[dev] ||
140145
[[ "$PYTHON_VERSION" = 'Pre' ]]
141146
displayName: "Install self"
142147
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Build system ported to Meson
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The build system of Matplotlib has been ported from setuptools to `meson-python
5+
<https://meson-python.readthedocs.io>`_ and `Meson <https://mesonbuild.com>`_.
6+
Consequently, there have been a few changes for development and packaging purposes.
7+
8+
1. Installation by ``pip`` of packages with ``pyproject.toml`` use `build isolation
9+
<https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#build-isolation>`_
10+
by default, which interferes with editable installation. Thus for developers using
11+
editable installs, it is now necessary to pass the ``--no-build-isolation`` flag to
12+
``pip install``. This means that all build-time requirements must be available in the
13+
environment for an editable install.
14+
2. Build configuration has moved from a custom :file:`mplsetup.cfg` (also configurable
15+
via ``MPLSETUP`` environment variable) to Meson options. These may be specified using
16+
`meson-python's build config settings
17+
<https://meson-python.readthedocs.io/en/stable/how-to-guides/config-settings.html>`_
18+
for ``setup-args``. See :file:`meson_options.txt` for all options. For example, a
19+
:file:`mplsetup.cfg` containing the following::
20+
21+
[rc_options]
22+
backend=Agg
23+
24+
[libs]
25+
system_qhull = True
26+
27+
may be replaced by passing the following arguments to ``pip``::
28+
29+
--config-settings=setup-args="-DrcParams-backend=Agg" \
30+
--config-settings=setup-args="-Dsystem-qhull=true"
31+
32+
Note that you must use ``pip`` >= 23.1 in order to pass more than one setting.
33+
3. Relatedly, Meson's `builtin options <https://mesonbuild.com/Builtin-options.html>`_
34+
are now used instead of custom options, e.g., the LTO option is now ``b_lto``.
35+
4. On Windows, Meson activates a Visual Studio environment automatically. However, it
36+
will not do so if another compiler is available. See `Meson's documentation
37+
<https://mesonbuild.com/Builtin-options.html#details-for-vsenv>`_ if you wish to
38+
change the priority of chosen compilers.
39+
5. Installation of test data was previously controlled by :file:`mplsetup.cfg`, but has
40+
now been moved to Meson's install tags. To install test data, add the ``tests``
41+
tag to the requested install (be sure to include the existing tags as below)::
42+
43+
--config-settings=install-args="--tags=data,python-runtime,runtime,tests"
44+
6. Checking typing stubs with ``stubtest`` does not work easily with editable install.
45+
For the time being, we suggest using a normal (non-editable) install if you wish to
46+
run ``stubtest``.

doc/devel/contribute.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ A brief overview of the workflow is as follows.
266266

267267
#. Install the local version of Matplotlib with::
268268

269-
python -m pip install -e .
269+
python -m pip install --no-build-isolation --editable .[dev]
270270

271271
See :ref:`installing_for_devs` for detailed instructions.
272272

@@ -476,9 +476,8 @@ take particular care when adding new API:
476476
New modules and files: installation
477477
-----------------------------------
478478

479-
* If you have added new files or directories, or reorganized existing
480-
ones, make sure the new files are included in the match patterns in
481-
in *package_data* in :file:`setupext.py`.
479+
* If you have added new files or directories, or reorganized existing ones, make sure the
480+
new files are included in the :file:`meson.build` in the corresponding directories.
482481
* New modules *may* be typed inline or using parallel stub file like existing modules.
483482

484483
C/C++ extensions

0 commit comments

Comments
 (0)