From 6665b26c72e2b1ab8d4a3844dc15751b74af5462 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 7 Sep 2022 18:36:07 +0200 Subject: [PATCH 1/8] Start transitioning to pyproject.toml --- pyproject.toml | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 80 +-------------------------------------------- 2 files changed, 89 insertions(+), 79 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4d9ccce2b290..423d6352ae8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,73 @@ +[project] +name = "matplotlib" +authors = [ + {email = "matplotlib-users@python.org"}, + {name = "John D. Hunter, Michael Droettboom"} +] +description = "Python plotting package" +readme = "README.md" +license = { file = "LICENSE/LICENSE" } +dynamic = ["version"] +classifiers=[ + "Development Status :: 5 - Production/Stable", + "Framework :: Matplotlib", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "License :: OSI Approved :: Python Software Foundation License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering :: Visualization", +] + +# When updating the list of dependencies, add an api_changes/development +# entry and also update the following places: +# - lib/matplotlib/__init__.py (matplotlib._check_versions()) +# - requirements/testing/minver.txt +# - doc/devel/dependencies.rst +# - .github/workflows/tests.yml +# - environment.yml +dependencies = [ + "contourpy >= 1.0.1", + "cycler >= 0.10", + "fonttools >= 4.22.0", + "kiwisolver >= 1.3.1", + "numpy >= 1.21", + "packaging >= 20.0", + "pillow >= 8", + "pyparsing >= 2.3.1", + "python-dateutil >= 2.7", + "setuptools >= 64", + "setuptools_scm >= 7", + "importlib-resources >= 3.2.0; python_version < '3.10'", +] +requires-python = ">=3.9" + +[project.optional-dependencies] +# Should be a copy of the build dependencies below. +dev = [ + "certifi>=2020.06.20", + "numpy>=1.25", + "pybind11>=2.6", + "setuptools>=64", + "setuptools_scm>=7", +] + +[project.urls] +"Homepage" = "https://matplotlib.org" +"Download" = "https://matplotlib.org/stable/users/installing/index.html" +"Documentation" = "https://matplotlib.org" +"Source Code" = "https://github.com/matplotlib/matplotlib" +"Bug Tracker" = "https://github.com/matplotlib/matplotlib/issues" +"Forum" = "https://discourse.matplotlib.org/" +"Donate" = "https://numfocus.org/donate-to-matplotlib" + [build-system] build-backend = "setuptools.build_meta" +# Also keep in sync with optional dependencies above. requires = [ "certifi>=2020.06.20", "numpy>=1.25", @@ -8,6 +76,26 @@ requires = [ "setuptools_scm>=7", ] +[tool.setuptools] +platforms = ["any"] +py-modules = ["pylab"] +license-files = ["LICENSE/*"] +namespace-packages = ["mpl_toolkits"] + +[tool.setuptools.packages.find] +where = ["lib"] +include = ["matplotlib*", "mpl_toolkits*"] +exclude = [ + "matplotlib.tests*", + "mpl_toolkits.axes_grid1.tests*", + "mpl_toolkits.axisartist.tests*", + "mpl_toolkits.mplot3d.tests*", +] +namespaces = true + +[tool.setuptools.exclude-package-data] +"*" = ["*.png", "*.svg"] + [tool.setuptools_scm] version_scheme = "release-branch-semver" local_scheme = "node-and-date" diff --git a/setup.py b/setup.py index 899021a83254..66698a3aed6c 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ import shutil import subprocess -from setuptools import setup, find_namespace_packages, Distribution, Extension +from setuptools import setup, Distribution, Extension import setuptools.command.build_ext import setuptools.command.build_py import setuptools.command.sdist @@ -277,89 +277,11 @@ def make_release_tree(self, base_dir, files): package_data[key] = list(set(val + package_data[key])) setup( # Finally, pass this all along to setuptools to do the heavy lifting. - name="matplotlib", - description="Python plotting package", - author="John D. Hunter, Michael Droettboom", - author_email="matplotlib-users@python.org", - url="https://matplotlib.org", - download_url="https://matplotlib.org/stable/users/installing/index.html", - project_urls={ - 'Documentation': 'https://matplotlib.org', - 'Source Code': 'https://github.com/matplotlib/matplotlib', - 'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues', - 'Forum': 'https://discourse.matplotlib.org/', - 'Donate': 'https://numfocus.org/donate-to-matplotlib' - }, - long_description=Path("README.md").read_text(encoding="utf-8"), - long_description_content_type="text/markdown", - license="PSF", - platforms="any", - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Framework :: Matplotlib', - 'Intended Audience :: Science/Research', - 'Intended Audience :: Education', - 'License :: OSI Approved :: Python Software Foundation License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Scientific/Engineering :: Visualization', - ], - - package_dir={"": "lib"}, - packages=find_namespace_packages( - where="lib", - exclude=["*baseline_images*", "*tinypages*", "*mpl-data*", "*web_backend*"], - ), - py_modules=["pylab"], # Dummy extension to trigger build_ext, which will swap it out with # real extensions that can depend on numpy for the build. ext_modules=[Extension("", [])], package_data=package_data, - python_requires='>={}'.format('.'.join(str(n) for n in py_min_version)), - # When updating the list of dependencies, add an api_changes/development - # entry and also update the following places: - # - lib/matplotlib/__init__.py (matplotlib._check_versions()) - # - requirements/testing/minver.txt - # - doc/devel/dependencies.rst - # - .github/workflows/tests.yml - # - environment.yml - install_requires=[ - "contourpy>=1.0.1", - "cycler>=0.10", - "fonttools>=4.22.0", - "kiwisolver>=1.3.1", - "numpy>=1.21", - "packaging>=20.0", - "pillow>=8", - "pyparsing>=2.3.1", - "python-dateutil>=2.7", - ] + ( - # Installing from a git checkout that is not producing a wheel. - # setuptools_scm warns with older setuptools, which turns into errors for our - # test suite. However setuptools_scm does not themselves pin the version of - # setuptools. - ["setuptools_scm>=7", "setuptools>=64"] if ( - Path(__file__).with_name(".git").exists() and - os.environ.get("CIBUILDWHEEL", "0") != "1" - ) else [] - ), - extras_require={ - ':python_version<"3.10"': [ - "importlib-resources>=3.2.0", - ], - }, - use_scm_version={ - "version_scheme": "release-branch-semver", - "local_scheme": "node-and-date", - "write_to": "lib/matplotlib/_version.py", - "parentdir_prefix_version": "matplotlib-", - "fallback_version": "0.0+UNKNOWN", - }, cmdclass={ "build_ext": BuildExtraLibraries, "build_py": BuildPy, From 044a5e50093a9572e72ca0a5aa2424f55d902aed Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 24 Aug 2023 03:28:10 -0400 Subject: [PATCH 2/8] BLD: Use Meson to build extensions --- .circleci/config.yml | 7 +- .gitignore | 3 + extern/agg24-svn/meson.build | 22 + extern/meson.build | 41 + extern/ttconv/meson.build | 14 + meson.build | 28 + meson_options.txt | 17 + src/_c_internal_utils.c | 6 + src/_tkagg.cpp | 7 + src/_ttconv.cpp | 2 +- src/meson.build | 191 ++++ src/tri/_tri.cpp | 10 +- subprojects/freetype-2.11.1.wrap | 7 + subprojects/freetype-2.6.1.wrap | 9 + .../freetype-2.6.1-meson/LICENSE.build | 19 + .../builds/unix/ftconfig.h.in | 498 ++++++++++ .../include/freetype/config/ftoption.h.in | 886 ++++++++++++++++++ .../freetype-2.6.1-meson/meson.build | 187 ++++ .../packagefiles/qhull-2020.2/meson.build | 31 + subprojects/qhull.wrap | 9 + 20 files changed, 1982 insertions(+), 12 deletions(-) create mode 100644 extern/agg24-svn/meson.build create mode 100644 extern/meson.build create mode 100644 extern/ttconv/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build create mode 100644 subprojects/freetype-2.11.1.wrap create mode 100644 subprojects/freetype-2.6.1.wrap create mode 100644 subprojects/packagefiles/freetype-2.6.1-meson/LICENSE.build create mode 100644 subprojects/packagefiles/freetype-2.6.1-meson/builds/unix/ftconfig.h.in create mode 100644 subprojects/packagefiles/freetype-2.6.1-meson/include/freetype/config/ftoption.h.in create mode 100644 subprojects/packagefiles/freetype-2.6.1-meson/meson.build create mode 100644 subprojects/packagefiles/qhull-2020.2/meson.build create mode 100644 subprojects/qhull.wrap diff --git a/.circleci/config.yml b/.circleci/config.yml index 60a1e8211e60..680798abe5fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,12 +117,9 @@ commands: python -m pip install --user -ve . fi - save_cache: - key: build-deps-1 + key: build-deps-2 paths: - # FreeType 2.6.1 tarball. - - ~/.cache/matplotlib/0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014 - # Qhull 2020.2 tarball. - - ~/.cache/matplotlib/b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e + - subprojects/packagecache doc-build: steps: diff --git a/.gitignore b/.gitignore index 9c6bb2263c99..a76efc1cd47a 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,9 @@ pip-wheel-metadata/* mplsetup.cfg # generated by setuptools_scm lib/matplotlib/_version.py +# build subproject files +subprojects/*/ +!subprojects/packagefiles/ # OS generated files # ###################### diff --git a/extern/agg24-svn/meson.build b/extern/agg24-svn/meson.build new file mode 100644 index 000000000000..a1c088423cb8 --- /dev/null +++ b/extern/agg24-svn/meson.build @@ -0,0 +1,22 @@ +# We need a patched Agg not available elsewhere, so always use the vendored +# version. + +agg_incdir = include_directories('include') + +agg_lib = static_library('agg', + 'src/agg_bezier_arc.cpp', + 'src/agg_curves.cpp', + 'src/agg_image_filters.cpp', + 'src/agg_trans_affine.cpp', + 'src/agg_vcgen_contour.cpp', + 'src/agg_vcgen_dash.cpp', + 'src/agg_vcgen_stroke.cpp', + 'src/agg_vpgen_segmentator.cpp', + include_directories : agg_incdir, + gnu_symbol_visibility: 'inlineshidden', +) + +agg_dep = declare_dependency( + include_directories: agg_incdir, + link_with: agg_lib, +) diff --git a/extern/meson.build b/extern/meson.build new file mode 100644 index 000000000000..af809ce2531d --- /dev/null +++ b/extern/meson.build @@ -0,0 +1,41 @@ +# Bundled code. +subdir('agg24-svn') +subdir('ttconv') + +# External code. + +# FreeType 2.3 has libtool version 9.11.3 as can be checked from the tarball. +# For FreeType>=2.4, there is a conversion table in docs/VERSIONS.txt in the +# FreeType source tree. +if get_option('system-freetype') + freetype_dep = dependency('freetype2', version: '>=9.11.3') +else + # This is the version of FreeType to use when building a local version. It + # must match the value in `lib/matplotlib.__init__.py`. Also update the docs + # in `docs/devel/dependencies.rst`. Bump the cache key in + # `.circleci/config.yml` when changing requirements. + TESTING_VERSION_OF_FREETYPE = '2.6.1' + if host_machine.system() == 'windows' and host_machine.cpu_family() == 'aarch64' + # Older versions of freetype are not supported for win/arm64 + # Matplotlib tests will not pass + LOCAL_FREETYPE_VERSION = '2.11.1' + else + LOCAL_FREETYPE_VERSION = TESTING_VERSION_OF_FREETYPE + endif + + freetype_proj = subproject( + f'freetype-@LOCAL_FREETYPE_VERSION@', + default_options: ['default_library=static']) + freetype_dep = freetype_proj.get_variable('freetype_dep') +endif + +if get_option('system-qhull') + qhull_dep = dependency('qhull_r', version: '>=8.0.2', required: false) + if not qhull_dep.found() + cc.check_header('libqhull_r/qhull_ra.h', required: true) + qhull_dep = cc.find_library('qhull_r') + endif +else + qhull_proj = subproject('qhull') + qhull_dep = qhull_proj.get_variable('qhull_dep') +endif diff --git a/extern/ttconv/meson.build b/extern/ttconv/meson.build new file mode 100644 index 000000000000..939eb3069c43 --- /dev/null +++ b/extern/ttconv/meson.build @@ -0,0 +1,14 @@ +ttconv_lib = static_library('ttconv', + 'pprdrv_tt2.cpp', + 'pprdrv_tt.cpp', + 'ttutil.cpp', + 'pprdrv.h', + 'truetype.h', + dependencies: [py3_dep], + gnu_symbol_visibility: 'inlineshidden', +) + +ttconv_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: ttconv_lib, +) diff --git a/meson.build b/meson.build new file mode 100644 index 000000000000..c294eea2a678 --- /dev/null +++ b/meson.build @@ -0,0 +1,28 @@ +project( + 'matplotlib', + 'c', 'cpp', + version: '3.9.0.dev0', + # qt_editor backend is MIT + # ResizeObserver at end of lib/matplotlib/backends/web_backend/js/mpl.js is CC0 + # Carlogo, STIX and Computer Modern is OFL + # DejaVu is Bitstream Vera and Public Domain + license: 'PSF-2.0 AND MIT AND CC0-1.0 AND OFL-1.1 AND Bitstream-Vera AND Public-Domain', + default_options: [ + 'b_lto=true', + 'cpp_std=c++11', + 'auto_features=disabled', # Force FreeType to avoid extra dependencies. + ], +) + +cc = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') + +# https://mesonbuild.com/Python-module.html +py_mod = import('python') +py3 = py_mod.find_installation() +py3_dep = py3.dependency() + +pybind11_dep = dependency('pybind11', version: '>=2.6') + +subdir('extern') +subdir('src') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000000..0b10c331ae48 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,17 @@ +# By default, Matplotlib downloads and builds its own copies of FreeType and of +# Qhull. You may set the following to True to instead link against a system +# FreeType/Qhull. As an exception, Matplotlib defaults to the system version +# of FreeType on AIX. +option('system-freetype', type: 'boolean', value: false, + description: 'Build against system version of FreeType') +option('system-qhull', type: 'boolean', value: false, + description: 'Build against system version of Qhull') + +# Some of Matplotlib's components are optional: the MacOSX backend (installed +# by default on MacOSX; requires the Cocoa headers included with XCode), and +# the test data (i.e., the baseline image files; not installed by default). You +# can control whether they are installed by uncommenting the following lines. +# Note that the MacOSX backend is never built on Linux or Windows, regardless +# of the config value. +option('macosx', type: 'boolean', value: true, + description: 'Enable MacOSX backend (requires Cocoa)') diff --git a/src/_c_internal_utils.c b/src/_c_internal_utils.c index f1bd22a42c54..49e5057f1349 100644 --- a/src/_c_internal_utils.c +++ b/src/_c_internal_utils.c @@ -1,3 +1,9 @@ +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +// Windows 10, for latest HiDPI API support. +#define WINVER 0x0A00 +#define _WIN32_WINNT 0x0A00 +#endif #define PY_SSIZE_T_CLEAN #include #ifdef __linux__ diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp index 5c36b3f07f50..a967845707d4 100644 --- a/src/_tkagg.cpp +++ b/src/_tkagg.cpp @@ -9,6 +9,13 @@ // rewritten, we have removed the PIL licensing information. If you want PIL, // you can get it at https://python-pillow.org/ +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +// Windows 8.1 +#define WINVER 0x0603 +#define _WIN32_WINNT 0x0603 +#endif + #define PY_SSIZE_T_CLEAN #include diff --git a/src/_ttconv.cpp b/src/_ttconv.cpp index 72fdfba6961d..51c2531bed99 100644 --- a/src/_ttconv.cpp +++ b/src/_ttconv.cpp @@ -8,7 +8,7 @@ #include "mplutils.h" #include -#include "ttconv/pprdrv.h" +#include "pprdrv.h" #include namespace py = pybind11; diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000000..6a33d2dfb12a --- /dev/null +++ b/src/meson.build @@ -0,0 +1,191 @@ +# NumPy include directory - needed in all submodules +# The try-except is needed because when things are split across drives on Windows, there +# is no relative path and an exception gets raised. There may be other such cases, so add +# a catch-all and switch to an absolute path. Relative paths are needed when for example +# a virtualenv is placed inside the source tree; Meson rejects absolute paths to places +# inside the source tree. +# For cross-compilation it is often not possible to run the Python interpreter in order +# to retrieve numpy's include directory. It can be specified in the cross file instead: +# +# [properties] +# numpy-include-dir = /abspath/to/host-pythons/site-packages/numpy/core/include +# +# This uses the path as is, and avoids running the interpreter. +incdir_numpy = meson.get_external_property('numpy-include-dir', 'not-given') +if incdir_numpy == 'not-given' + incdir_numpy = run_command(py3, + [ + '-c', + '''import os +import numpy as np +try: + incdir = os.path.relpath(np.get_include()) +except Exception: + incdir = np.get_include() +print(incdir)''' + ], + check: true + ).stdout().strip() +endif +numpy_dep = declare_dependency( + compile_args: [ + '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION', + # Allow NumPy's printf format specifiers in C++. + '-D__STDC_FORMAT_MACROS=1', + ], + include_directories: include_directories(incdir_numpy), + dependencies: py3_dep, +) + +# For cross-compilation it is often not possible to run the Python interpreter in order +# to retrieve the platform-specific /dev/null. It can be specified in the cross file +# instead: +# +# [properties] +# devnull = /dev/null +# +# This uses the value as is, and avoids running the interpreter. +devnull = meson.get_external_property('devnull', 'not-given') +if devnull == 'not-given' + devnull = run_command(py3, '-c', 'import os; print(os.devnull)', + capture: true, check: true).stdout().strip() +endif + +# Will only exist on Linux with older glibc. +dl = cc.find_library('dl', required: false) + +# With Meson >= 1.2.0, use cpp_winlibs instead of manually searching. +if ['cygwin', 'windows'].contains(host_machine.system()) + comctl32 = cc.find_library('comctl32') + ole32 = cc.find_library('ole32') + psapi = cc.find_library('psapi') + shell32 = cc.find_library('shell32') + user32 = cc.find_library('user32') +else + comctl32 = [] + ole32 = [] + psapi = [] + shell32 = [] + user32 = [] +endif + +extension_data = { + '_backend_agg': { + 'subdir': 'matplotlib/backends', + 'sources': files( + 'py_converters.cpp', + '_backend_agg.cpp', + '_backend_agg_wrapper.cpp', + ), + 'dependencies': [agg_dep, numpy_dep, freetype_dep], + }, + '_c_internal_utils': { + 'subdir': 'matplotlib', + 'sources': files( + '_c_internal_utils.c', + ), + 'dependencies': [py3_dep, dl, ole32, shell32, user32], + }, + 'ft2font': { + 'subdir': 'matplotlib', + 'sources': files( + 'ft2font.cpp', + 'ft2font_wrapper.cpp', + 'py_converters.cpp', + ), + 'dependencies': [ + freetype_dep, numpy_dep, agg_dep.partial_dependency(includes: true), + ], + }, + '_image': { + 'subdir': 'matplotlib', + 'sources': files( + '_image_wrapper.cpp', + 'py_converters_11.cpp', + ), + 'dependencies': [ + pybind11_dep, + # Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp + agg_dep, + ], + }, + '_path': { + 'subdir': 'matplotlib', + 'sources': files( + 'py_converters.cpp', + '_path_wrapper.cpp', + ), + 'dependencies': [numpy_dep, agg_dep], + }, + '_qhull': { + 'subdir': 'matplotlib', + 'sources': files( + '_qhull_wrapper.cpp', + ), + 'dependencies': [numpy_dep, qhull_dep], + 'c_args': [f'-DMPL_DEVNULL=@devnull@'], + 'cpp_args': [f'-DMPL_DEVNULL=@devnull@'], + }, + '_tkagg': { + 'subdir': 'matplotlib/backends', + 'sources': files( + '_tkagg.cpp', + ), + 'include_directories': include_directories('.'), + # The dl/psapi libraries are needed for finding Tcl/Tk at run time. + 'dependencies': [ + numpy_dep, agg_dep.partial_dependency(includes: true), dl, comctl32, psapi, + ], + }, + '_tri': { + 'subdir': 'matplotlib', + 'sources': files( + 'tri/_tri.cpp', + 'tri/_tri_wrapper.cpp', + ), + 'dependencies': [pybind11_dep], + }, + '_ttconv': { + 'subdir': 'matplotlib', + 'sources': files( + '_ttconv.cpp', + ), + 'dependencies': [ttconv_dep, pybind11_dep], + }, +} + +cpp_special_arguments = [] +if cpp.get_id() == 'msvc' and get_option('buildtype') != 'plain' + # Disable FH4 Exception Handling implementation so that we don't require + # VCRUNTIME140_1.dll. For more details, see: + # https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/ + # https://github.com/joerick/cibuildwheel/issues/423#issuecomment-677763904 + cpp_special_arguments += ['/d2FH4-'] +endif + +foreach ext, kwargs : extension_data + # Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each extension. + unique_array_api = '-DPY_ARRAY_UNIQUE_SYMBOL=MPL_@0@_ARRAY_API'.format(ext.replace('.', '_')) + additions = { + 'c_args': [unique_array_api] + kwargs.get('c_args', []), + 'cpp_args': cpp_special_arguments + [unique_array_api] + kwargs.get('cpp_args', []), + } + py3.extension_module( + ext, + install: true, + kwargs: kwargs + additions) +endforeach + +if get_option('macosx') and host_machine.system() == 'darwin' + add_languages('objc', native: false) + py3.extension_module( + '_macosx', + subdir: 'matplotlib/backends', + sources: files( + '_macosx.m', + ), + dependencies: dependency('appleframeworks', modules: 'Cocoa'), + override_options: ['werror=true'], + install: true, + ) +endif diff --git a/src/tri/_tri.cpp b/src/tri/_tri.cpp index 2674a3140b35..5c01dbfa681c 100644 --- a/src/tri/_tri.cpp +++ b/src/tri/_tri.cpp @@ -1,9 +1,7 @@ -/* This file contains liberal use of asserts to assist code development and - * debugging. Standard matplotlib builds disable asserts so they cause no - * performance reduction. To enable the asserts, you need to undefine the - * NDEBUG macro, which is achieved by adding the following - * undef_macros=['NDEBUG'] - * to the appropriate make_extension call in setupext.py, and then rebuilding. +/* This file contains liberal use of asserts to assist code development and debugging. + * Standard Matplotlib builds disable asserts so they cause no performance reduction. To + * enable the asserts, you need to undefine the NDEBUG macro, which is achieved by + * passing ``b_ndebug=false`` to the Meson configuration. */ #include "../mplutils.h" #include "_tri.h" diff --git a/subprojects/freetype-2.11.1.wrap b/subprojects/freetype-2.11.1.wrap new file mode 100644 index 000000000000..af4e91e2d0a5 --- /dev/null +++ b/subprojects/freetype-2.11.1.wrap @@ -0,0 +1,7 @@ +[wrap-file] +source_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.11.1.tar.xz +source_filename = freetype-2.11.1.tar.xz +source_hash = 3333ae7cfda88429c97a7ae63b7d01ab398076c3b67182e960e5684050f2c5c8 + +[provide] +freetype-2.11.1 = freetype_dep diff --git a/subprojects/freetype-2.6.1.wrap b/subprojects/freetype-2.6.1.wrap new file mode 100644 index 000000000000..9da2890cdac8 --- /dev/null +++ b/subprojects/freetype-2.6.1.wrap @@ -0,0 +1,9 @@ +[wrap-file] +source_url = https://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-2.6.1.tar.gz +source_filename = freetype-2.6.1.tar.gz +source_hash = 0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014 + +patch_directory = freetype-2.6.1-meson + +[provide] +freetype-2.6.1 = freetype_dep diff --git a/subprojects/packagefiles/freetype-2.6.1-meson/LICENSE.build b/subprojects/packagefiles/freetype-2.6.1-meson/LICENSE.build new file mode 100644 index 000000000000..ec288041f388 --- /dev/null +++ b/subprojects/packagefiles/freetype-2.6.1-meson/LICENSE.build @@ -0,0 +1,19 @@ +Copyright (c) 2018 The Meson development team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/subprojects/packagefiles/freetype-2.6.1-meson/builds/unix/ftconfig.h.in b/subprojects/packagefiles/freetype-2.6.1-meson/builds/unix/ftconfig.h.in new file mode 100644 index 000000000000..400f3a2a5bf2 --- /dev/null +++ b/subprojects/packagefiles/freetype-2.6.1-meson/builds/unix/ftconfig.h.in @@ -0,0 +1,498 @@ +/***************************************************************************/ +/* */ +/* ftconfig.in */ +/* */ +/* UNIX-specific configuration file (specification only). */ +/* */ +/* Copyright 1996-2015 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This header file contains a number of macro definitions that are used */ + /* by the rest of the engine. Most of the macros here are automatically */ + /* determined at compile time, and you should not need to change it to */ + /* port FreeType, except to compile the library with a non-ANSI */ + /* compiler. */ + /* */ + /* Note however that if some specific modifications are needed, we */ + /* advise you to place a modified copy in your build directory. */ + /* */ + /* The build directory is usually `builds/', and contains */ + /* system-specific files that are always included first when building */ + /* the library. */ + /* */ + /*************************************************************************/ + +/* MESON: based on unix/ftconfig.in with but meson-friendly configuration defines */ + +#ifndef FTCONFIG_H_ +#define FTCONFIG_H_ + +#include +#include FT_CONFIG_OPTIONS_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +FT_BEGIN_HEADER + + + /*************************************************************************/ + /* */ + /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ + /* */ + /* These macros can be toggled to suit a specific system. The current */ + /* ones are defaults used to compile FreeType in an ANSI C environment */ + /* (16bit compilers are also supported). Copy this file to your own */ + /* `builds/' directory, and edit it to port the engine. */ + /* */ + /*************************************************************************/ + + +#define HAVE_UNISTD_H @HAVE_UNISTD_H@ +#define HAVE_FCNTL_H @HAVE_FCNTL_H@ +#define HAVE_STDINT_H @HAVE_STDINT_H@ + + + /* There are systems (like the Texas Instruments 'C54x) where a `char' */ + /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ + /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ + /* `char' type. */ + +#ifndef FT_CHAR_BIT +#define FT_CHAR_BIT CHAR_BIT +#endif + + +#undef FT_USE_AUTOCONF_SIZEOF_TYPES +#ifdef FT_USE_AUTOCONF_SIZEOF_TYPES + +#undef SIZEOF_INT +#undef SIZEOF_LONG +#define FT_SIZEOF_INT SIZEOF_INT +#define FT_SIZEOF_LONG SIZEOF_LONG + +#else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */ + + /* Following cpp computation of the bit length of int and long */ + /* is copied from default include/freetype/config/ftconfig.h. */ + /* If any improvement is required for this file, it should be */ + /* applied to the original header file for the builders that */ + /* do not use configure script. */ + + /* The size of an `int' type. */ +#if FT_UINT_MAX == 0xFFFFUL +#define FT_SIZEOF_INT (16 / FT_CHAR_BIT) +#elif FT_UINT_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_INT (32 / FT_CHAR_BIT) +#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_INT (64 / FT_CHAR_BIT) +#else +#error "Unsupported size of `int' type!" +#endif + + /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ + /* DM642) is recognized but avoided. */ +#if FT_ULONG_MAX == 0xFFFFFFFFUL +#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL +#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) +#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL +#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT) +#else +#error "Unsupported size of `long' type!" +#endif + +#endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */ + + + /* FT_UNUSED is a macro used to indicate that a given parameter is not */ + /* used -- this is only used to get rid of unpleasant compiler warnings */ +#ifndef FT_UNUSED +#define FT_UNUSED( arg ) ( (arg) = (arg) ) +#endif + + + /*************************************************************************/ + /* */ + /* AUTOMATIC CONFIGURATION MACROS */ + /* */ + /* These macros are computed from the ones defined above. Don't touch */ + /* their definition, unless you know precisely what you are doing. No */ + /* porter should need to mess with them. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Mac support */ + /* */ + /* This is the only necessary change, so it is defined here instead */ + /* providing a new configuration file. */ + /* */ +#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) + /* no Carbon frameworks for 64bit 10.4.x */ + /* AvailabilityMacros.h is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion */ +#include +#ifdef ECANCELED /* defined since 10.2 */ +#include "AvailabilityMacros.h" +#endif +#if defined( __LP64__ ) && \ + ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) +/undef FT_MACINTOSH +#endif + +#elif defined( __SC__ ) || defined( __MRC__ ) + /* Classic MacOS compilers */ +#include "ConditionalMacros.h" +#if TARGET_OS_MAC +#define FT_MACINTOSH 1 +#endif + +#endif + + + /* Fix compiler warning with sgi compiler */ +#if defined( __sgi ) && !defined( __GNUC__ ) +#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +#pragma set woff 3505 +#endif +#endif + + + /*************************************************************************/ + /* */ + /*
*/ + /* basic_types */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int16 */ + /* */ + /* */ + /* A typedef for a 16bit signed integer type. */ + /* */ + typedef signed short FT_Int16; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt16 */ + /* */ + /* */ + /* A typedef for a 16bit unsigned integer type. */ + /* */ + typedef unsigned short FT_UInt16; + + /* */ + + + /* this #if 0 ... #endif clause is for documentation purposes */ +#if 0 + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int32 */ + /* */ + /* */ + /* A typedef for a 32bit signed integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef signed XXX FT_Int32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt32 */ + /* */ + /* A typedef for a 32bit unsigned integer type. The size depends on */ + /* the configuration. */ + /* */ + typedef unsigned XXX FT_UInt32; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_Int64 */ + /* */ + /* A typedef for a 64bit signed integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef signed XXX FT_Int64; + + + /*************************************************************************/ + /* */ + /* */ + /* FT_UInt64 */ + /* */ + /* A typedef for a 64bit unsigned integer type. The size depends on */ + /* the configuration. Only defined if there is real 64bit support; */ + /* otherwise, it gets emulated with a structure (if necessary). */ + /* */ + typedef unsigned XXX FT_UInt64; + + /* */ + +#endif + +#if FT_SIZEOF_INT == 4 + + typedef signed int FT_Int32; + typedef unsigned int FT_UInt32; + +#elif FT_SIZEOF_LONG == 4 + + typedef signed long FT_Int32; + typedef unsigned long FT_UInt32; + +#else +#error "no 32bit type found -- please check your configuration files" +#endif + + + /* look up an integer type that is at least 32 bits */ +#if FT_SIZEOF_INT >= 4 + + typedef int FT_Fast; + typedef unsigned int FT_UFast; + +#elif FT_SIZEOF_LONG >= 4 + + typedef long FT_Fast; + typedef unsigned long FT_UFast; + +#endif + + + /* determine whether we have a 64-bit int type for platforms without */ + /* Autoconf */ +#if FT_SIZEOF_LONG == 8 + + /* FT_LONG64 must be defined if a 64-bit type is available */ +#define FT_LONG64 +#define FT_INT64 long +#define FT_UINT64 unsigned long + + /*************************************************************************/ + /* */ + /* A 64-bit data type may create compilation problems if you compile */ + /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ + /* types if __STDC__ is defined. You can however ignore this rule */ + /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ + /* */ +#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) + +#if defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __BORLANDC__ ) /* Borland C++ */ + + /* XXXX: We should probably check the value of __BORLANDC__ in order */ + /* to test the compiler version. */ + + /* this compiler provides the __int64 type */ +#define FT_LONG64 +#define FT_INT64 __int64 +#define FT_UINT64 unsigned __int64 + +#elif defined( __WATCOMC__ ) /* Watcom C++ */ + + /* Watcom doesn't provide 64-bit data types */ + +#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ + +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#elif defined( __GNUC__ ) + + /* GCC provides the `long long' type */ +#define FT_LONG64 +#define FT_INT64 long long int +#define FT_UINT64 unsigned long long int + +#endif /* _MSC_VER */ + +#endif /* FT_SIZEOF_LONG == 8 */ + +#ifdef FT_LONG64 + typedef FT_INT64 FT_Int64; + typedef FT_UINT64 FT_UInt64; +#endif + + + /*************************************************************************/ + /* */ + /* miscellaneous */ + /* */ + /*************************************************************************/ + + +#define FT_BEGIN_STMNT do { +#define FT_END_STMNT } while ( 0 ) +#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT + + + /* typeof condition taken from gnulib's `intprops.h' header file */ +#if ( __GNUC__ >= 2 || \ + defined( __IBM__TYPEOF__ ) || \ + ( __SUNPRO_C >= 0x5110 && !__STDC__ ) ) +#define FT_TYPEOF( type ) (__typeof__ (type)) +#else +#define FT_TYPEOF( type ) /* empty */ +#endif + + +#ifdef FT_MAKE_OPTION_SINGLE_OBJECT + +#define FT_LOCAL( x ) static x +#define FT_LOCAL_DEF( x ) static x + +#else + +#ifdef __cplusplus +#define FT_LOCAL( x ) extern "C" x +#define FT_LOCAL_DEF( x ) extern "C" x +#else +#define FT_LOCAL( x ) extern x +#define FT_LOCAL_DEF( x ) x +#endif + +#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ + +#define FT_LOCAL_ARRAY( x ) extern const x +#define FT_LOCAL_ARRAY_DEF( x ) const x + + +#ifndef FT_BASE + +#ifdef __cplusplus +#define FT_BASE( x ) extern "C" x +#else +#define FT_BASE( x ) extern x +#endif + +#endif /* !FT_BASE */ + + +#ifndef FT_BASE_DEF + +#ifdef __cplusplus +#define FT_BASE_DEF( x ) x +#else +#define FT_BASE_DEF( x ) x +#endif + +#endif /* !FT_BASE_DEF */ + + +#ifndef FT_EXPORT + +#ifdef __cplusplus +#define FT_EXPORT( x ) extern "C" x +#else +#define FT_EXPORT( x ) extern x +#endif + +#endif /* !FT_EXPORT */ + + +#ifndef FT_EXPORT_DEF + +#ifdef __cplusplus +#define FT_EXPORT_DEF( x ) extern "C" x +#else +#define FT_EXPORT_DEF( x ) extern x +#endif + +#endif /* !FT_EXPORT_DEF */ + + +#ifndef FT_EXPORT_VAR + +#ifdef __cplusplus +#define FT_EXPORT_VAR( x ) extern "C" x +#else +#define FT_EXPORT_VAR( x ) extern x +#endif + +#endif /* !FT_EXPORT_VAR */ + + /* The following macros are needed to compile the library with a */ + /* C++ compiler and with 16bit compilers. */ + /* */ + + /* This is special. Within C++, you must specify `extern "C"' for */ + /* functions which are used via function pointers, and you also */ + /* must do that for structures which contain function pointers to */ + /* assure C linkage -- it's not possible to have (local) anonymous */ + /* functions which are accessed by (global) function pointers. */ + /* */ + /* */ + /* FT_CALLBACK_DEF is used to _define_ a callback function. */ + /* */ + /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ + /* contains pointers to callback functions. */ + /* */ + /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ + /* that contains pointers to callback functions. */ + /* */ + /* */ + /* Some 16bit compilers have to redefine these macros to insert */ + /* the infamous `_cdecl' or `__fastcall' declarations. */ + /* */ +#ifndef FT_CALLBACK_DEF +#ifdef __cplusplus +#define FT_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_CALLBACK_DEF( x ) static x +#endif +#endif /* FT_CALLBACK_DEF */ + +#ifndef FT_CALLBACK_TABLE +#ifdef __cplusplus +#define FT_CALLBACK_TABLE extern "C" +#define FT_CALLBACK_TABLE_DEF extern "C" +#else +#define FT_CALLBACK_TABLE extern +#define FT_CALLBACK_TABLE_DEF /* nothing */ +#endif +#endif /* FT_CALLBACK_TABLE */ + + +FT_END_HEADER + + +#endif /* FTCONFIG_H_ */ + + +/* END */ diff --git a/subprojects/packagefiles/freetype-2.6.1-meson/include/freetype/config/ftoption.h.in b/subprojects/packagefiles/freetype-2.6.1-meson/include/freetype/config/ftoption.h.in new file mode 100644 index 000000000000..5df84c706800 --- /dev/null +++ b/subprojects/packagefiles/freetype-2.6.1-meson/include/freetype/config/ftoption.h.in @@ -0,0 +1,886 @@ +/***************************************************************************/ +/* */ +/* ftoption.h */ +/* */ +/* User-selectable configuration macros (specification only). */ +/* */ +/* Copyright 1996-2015 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTOPTION_H_ +#define FTOPTION_H_ + + +#include + + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* USER-SELECTABLE CONFIGURATION MACROS */ + /* */ + /* This file contains the default configuration macro definitions for */ + /* a standard build of the FreeType library. There are three ways to */ + /* use this file to build project-specific versions of the library: */ + /* */ + /* - You can modify this file by hand, but this is not recommended in */ + /* cases where you would like to build several versions of the */ + /* library from a single source directory. */ + /* */ + /* - You can put a copy of this file in your build directory, more */ + /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ + /* is the name of a directory that is included _before_ the FreeType */ + /* include path during compilation. */ + /* */ + /* The default FreeType Makefiles and Jamfiles use the build */ + /* directory `builds/' by default, but you can easily change */ + /* that for your own projects. */ + /* */ + /* - Copy the file to `$BUILD/ft2build.h' and modify it */ + /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ + /* locate this file during the build. For example, */ + /* */ + /* #define FT_CONFIG_OPTIONS_H */ + /* #include */ + /* */ + /* will use `$BUILD/myftoptions.h' instead of this file for macro */ + /* definitions. */ + /* */ + /* Note also that you can similarly pre-define the macro */ + /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ + /* that are statically linked to the library at compile time. By */ + /* default, this file is . */ + /* */ + /* We highly recommend using the third method whenever possible. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Uncomment the line below if you want to activate sub-pixel rendering */ + /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ + /* */ + /* Note that this feature is covered by several Microsoft patents */ + /* and should not be activated in any default build of the library. */ + /* */ + /* This macro has no impact on the FreeType API, only on its */ + /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ + /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ + /* the original size in case this macro isn't defined; however, each */ + /* triplet of subpixels has R=G=B. */ + /* */ + /* This is done to allow FreeType clients to run unmodified, forcing */ + /* them to display normal gray-level anti-aliased glyphs. */ + /* */ +/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + + /*************************************************************************/ + /* */ + /* Many compilers provide a non-ANSI 64-bit data type that can be used */ + /* by FreeType to speed up some computations. However, this will create */ + /* some problems when compiling the library in strict ANSI mode. */ + /* */ + /* For this reason, the use of 64-bit integers is normally disabled when */ + /* the __STDC__ macro is defined. You can however disable this by */ + /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ + /* */ + /* For most compilers, this will only create compilation warnings when */ + /* building the library. */ + /* */ + /* ObNote: The compiler-specific 64-bit integers are detected in the */ + /* file `ftconfig.h' either statically or through the */ + /* `configure' script on supported platforms. */ + /* */ +#undef FT_CONFIG_OPTION_FORCE_INT64 + + + /*************************************************************************/ + /* */ + /* If this macro is defined, do not try to use an assembler version of */ + /* performance-critical functions (e.g. FT_MulFix). You should only do */ + /* that to verify that the assembler function works properly, or to */ + /* execute benchmark tests of the various implementations. */ +/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ + + + /*************************************************************************/ + /* */ + /* If this macro is defined, try to use an inlined assembler version of */ + /* the `FT_MulFix' function, which is a `hotspot' when loading and */ + /* hinting glyphs, and which should be executed as fast as possible. */ + /* */ + /* Note that if your compiler or CPU is not supported, this will default */ + /* to the standard and portable implementation found in `ftcalc.c'. */ + /* */ +#define FT_CONFIG_OPTION_INLINE_MULFIX + + + /*************************************************************************/ + /* */ + /* LZW-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `compress' program. This is mostly used to parse many of the PCF */ + /* files that come with various X11 distributions. The implementation */ + /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ + /* (see src/lzw/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#define FT_CONFIG_OPTION_USE_LZW + + + /*************************************************************************/ + /* */ + /* Gzip-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `gzip' program. This is mostly used to parse many of the PCF files */ + /* that come with XFree86. The implementation uses `zlib' to */ + /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ + /* */ + /* Define this macro if you want to enable this `feature'. See also */ + /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ + /* */ +#define FT_CONFIG_OPTION_USE_ZLIB + + + /*************************************************************************/ + /* */ + /* ZLib library selection */ + /* */ + /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ + /* It allows FreeType's `ftgzip' component to link to the system's */ + /* installation of the ZLib library. This is useful on systems like */ + /* Unix or VMS where it generally is already available. */ + /* */ + /* If you let it undefined, the component will use its own copy */ + /* of the zlib sources instead. These have been modified to be */ + /* included directly within the component and *not* export external */ + /* function names. This allows you to link any program with FreeType */ + /* _and_ ZLib without linking conflicts. */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ +#mesondefine FT_CONFIG_OPTION_SYSTEM_ZLIB + + + /*************************************************************************/ + /* */ + /* Bzip2-compressed file support. */ + /* */ + /* FreeType now handles font files that have been compressed with the */ + /* `bzip2' program. This is mostly used to parse many of the PCF */ + /* files that come with XFree86. The implementation uses `libbz2' to */ + /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ + /* Contrary to gzip, bzip2 currently is not included and need to use */ + /* the system available bzip2 implementation. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#mesondefine FT_CONFIG_OPTION_USE_BZIP2 + + + /*************************************************************************/ + /* */ + /* Define to disable the use of file stream functions and types, FILE, */ + /* fopen() etc. Enables the use of smaller system libraries on embedded */ + /* systems that have multiple system libraries, some with or without */ + /* file stream support, in the cases where file stream support is not */ + /* necessary such as memory loading of font files. */ + /* */ +/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ + + + /*************************************************************************/ + /* */ + /* PNG bitmap support. */ + /* */ + /* FreeType now handles loading color bitmap glyphs in the PNG format. */ + /* This requires help from the external libpng library. Uncompressed */ + /* color bitmaps do not need any external libraries and will be */ + /* supported regardless of this configuration. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#mesondefine FT_CONFIG_OPTION_USE_PNG + + + /*************************************************************************/ + /* */ + /* HarfBuzz support. */ + /* */ + /* FreeType uses the HarfBuzz library to improve auto-hinting of */ + /* OpenType fonts. If available, many glyphs not directly addressable */ + /* by a font's character map will be hinted also. */ + /* */ + /* Define this macro if you want to enable this `feature'. */ + /* */ +#mesondefine FT_CONFIG_OPTION_USE_HARFBUZZ + + + /*************************************************************************/ + /* */ + /* DLL export compilation */ + /* */ + /* When compiling FreeType as a DLL, some systems/compilers need a */ + /* special keyword in front OR after the return type of function */ + /* declarations. */ + /* */ + /* Two macros are used within the FreeType source code to define */ + /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ + /* */ + /* FT_EXPORT( return_type ) */ + /* */ + /* is used in a function declaration, as in */ + /* */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* */ + /* */ + /* FT_EXPORT_DEF( return_type ) */ + /* */ + /* is used in a function definition, as in */ + /* */ + /* FT_EXPORT_DEF( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* { */ + /* ... some code ... */ + /* return FT_Err_Ok; */ + /* } */ + /* */ + /* You can provide your own implementation of FT_EXPORT and */ + /* FT_EXPORT_DEF here if you want. If you leave them undefined, they */ + /* will be later automatically defined as `extern return_type' to */ + /* allow normal compilation. */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_EXPORT(x) extern x */ +/* #define FT_EXPORT_DEF(x) x */ + + + /*************************************************************************/ + /* */ + /* Glyph Postscript Names handling */ + /* */ + /* By default, FreeType 2 is compiled with the `psnames' module. This */ + /* module is in charge of converting a glyph name string into a */ + /* Unicode value, or return a Macintosh standard glyph name for the */ + /* use with the TrueType `post' table. */ + /* */ + /* Undefine this macro if you do not want `psnames' compiled in your */ + /* build of FreeType. This has the following effects: */ + /* */ + /* - The TrueType driver will provide its own set of glyph names, */ + /* if you build it to support postscript names in the TrueType */ + /* `post' table. */ + /* */ + /* - The Type 1 driver will not be able to synthesize a Unicode */ + /* charmap out of the glyphs found in the fonts. */ + /* */ + /* You would normally undefine this configuration macro when building */ + /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ + /* */ +#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Postscript Names to Unicode Values support */ + /* */ + /* By default, FreeType 2 is built with the `PSNames' module compiled */ + /* in. Among other things, the module is used to convert a glyph name */ + /* into a Unicode value. This is especially useful in order to */ + /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ + /* through a big table named the `Adobe Glyph List' (AGL). */ + /* */ + /* Undefine this macro if you do not want the Adobe Glyph List */ + /* compiled in your `PSNames' module. The Type 1 driver will not be */ + /* able to synthesize a Unicode charmap out of the glyphs found in the */ + /* fonts. */ + /* */ +#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST + + + /*************************************************************************/ + /* */ + /* Support for Mac fonts */ + /* */ + /* Define this macro if you want support for outline fonts in Mac */ + /* format (mac dfont, mac resource, macbinary containing a mac */ + /* resource) on non-Mac platforms. */ + /* */ + /* Note that the `FOND' resource isn't checked. */ + /* */ +#define FT_CONFIG_OPTION_MAC_FONTS + + + /*************************************************************************/ + /* */ + /* Guessing methods to access embedded resource forks */ + /* */ + /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ + /* GNU/Linux). */ + /* */ + /* Resource forks which include fonts data are stored sometimes in */ + /* locations which users or developers don't expected. In some cases, */ + /* resource forks start with some offset from the head of a file. In */ + /* other cases, the actual resource fork is stored in file different */ + /* from what the user specifies. If this option is activated, */ + /* FreeType tries to guess whether such offsets or different file */ + /* names must be used. */ + /* */ + /* Note that normal, direct access of resource forks is controlled via */ + /* the FT_CONFIG_OPTION_MAC_FONTS option. */ + /* */ +#ifdef FT_CONFIG_OPTION_MAC_FONTS +#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK +#endif + + + /*************************************************************************/ + /* */ + /* Allow the use of FT_Incremental_Interface to load typefaces that */ + /* contain no glyph data, but supply it via a callback function. */ + /* This is required by clients supporting document formats which */ + /* supply font data incrementally as the document is parsed, such */ + /* as the Ghostscript interpreter for the PostScript language. */ + /* */ +#define FT_CONFIG_OPTION_INCREMENTAL + + + /*************************************************************************/ + /* */ + /* The size in bytes of the render pool used by the scan-line converter */ + /* to do all of its work. */ + /* */ +#define FT_RENDER_POOL_SIZE 16384L + + + /*************************************************************************/ + /* */ + /* FT_MAX_MODULES */ + /* */ + /* The maximum number of modules that can be registered in a single */ + /* FreeType library object. 32 is the default. */ + /* */ +#define FT_MAX_MODULES 32 + + + /*************************************************************************/ + /* */ + /* Debug level */ + /* */ + /* FreeType can be compiled in debug or trace mode. In debug mode, */ + /* errors are reported through the `ftdebug' component. In trace */ + /* mode, additional messages are sent to the standard output during */ + /* execution. */ + /* */ + /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ + /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ + /* */ + /* Don't define any of these macros to compile in `release' mode! */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_LEVEL_ERROR */ +/* #define FT_DEBUG_LEVEL_TRACE */ + + + /*************************************************************************/ + /* */ + /* Autofitter debugging */ + /* */ + /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ + /* control the autofitter behaviour for debugging purposes with global */ + /* boolean variables (consequently, you should *never* enable this */ + /* while compiling in `release' mode): */ + /* */ + /* _af_debug_disable_horz_hints */ + /* _af_debug_disable_vert_hints */ + /* _af_debug_disable_blue_hints */ + /* */ + /* Additionally, the following functions provide dumps of various */ + /* internal autofit structures to stdout (using `printf'): */ + /* */ + /* af_glyph_hints_dump_points */ + /* af_glyph_hints_dump_segments */ + /* af_glyph_hints_dump_edges */ + /* af_glyph_hints_get_num_segments */ + /* af_glyph_hints_get_segment_offset */ + /* */ + /* As an argument, they use another global variable: */ + /* */ + /* _af_debug_hints */ + /* */ + /* Please have a look at the `ftgrid' demo program to see how those */ + /* variables and macros should be used. */ + /* */ + /* Do not #undef these macros here since the build system might define */ + /* them for certain configurations only. */ + /* */ +/* #define FT_DEBUG_AUTOFIT */ + + + /*************************************************************************/ + /* */ + /* Memory Debugging */ + /* */ + /* FreeType now comes with an integrated memory debugger that is */ + /* capable of detecting simple errors like memory leaks or double */ + /* deletes. To compile it within your build of the library, you */ + /* should define FT_DEBUG_MEMORY here. */ + /* */ + /* Note that the memory debugger is only activated at runtime when */ + /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ + /* */ + /* Do not #undef this macro here since the build system might define */ + /* it for certain configurations only. */ + /* */ +/* #define FT_DEBUG_MEMORY */ + + + /*************************************************************************/ + /* */ + /* Module errors */ + /* */ + /* If this macro is set (which is _not_ the default), the higher byte */ + /* of an error code gives the module in which the error has occurred, */ + /* while the lower byte is the real error code. */ + /* */ + /* Setting this macro makes sense for debugging purposes only, since */ + /* it would break source compatibility of certain programs that use */ + /* FreeType 2. */ + /* */ + /* More details can be found in the files ftmoderr.h and fterrors.h. */ + /* */ +#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS + + + /*************************************************************************/ + /* */ + /* Position Independent Code */ + /* */ + /* If this macro is set (which is _not_ the default), FreeType2 will */ + /* avoid creating constants that require address fixups. Instead the */ + /* constants will be moved into a struct and additional intialization */ + /* code will be used. */ + /* */ + /* Setting this macro is needed for systems that prohibit address */ + /* fixups, such as BREW. */ + /* */ +#mesondefine FT_CONFIG_OPTION_PIC + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ + /* embedded bitmaps in all formats using the SFNT module (namely */ + /* TrueType & OpenType). */ + /* */ +#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ + /* load and enumerate the glyph Postscript names in a TrueType or */ + /* OpenType file. */ + /* */ + /* Note that when you do not compile the `PSNames' module by undefining */ + /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ + /* contain additional code used to read the PS Names table from a font. */ + /* */ + /* (By default, the module uses `PSNames' to extract glyph names.) */ + /* */ +#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ + /* access the internal name table in a SFNT-based format like TrueType */ + /* or OpenType. The name table contains various strings used to */ + /* describe the font, like family name, copyright, version, etc. It */ + /* does not contain any glyph name though. */ + /* */ + /* Accessing SFNT names is done through the functions declared in */ + /* `ftsnames.h'. */ + /* */ +#define TT_CONFIG_OPTION_SFNT_NAMES + + + /*************************************************************************/ + /* */ + /* TrueType CMap support */ + /* */ + /* Here you can fine-tune which TrueType CMap table format shall be */ + /* supported. */ +#define TT_CONFIG_CMAP_FORMAT_0 +#define TT_CONFIG_CMAP_FORMAT_2 +#define TT_CONFIG_CMAP_FORMAT_4 +#define TT_CONFIG_CMAP_FORMAT_6 +#define TT_CONFIG_CMAP_FORMAT_8 +#define TT_CONFIG_CMAP_FORMAT_10 +#define TT_CONFIG_CMAP_FORMAT_12 +#define TT_CONFIG_CMAP_FORMAT_13 +#define TT_CONFIG_CMAP_FORMAT_14 + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ + /* a bytecode interpreter in the TrueType driver. */ + /* */ + /* By undefining this, you will only compile the code necessary to load */ + /* TrueType glyphs without hinting. */ + /* */ + /* Do not #undef this macro here, since the build system might */ + /* define it for certain configurations only. */ + /* */ +#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ + /* EXPERIMENTAL subpixel hinting support into the TrueType driver. This */ + /* replaces the native TrueType hinting mechanism when anything but */ + /* FT_RENDER_MODE_MONO is requested. */ + /* */ + /* Enabling this causes the TrueType driver to ignore instructions under */ + /* certain conditions. This is done in accordance with the guide here, */ + /* with some minor differences: */ + /* */ + /* http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ + /* */ + /* By undefining this, you only compile the code necessary to hint */ + /* TrueType glyphs with native TT hinting. */ + /* */ + /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ + /* defined. */ + /* */ +/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */ + + + /*************************************************************************/ + /* */ + /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */ + /* of the TrueType bytecode interpreter is used that doesn't implement */ + /* any of the patented opcodes and algorithms. The patents related to */ + /* TrueType hinting have expired worldwide since May 2010; this option */ + /* is now deprecated. */ + /* */ + /* Note that the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* */ + /* if you define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, */ + /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */ + /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */ + /* */ + /* This macro is only useful for a small number of font files (mostly */ + /* for Asian scripts) that require bytecode interpretation to properly */ + /* load glyphs. For all other fonts, this produces unpleasant results, */ + /* thus the unpatented interpreter is never used to load glyphs from */ + /* TrueType fonts unless one of the following two options is used. */ + /* */ + /* - The unpatented interpreter is explicitly activated by the user */ + /* through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag */ + /* when opening the FT_Face. */ + /* */ + /* - FreeType detects that the FT_Face corresponds to one of the */ + /* `trick' fonts (e.g., `Mingliu') it knows about. The font engine */ + /* contains a hard-coded list of font names and other matching */ + /* parameters (see function `tt_face_init' in file */ + /* `src/truetype/ttobjs.c'). */ + /* */ + /* Here a sample code snippet for using FT_PARAM_TAG_UNPATENTED_HINTING. */ + /* */ + /* { */ + /* FT_Parameter parameter; */ + /* FT_Open_Args open_args; */ + /* */ + /* */ + /* parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING; */ + /* */ + /* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; */ + /* open_args.pathname = my_font_pathname; */ + /* open_args.num_params = 1; */ + /* open_args.params = ¶meter; */ + /* */ + /* error = FT_Open_Face( library, &open_args, index, &face ); */ + /* ... */ + /* } */ + /* */ +/* #define TT_CONFIG_OPTION_UNPATENTED_HINTING */ + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ + /* TrueType glyph loader to use Apple's definition of how to handle */ + /* component offsets in composite glyphs. */ + /* */ + /* Apple and MS disagree on the default behavior of component offsets */ + /* in composites. Apple says that they should be scaled by the scaling */ + /* factors in the transformation matrix (roughly, it's more complex) */ + /* while MS says they should not. OpenType defines two bits in the */ + /* composite flags array which can be used to disambiguate, but old */ + /* fonts will not have them. */ + /* */ + /* http://www.microsoft.com/typography/otspec/glyf.htm */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ + /* */ +#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ + /* support for Apple's distortable font technology (fvar, gvar, cvar, */ + /* and avar tables). This has many similarities to Type 1 Multiple */ + /* Masters support. */ + /* */ +#define TT_CONFIG_OPTION_GX_VAR_SUPPORT + + + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ + /* an embedded `BDF ' table within SFNT-based bitmap formats. */ + /* */ +#define TT_CONFIG_OPTION_BDF + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ + /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ + /* required. */ + /* */ +#define T1_MAX_DICT_DEPTH 5 + + + /*************************************************************************/ + /* */ + /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ + /* calls during glyph loading. */ + /* */ +#define T1_MAX_SUBRS_CALLS 16 + + + /*************************************************************************/ + /* */ + /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ + /* minimum of 16 is required. */ + /* */ + /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ + /* */ +#define T1_MAX_CHARSTRINGS_OPERANDS 256 + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ + /* files into an existing face. Note that if set, the T1 driver will be */ + /* unable to produce kerning distances. */ + /* */ +#undef T1_CONFIG_OPTION_NO_AFM + + + /*************************************************************************/ + /* */ + /* Define this configuration macro if you want to prevent the */ + /* compilation of the Multiple Masters font support in the Type 1 */ + /* driver. */ + /* */ +#undef T1_CONFIG_OPTION_NO_MM_SUPPORT + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** C F F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ + /* possible to set up the default values of the four control points that */ + /* define the stem darkening behaviour of the (new) CFF engine. For */ + /* more details please read the documentation of the */ + /* `darkening-parameters' property of the cff driver module (file */ + /* `ftcffdrv.h'), which allows the control at run-time. */ + /* */ + /* Do *not* undefine these macros! */ + /* */ +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275 + +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333 +#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 + + + /*************************************************************************/ + /* */ + /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ + /* engine gets compiled into FreeType. If defined, it is possible to */ + /* switch between the two engines using the `hinting-engine' property of */ + /* the cff driver module. */ + /* */ +/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ + + + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ + /* support. */ + /* */ +#define AF_CONFIG_OPTION_CJK + + /*************************************************************************/ + /* */ + /* Compile autofit module with Indic script support. */ + /* */ +#define AF_CONFIG_OPTION_INDIC + + /*************************************************************************/ + /* */ + /* Compile autofit module with warp hinting. The idea of the warping */ + /* code is to slightly scale and shift a glyph within a single dimension */ + /* so that as much of its segments are aligned (more or less) on the */ + /* grid. To find out the optimal scaling and shifting value, various */ + /* parameter combinations are tried and scored. */ + /* */ + /* This experimental option is active only if the rendering mode is */ + /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ + /* `warping' property of the auto-hinter (see file `ftautoh.h' for more */ + /* information; by default it is switched off). */ + /* */ +#define AF_CONFIG_OPTION_USE_WARPER + + /* */ + + + /* + * This macro is obsolete. Support has been removed in FreeType + * version 2.5. + */ +/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ + + + /* + * This macro is defined if either unpatented or native TrueType + * hinting is requested by the definitions above. + */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#define TT_USE_BYTECODE_INTERPRETER +#undef TT_CONFIG_OPTION_UNPATENTED_HINTING +#elif defined TT_CONFIG_OPTION_UNPATENTED_HINTING +#define TT_USE_BYTECODE_INTERPRETER +#endif + + + /* + * Check CFF darkening parameters. The checks are the same as in function + * `cff_property_set' in file `cffdrivr.c'. + */ +#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \ + \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \ + CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500 +#error "Invalid CFF darkening parameters!" +#endif + +FT_END_HEADER + + +#endif /* FTOPTION_H_ */ + + +/* END */ diff --git a/subprojects/packagefiles/freetype-2.6.1-meson/meson.build b/subprojects/packagefiles/freetype-2.6.1-meson/meson.build new file mode 100644 index 000000000000..dddfd67f6d09 --- /dev/null +++ b/subprojects/packagefiles/freetype-2.6.1-meson/meson.build @@ -0,0 +1,187 @@ +project('freetype2', 'c', + license : ['FTL', 'GPL2'], + version: '2.6.1') + +# NOTE about FreeType versions +# There are 3 versions numbers associated with each releases: +# - official release number (eg. 2.6.1) - accessible via +# FREETYPE_{MAJOR,MINOR,PATCH} macros from FT_FREETYPE_H +# - libtool-specific version number, this is what is returned by +# freetype-config --version / pkg-config --modversion (eg. 22.1.16) +# - the platform-specific shared object version number (eg. 6.16.1) +# See https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/VERSIONS.TXT +# for more information +release_version = meson.project_version() +libtool_version = '18.1.12' +so_version = '6.12.1' +so_soversion = '6' + +pkgmod = import('pkgconfig') + +cc = meson.get_compiler('c') + +base_sources = [ + 'src/autofit/autofit.c', + 'src/base/ftbase.c', + 'src/base/ftbbox.c', + 'src/base/ftbdf.c', + 'src/base/ftbitmap.c', + 'src/base/ftcid.c', + 'src/base/ftfntfmt.c', + 'src/base/ftfstype.c', + 'src/base/ftgasp.c', + 'src/base/ftglyph.c', + 'src/base/ftgxval.c', + 'src/base/ftinit.c', + 'src/base/ftlcdfil.c', + 'src/base/ftmm.c', + 'src/base/ftotval.c', + 'src/base/ftpatent.c', + 'src/base/ftpfr.c', + 'src/base/ftstroke.c', + 'src/base/ftsynth.c', + 'src/base/ftsystem.c', + 'src/base/fttype1.c', + 'src/base/ftwinfnt.c', + 'src/bdf/bdf.c', + 'src/bzip2/ftbzip2.c', + 'src/cache/ftcache.c', + 'src/cff/cff.c', + 'src/cid/type1cid.c', + 'src/gzip/ftgzip.c', + 'src/lzw/ftlzw.c', + 'src/pcf/pcf.c', + 'src/pfr/pfr.c', + 'src/psaux/psaux.c', + 'src/pshinter/pshinter.c', + 'src/psnames/psnames.c', + 'src/raster/raster.c', + 'src/sfnt/sfnt.c', + 'src/smooth/smooth.c', + 'src/truetype/truetype.c', + 'src/type1/type1.c', + 'src/type42/type42.c', + 'src/winfonts/winfnt.c', +] + +ft2build_h = [ + 'include/ft2build.h', +] + +ft_headers = [ + 'include/freetype/freetype.h', + 'include/freetype/ftadvanc.h', + 'include/freetype/ftautoh.h', + 'include/freetype/ftbbox.h', + 'include/freetype/ftbdf.h', + 'include/freetype/ftbitmap.h', + 'include/freetype/ftbzip2.h', + 'include/freetype/ftcache.h', + 'include/freetype/ftcffdrv.h', + 'include/freetype/ftchapters.h', + 'include/freetype/ftcid.h', + 'include/freetype/fterrdef.h', + 'include/freetype/fterrors.h', + 'include/freetype/ftfntfmt.h', + 'include/freetype/ftgasp.h', + 'include/freetype/ftglyph.h', + 'include/freetype/ftgxval.h', + 'include/freetype/ftgzip.h', + 'include/freetype/ftimage.h', + 'include/freetype/ftincrem.h', + 'include/freetype/ftlcdfil.h', + 'include/freetype/ftlist.h', + 'include/freetype/ftlzw.h', + 'include/freetype/ftmac.h', + 'include/freetype/ftmm.h', + 'include/freetype/ftmodapi.h', + 'include/freetype/ftmoderr.h', + 'include/freetype/ftotval.h', + 'include/freetype/ftoutln.h', + 'include/freetype/ftpfr.h', + 'include/freetype/ftrender.h', + 'include/freetype/ftsizes.h', + 'include/freetype/ftsnames.h', + 'include/freetype/ftstroke.h', + 'include/freetype/ftsynth.h', + 'include/freetype/ftsystem.h', + 'include/freetype/fttrigon.h', + 'include/freetype/ftttdrv.h', + 'include/freetype/fttypes.h', + 'include/freetype/ftwinfnt.h', + 'include/freetype/t1tables.h', + 'include/freetype/ttnameid.h', + 'include/freetype/tttables.h', + 'include/freetype/tttags.h', + 'include/freetype/ttunpat.h', +] + +ft_config_headers = [ + 'include/freetype/config/ftconfig.h', + 'include/freetype/config/ftheader.h', + 'include/freetype/config/ftmodule.h', + 'include/freetype/config/ftoption.h', + 'include/freetype/config/ftstdlib.h', +] + +if host_machine.system() == 'windows' + base_sources += [ + 'builds/windows/ftdebug.c', + ] +else + base_sources += [ + 'src/base/ftdebug.c', + ] +endif + +c_args = [ + '-DFT2_BUILD_LIBRARY', + '-DFT_CONFIG_CONFIG_H=', + '-DFT_CONFIG_OPTIONS_H=' +] + +check_headers = [] + +if ['linux', 'darwin', 'cygwin'].contains(host_machine.system()) + check_headers += [ + ['unistd.h'], + ['fcntl.h'], + ['stdint.h'], + ] + ftconfig_h_in = files('builds/unix/ftconfig.h.in') +else + ftconfig_h_in = files('include/freetype/config/ftconfig.h') +endif + +conf = configuration_data() +deps = [] +incbase = include_directories(['include']) + +foreach check : check_headers + name = check[0] + + if cc.has_header(name) + conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1) + endif +endforeach + +configure_file(input: ftconfig_h_in, + output: 'ftconfig.h', + configuration: conf) + +ft_config_headers += [configure_file(input: 'include/freetype/config/ftoption.h.in', + output: 'ftoption.h', + configuration: conf)] + +libfreetype = static_library('freetype', base_sources, + include_directories: incbase, + dependencies: deps, + c_args: c_args, + gnu_symbol_visibility: 'inlineshidden', +) + +freetype_dep = declare_dependency( + link_with: libfreetype, + include_directories : incbase, + dependencies: deps, +) diff --git a/subprojects/packagefiles/qhull-2020.2/meson.build b/subprojects/packagefiles/qhull-2020.2/meson.build new file mode 100644 index 000000000000..3d20c5d2ae55 --- /dev/null +++ b/subprojects/packagefiles/qhull-2020.2/meson.build @@ -0,0 +1,31 @@ +project('qhull', 'c', + version: '8.0.2', + license: 'Qhull') + +qhull_inc = include_directories('src') +qhull_lib = static_library('qhull_r', + 'src/libqhull_r/geom2_r.c', + 'src/libqhull_r/geom_r.c', + 'src/libqhull_r/global_r.c', + 'src/libqhull_r/io_r.c', + 'src/libqhull_r/libqhull_r.c', + 'src/libqhull_r/mem_r.c', + 'src/libqhull_r/merge_r.c', + 'src/libqhull_r/poly2_r.c', + 'src/libqhull_r/poly_r.c', + 'src/libqhull_r/qset_r.c', + 'src/libqhull_r/random_r.c', + 'src/libqhull_r/rboxlib_r.c', + 'src/libqhull_r/stat_r.c', + 'src/libqhull_r/usermem_r.c', + 'src/libqhull_r/userprintf_rbox_r.c', + 'src/libqhull_r/userprintf_r.c', + 'src/libqhull_r/user_r.c', + gnu_symbol_visibility: 'inlineshidden', +) + +qhull_dep = declare_dependency( + include_directories: qhull_inc, + link_with: qhull_lib) + +meson.override_dependency('qhull_r', qhull_dep) diff --git a/subprojects/qhull.wrap b/subprojects/qhull.wrap new file mode 100644 index 000000000000..f43ead300834 --- /dev/null +++ b/subprojects/qhull.wrap @@ -0,0 +1,9 @@ +[wrap-file] +# Also bump the cache key in `.circleci/config.yml`. +# Also update the docs in `docs/devel/dependencies.rst`. +directory = qhull-2020.2 +source_url = http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz +source_filename = qhull-2020-src-8.0.2.tgz +source_hash = b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e + +patch_directory = qhull-2020.2 From 7d85c0e1e942be5c65118a678c78605ef9533089 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 24 Aug 2023 03:28:22 -0400 Subject: [PATCH 3/8] BLD: Install Python files via Meson --- .flake8 | 2 - lib/matplotlib/_api/meson.build | 12 + lib/matplotlib/axes/meson.build | 16 + lib/matplotlib/backends/meson.build | 49 ++ lib/matplotlib/backends/qt_editor/meson.build | 11 + .../backends/web_backend/meson.build | 14 + lib/matplotlib/meson.build | 154 ++++ lib/matplotlib/projections/meson.build | 14 + lib/matplotlib/sphinxext/meson.build | 12 + lib/matplotlib/style/meson.build | 11 + lib/matplotlib/testing/jpl_units/meson.build | 16 + lib/matplotlib/testing/meson.build | 22 + lib/matplotlib/tests/meson.build | 113 +++ lib/matplotlib/tri/meson.build | 25 + lib/meson.build | 8 + lib/mpl_toolkits/axes_grid1/meson.build | 15 + lib/mpl_toolkits/axes_grid1/tests/meson.build | 12 + lib/mpl_toolkits/axisartist/meson.build | 18 + lib/mpl_toolkits/axisartist/tests/meson.build | 17 + lib/mpl_toolkits/meson.build | 3 + lib/mpl_toolkits/mplot3d/meson.build | 11 + lib/mpl_toolkits/mplot3d/tests/meson.build | 14 + meson.build | 4 +- meson_options.txt | 11 + mplsetup.cfg.template | 38 - pyproject.toml | 39 +- setup.cfg | 5 - setup.py | 290 ------- setupext.py | 799 ------------------ 29 files changed, 592 insertions(+), 1163 deletions(-) create mode 100644 lib/matplotlib/_api/meson.build create mode 100644 lib/matplotlib/axes/meson.build create mode 100644 lib/matplotlib/backends/meson.build create mode 100644 lib/matplotlib/backends/qt_editor/meson.build create mode 100644 lib/matplotlib/backends/web_backend/meson.build create mode 100644 lib/matplotlib/meson.build create mode 100644 lib/matplotlib/projections/meson.build create mode 100644 lib/matplotlib/sphinxext/meson.build create mode 100644 lib/matplotlib/style/meson.build create mode 100644 lib/matplotlib/testing/jpl_units/meson.build create mode 100644 lib/matplotlib/testing/meson.build create mode 100644 lib/matplotlib/tests/meson.build create mode 100644 lib/matplotlib/tri/meson.build create mode 100644 lib/meson.build create mode 100644 lib/mpl_toolkits/axes_grid1/meson.build create mode 100644 lib/mpl_toolkits/axes_grid1/tests/meson.build create mode 100644 lib/mpl_toolkits/axisartist/meson.build create mode 100644 lib/mpl_toolkits/axisartist/tests/meson.build create mode 100644 lib/mpl_toolkits/meson.build create mode 100644 lib/mpl_toolkits/mplot3d/meson.build create mode 100644 lib/mpl_toolkits/mplot3d/tests/meson.build delete mode 100644 mplsetup.cfg.template delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 setupext.py diff --git a/.flake8 b/.flake8 index ee739cdf4231..00cd213e0f79 100644 --- a/.flake8 +++ b/.flake8 @@ -31,8 +31,6 @@ exclude = .eggs per-file-ignores = - setup.py: E402 - lib/matplotlib/__init__.py: E402, F401 lib/matplotlib/_animation_data.py: E501 lib/matplotlib/_api/__init__.py: F401 diff --git a/lib/matplotlib/_api/meson.build b/lib/matplotlib/_api/meson.build new file mode 100644 index 000000000000..57aa234ab878 --- /dev/null +++ b/lib/matplotlib/_api/meson.build @@ -0,0 +1,12 @@ +python_sources = [ + '__init__.py', + 'deprecation.py', +] + +typing_sources = [ + '__init__.pyi', + 'deprecation.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/_api') diff --git a/lib/matplotlib/axes/meson.build b/lib/matplotlib/axes/meson.build new file mode 100644 index 000000000000..8de3c9c382d7 --- /dev/null +++ b/lib/matplotlib/axes/meson.build @@ -0,0 +1,16 @@ +python_sources = [ + '__init__.py', + '_axes.py', + '_base.py', + '_secondary_axes.py', +] + +typing_sources = [ + '__init__.pyi', + '_axes.pyi', + '_base.pyi', + '_secondary_axes.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/axes') diff --git a/lib/matplotlib/backends/meson.build b/lib/matplotlib/backends/meson.build new file mode 100644 index 000000000000..050cc616b42c --- /dev/null +++ b/lib/matplotlib/backends/meson.build @@ -0,0 +1,49 @@ +python_sources = [ + '__init__.py', + 'backend_agg.py', + 'backend_cairo.py', + '_backend_gtk.py', + 'backend_gtk3.py', + 'backend_gtk3agg.py', + 'backend_gtk3cairo.py', + 'backend_gtk4.py', + 'backend_gtk4agg.py', + 'backend_gtk4cairo.py', + 'backend_macosx.py', + 'backend_mixed.py', + 'backend_nbagg.py', + '_backend_pdf_ps.py', + 'backend_pdf.py', + 'backend_pgf.py', + 'backend_ps.py', + 'backend_qt.py', + 'backend_qtagg.py', + 'backend_qtcairo.py', + 'backend_qt5.py', + 'backend_qt5agg.py', + 'backend_qt5cairo.py', + 'backend_svg.py', + 'backend_template.py', + '_backend_tk.py', + 'backend_tkagg.py', + 'backend_tkcairo.py', + 'backend_webagg.py', + 'backend_webagg_core.py', + 'backend_wx.py', + 'backend_wxagg.py', + 'backend_wxcairo.py', + 'qt_compat.py', +] + +typing_sources = [ + # Compiled extension types. + '_backend_agg.pyi', + '_macosx.pyi', + '_tkagg.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/backends') + +subdir('qt_editor') +subdir('web_backend') diff --git a/lib/matplotlib/backends/qt_editor/meson.build b/lib/matplotlib/backends/qt_editor/meson.build new file mode 100644 index 000000000000..1f4ea9cd4691 --- /dev/null +++ b/lib/matplotlib/backends/qt_editor/meson.build @@ -0,0 +1,11 @@ +python_sources = [ + '__init__.py', + '_formlayout.py', + 'figureoptions.py', +] + +typing_sources = [ +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/backends/qt_editor') diff --git a/lib/matplotlib/backends/web_backend/meson.build b/lib/matplotlib/backends/web_backend/meson.build new file mode 100644 index 000000000000..f8025d1742d3 --- /dev/null +++ b/lib/matplotlib/backends/web_backend/meson.build @@ -0,0 +1,14 @@ +install_dir = py3.get_install_dir(subdir: 'matplotlib/backends/web_backend') + +install_data( + 'all_figures.html', + 'ipython_inline_figure.html', + 'single_figure.html', + install_tag: 'data', + install_dir: install_dir) +install_subdir('css', install_tag: 'data', install_dir: install_dir) +install_subdir('js', install_tag: 'data', install_dir: install_dir) +install_data( + 'nbagg_uat.ipynb', + install_tag: 'tests', + install_dir: install_dir) diff --git a/lib/matplotlib/meson.build b/lib/matplotlib/meson.build new file mode 100644 index 000000000000..4f8d93d1f01d --- /dev/null +++ b/lib/matplotlib/meson.build @@ -0,0 +1,154 @@ +python_sources = [ + '__init__.py', + '_afm.py', + '_animation_data.py', + '_blocking_input.py', + '_cm.py', + '_cm_listed.py', + '_color_data.py', + '_constrained_layout.py', + '_docstring.py', + '_enums.py', + '_fontconfig_pattern.py', + '_internal_utils.py', + '_layoutgrid.py', + '_mathtext.py', + '_mathtext_data.py', + '_pylab_helpers.py', + '_text_helpers.py', + '_tight_bbox.py', + '_tight_layout.py', + '_type1font.py', + 'animation.py', + 'artist.py', + 'axis.py', + 'backend_bases.py', + 'backend_managers.py', + 'backend_tools.py', + 'bezier.py', + 'category.py', + 'cbook.py', + 'cm.py', + 'collections.py', + 'colorbar.py', + 'colors.py', + 'container.py', + 'contour.py', + 'dates.py', + 'dviread.py', + 'figure.py', + 'font_manager.py', + 'gridspec.py', + 'hatch.py', + 'image.py', + 'layout_engine.py', + 'legend_handler.py', + 'legend.py', + 'lines.py', + 'markers.py', + 'mathtext.py', + 'mlab.py', + 'offsetbox.py', + 'patches.py', + 'patheffects.py', + 'path.py', + 'pylab.py', + 'pyplot.py', + 'quiver.py', + 'rcsetup.py', + 'sankey.py', + 'scale.py', + 'spines.py', + 'stackplot.py', + 'streamplot.py', + 'table.py', + 'texmanager.py', + 'textpath.py', + 'text.py', + 'ticker.py', + 'transforms.py', + 'typing.py', + 'units.py', + 'widgets.py', +] + +typing_sources = [ + 'py.typed', + # Compiled extension types. + '_c_internal_utils.pyi', + 'ft2font.pyi', + '_image.pyi', + '_qhull.pyi', + '_tri.pyi', + # Pure Python types. + '__init__.pyi', + '_color_data.pyi', + '_docstring.pyi', + '_enums.pyi', + '_path.pyi', + '_pylab_helpers.pyi', + '_ttconv.pyi', + 'animation.pyi', + 'artist.pyi', + 'axis.pyi', + 'backend_bases.pyi', + 'backend_managers.pyi', + 'backend_tools.pyi', + 'bezier.pyi', + 'cbook.pyi', + 'cm.pyi', + 'collections.pyi', + 'colorbar.pyi', + 'colors.pyi', + 'container.pyi', + 'contour.pyi', + 'dviread.pyi', + 'figure.pyi', + 'font_manager.pyi', + 'gridspec.pyi', + 'hatch.pyi', + 'image.pyi', + 'layout_engine.pyi', + 'legend_handler.pyi', + 'legend.pyi', + 'lines.pyi', + 'markers.pyi', + 'mathtext.pyi', + 'mlab.pyi', + 'offsetbox.pyi', + 'patches.pyi', + 'patheffects.pyi', + 'path.pyi', + 'quiver.pyi', + 'rcsetup.pyi', + 'sankey.pyi', + 'scale.pyi', + 'spines.pyi', + 'stackplot.pyi', + 'streamplot.pyi', + 'table.pyi', + 'texmanager.pyi', + 'textpath.pyi', + 'text.pyi', + 'ticker.pyi', + 'transforms.pyi', + 'widgets.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib') + +subdir('_api') +subdir('axes') +subdir('backends') +subdir('projections') +subdir('sphinxext') +subdir('style') +subdir('testing') +subdir('tests') +subdir('tri') + +install_subdir( + 'mpl-data', + install_tag: 'data', + install_dir: py3.get_install_dir(subdir: 'matplotlib')) diff --git a/lib/matplotlib/projections/meson.build b/lib/matplotlib/projections/meson.build new file mode 100644 index 000000000000..221b93efadee --- /dev/null +++ b/lib/matplotlib/projections/meson.build @@ -0,0 +1,14 @@ +python_sources = [ + '__init__.py', + 'geo.py', + 'polar.py', +] + +typing_sources = [ + '__init__.pyi', + 'geo.pyi', + 'polar.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/projections') diff --git a/lib/matplotlib/sphinxext/meson.build b/lib/matplotlib/sphinxext/meson.build new file mode 100644 index 000000000000..5dc7388384eb --- /dev/null +++ b/lib/matplotlib/sphinxext/meson.build @@ -0,0 +1,12 @@ +python_sources = [ + '__init__.py', + 'figmpl_directive.py', + 'mathmpl.py', + 'plot_directive.py', +] + +typing_sources = [ +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/sphinxext') diff --git a/lib/matplotlib/style/meson.build b/lib/matplotlib/style/meson.build new file mode 100644 index 000000000000..03e7972132bb --- /dev/null +++ b/lib/matplotlib/style/meson.build @@ -0,0 +1,11 @@ +python_sources = [ + '__init__.py', + 'core.py', +] + +typing_sources = [ + 'core.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/style') diff --git a/lib/matplotlib/testing/jpl_units/meson.build b/lib/matplotlib/testing/jpl_units/meson.build new file mode 100644 index 000000000000..c950f0bfa4dd --- /dev/null +++ b/lib/matplotlib/testing/jpl_units/meson.build @@ -0,0 +1,16 @@ +python_sources = [ + '__init__.py', + 'Duration.py', + 'EpochConverter.py', + 'Epoch.py', + 'StrConverter.py', + 'UnitDblConverter.py', + 'UnitDblFormatter.py', + 'UnitDbl.py', +] + +typing_sources = [ +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/testing/jpl_units') diff --git a/lib/matplotlib/testing/meson.build b/lib/matplotlib/testing/meson.build new file mode 100644 index 000000000000..1016f81941ca --- /dev/null +++ b/lib/matplotlib/testing/meson.build @@ -0,0 +1,22 @@ +python_sources = [ + '__init__.py', + '_markers.py', + 'compare.py', + 'conftest.py', + 'decorators.py', + 'exceptions.py', + 'widgets.py', +] + +typing_sources = [ + '__init__.pyi', + 'compare.pyi', + 'conftest.pyi', + 'decorators.pyi', + 'widgets.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/testing') + +subdir('jpl_units') diff --git a/lib/matplotlib/tests/meson.build b/lib/matplotlib/tests/meson.build new file mode 100644 index 000000000000..148a40f11a2f --- /dev/null +++ b/lib/matplotlib/tests/meson.build @@ -0,0 +1,113 @@ +python_sources = [ + '__init__.py', + 'conftest.py', + 'test_afm.py', + 'test_agg_filter.py', + 'test_agg.py', + 'test_animation.py', + 'test_api.py', + 'test_arrow_patches.py', + 'test_artist.py', + 'test_axes.py', + 'test_axis.py', + 'test_backend_bases.py', + 'test_backend_cairo.py', + 'test_backend_gtk3.py', + 'test_backend_macosx.py', + 'test_backend_nbagg.py', + 'test_backend_pdf.py', + 'test_backend_pgf.py', + 'test_backend_ps.py', + 'test_backend_qt.py', + 'test_backends_interactive.py', + 'test_backend_svg.py', + 'test_backend_template.py', + 'test_backend_tk.py', + 'test_backend_tools.py', + 'test_backend_webagg.py', + 'test_basic.py', + 'test_bbox_tight.py', + 'test_category.py', + 'test_cbook.py', + 'test_collections.py', + 'test_colorbar.py', + 'test_colors.py', + 'test_compare_images.py', + 'test_constrainedlayout.py', + 'test_container.py', + 'test_contour.py', + 'test_cycles.py', + 'test_dates.py', + 'test_datetime.py', + 'test_determinism.py', + 'test_doc.py', + 'test_dviread.py', + 'test_figure.py', + 'test_fontconfig_pattern.py', + 'test_font_manager.py', + 'test_ft2font.py', + 'test_getattr.py', + 'test_gridspec.py', + 'test_image.py', + 'test_legend.py', + 'test_lines.py', + 'test_marker.py', + 'test_mathtext.py', + 'test_matplotlib.py', + 'test_mlab.py', + 'test_offsetbox.py', + 'test_patches.py', + 'test_patheffects.py', + 'test_path.py', + 'test_pickle.py', + 'test_png.py', + 'test_polar.py', + 'test_preprocess_data.py', + 'test_pyplot.py', + 'test_quiver.py', + 'test_rcparams.py', + 'test_sankey.py', + 'test_scale.py', + 'test_simplification.py', + 'test_skew.py', + 'test_sphinxext.py', + 'test_spines.py', + 'test_streamplot.py', + 'test_style.py', + 'test_subplots.py', + 'test_table.py', + 'test_testing.py', + 'test_texmanager.py', + 'test_textpath.py', + 'test_text.py', + 'test_ticker.py', + 'test_tightlayout.py', + 'test_transforms.py', + 'test_triangulation.py', + 'test_ttconv.py', + 'test_type1font.py', + 'test_units.py', + 'test_usetex.py', + 'test_widgets.py', +] + +py3.install_sources(python_sources, + subdir: 'matplotlib/tests') + +install_data( + 'README', + 'Courier10PitchBT-Bold.pfb', + 'cmr10.pfb', + 'mpltest.ttf', + 'test_nbagg_01.ipynb', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'matplotlib/tests/')) + +install_subdir( + 'baseline_images', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'matplotlib/tests')) +install_subdir( + 'tinypages', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'matplotlib/tests')) diff --git a/lib/matplotlib/tri/meson.build b/lib/matplotlib/tri/meson.build new file mode 100644 index 000000000000..9e71f3348c69 --- /dev/null +++ b/lib/matplotlib/tri/meson.build @@ -0,0 +1,25 @@ +python_sources = [ + '__init__.py', + '_triangulation.py', + '_tricontour.py', + '_trifinder.py', + '_triinterpolate.py', + '_tripcolor.py', + '_triplot.py', + '_trirefine.py', + '_tritools.py', +] + +typing_sources = [ + '_triangulation.pyi', + '_tricontour.pyi', + '_trifinder.pyi', + '_triinterpolate.pyi', + '_tripcolor.pyi', + '_triplot.pyi', + '_trirefine.pyi', + '_tritools.pyi', +] + +py3.install_sources(python_sources, typing_sources, + subdir: 'matplotlib/tri') diff --git a/lib/meson.build b/lib/meson.build new file mode 100644 index 000000000000..9701a7da98dd --- /dev/null +++ b/lib/meson.build @@ -0,0 +1,8 @@ +python_sources = [ + 'pylab.py', +] + +py3.install_sources(python_sources) + +subdir('matplotlib') +subdir('mpl_toolkits') diff --git a/lib/mpl_toolkits/axes_grid1/meson.build b/lib/mpl_toolkits/axes_grid1/meson.build new file mode 100644 index 000000000000..7dd5c3861163 --- /dev/null +++ b/lib/mpl_toolkits/axes_grid1/meson.build @@ -0,0 +1,15 @@ +python_sources = [ + '__init__.py', + 'anchored_artists.py', + 'axes_divider.py', + 'axes_grid.py', + 'axes_rgb.py', + 'axes_size.py', + 'inset_locator.py', + 'mpl_axes.py', + 'parasite_axes.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/axes_grid1') + +subdir('tests') diff --git a/lib/mpl_toolkits/axes_grid1/tests/meson.build b/lib/mpl_toolkits/axes_grid1/tests/meson.build new file mode 100644 index 000000000000..980bf173cc10 --- /dev/null +++ b/lib/mpl_toolkits/axes_grid1/tests/meson.build @@ -0,0 +1,12 @@ +python_sources = [ + '__init__.py', + 'conftest.py', + 'test_axes_grid1.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/axes_grid1/tests') + +install_subdir( + 'baseline_images', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'mpl_toolkits/axes_grid1/tests')) diff --git a/lib/mpl_toolkits/axisartist/meson.build b/lib/mpl_toolkits/axisartist/meson.build new file mode 100644 index 000000000000..8d9314e42576 --- /dev/null +++ b/lib/mpl_toolkits/axisartist/meson.build @@ -0,0 +1,18 @@ +python_sources = [ + '__init__.py', + 'angle_helper.py', + 'axes_divider.py', + 'axes_grid.py', + 'axes_rgb.py', + 'axis_artist.py', + 'axislines.py', + 'axisline_style.py', + 'floating_axes.py', + 'grid_finder.py', + 'grid_helper_curvelinear.py', + 'parasite_axes.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/axisartist') + +subdir('tests') diff --git a/lib/mpl_toolkits/axisartist/tests/meson.build b/lib/mpl_toolkits/axisartist/tests/meson.build new file mode 100644 index 000000000000..634c8190a037 --- /dev/null +++ b/lib/mpl_toolkits/axisartist/tests/meson.build @@ -0,0 +1,17 @@ +python_sources = [ + '__init__.py', + 'conftest.py', + 'test_angle_helper.py', + 'test_axis_artist.py', + 'test_axislines.py', + 'test_floating_axes.py', + 'test_grid_finder.py', + 'test_grid_helper_curvelinear.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/axisartist/tests') + +install_subdir( + 'baseline_images', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'mpl_toolkits/axisartist/tests')) diff --git a/lib/mpl_toolkits/meson.build b/lib/mpl_toolkits/meson.build new file mode 100644 index 000000000000..290cd6139f94 --- /dev/null +++ b/lib/mpl_toolkits/meson.build @@ -0,0 +1,3 @@ +subdir('axes_grid1') +subdir('axisartist') +subdir('mplot3d') diff --git a/lib/mpl_toolkits/mplot3d/meson.build b/lib/mpl_toolkits/mplot3d/meson.build new file mode 100644 index 000000000000..2d9cade6c93c --- /dev/null +++ b/lib/mpl_toolkits/mplot3d/meson.build @@ -0,0 +1,11 @@ +python_sources = [ + '__init__.py', + 'art3d.py', + 'axes3d.py', + 'axis3d.py', + 'proj3d.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/mplot3d') + +subdir('tests') diff --git a/lib/mpl_toolkits/mplot3d/tests/meson.build b/lib/mpl_toolkits/mplot3d/tests/meson.build new file mode 100644 index 000000000000..7a638aedf72b --- /dev/null +++ b/lib/mpl_toolkits/mplot3d/tests/meson.build @@ -0,0 +1,14 @@ +python_sources = [ + '__init__.py', + 'conftest.py', + 'test_art3d.py', + 'test_axes3d.py', + 'test_legend3d.py', +] + +py3.install_sources(python_sources, subdir: 'mpl_toolkits/mplot3d/tests') + +install_subdir( + 'baseline_images', + install_tag: 'tests', + install_dir: py3.get_install_dir(subdir: 'mpl_toolkits/mplot3d/tests')) diff --git a/meson.build b/meson.build index c294eea2a678..1ba673948a1e 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,7 @@ project( # Carlogo, STIX and Computer Modern is OFL # DejaVu is Bitstream Vera and Public Domain license: 'PSF-2.0 AND MIT AND CC0-1.0 AND OFL-1.1 AND Bitstream-Vera AND Public-Domain', + meson_version: '>=1.1.0', default_options: [ 'b_lto=true', 'cpp_std=c++11', @@ -19,10 +20,11 @@ cpp = meson.get_compiler('cpp') # https://mesonbuild.com/Python-module.html py_mod = import('python') -py3 = py_mod.find_installation() +py3 = py_mod.find_installation(pure: false) py3_dep = py3.dependency() pybind11_dep = dependency('pybind11', version: '>=2.6') subdir('extern') subdir('src') +subdir('lib') diff --git a/meson_options.txt b/meson_options.txt index 0b10c331ae48..ed753bb26854 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -15,3 +15,14 @@ option('system-qhull', type: 'boolean', value: false, # of the config value. option('macosx', type: 'boolean', value: true, description: 'Enable MacOSX backend (requires Cocoa)') + +# User-configurable options +# +# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo, +# MacOSX, Pdf, Ps, QtAgg, QtCairo, SVG, TkAgg, WX, WXAgg. +# +# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do +# not choose MacOSX if you have disabled the relevant extension modules. The +# default is determined by fallback. +option('rcParams-backend', type: 'string', value: 'auto', + description: 'Set default backend at runtime') diff --git a/mplsetup.cfg.template b/mplsetup.cfg.template deleted file mode 100644 index 30985b2e313d..000000000000 --- a/mplsetup.cfg.template +++ /dev/null @@ -1,38 +0,0 @@ -# Rename this file to mplsetup.cfg to modify Matplotlib's build options. - -[libs] -# By default, Matplotlib builds with LTO, which may be slow if you re-compile -# often, and don't need the space saving/speedup. -# -#enable_lto = True -# -# By default, Matplotlib downloads and builds its own copies of FreeType and of -# Qhull. You may set the following to True to instead link against a system -# FreeType/Qhull. As an exception, Matplotlib defaults to the system version -# of FreeType on AIX. -# -#system_freetype = False -#system_qhull = False - -[packages] -# Some of Matplotlib's components are optional: the MacOSX backend (installed -# by default on MacOSX; requires the Cocoa headers included with XCode), and -# the test data (i.e., the baseline image files; not installed by default). -# You can control whether they are installed by uncommenting the following -# lines. Note that the MacOSX backend is never built on Linux or Windows, -# regardless of the config value. -# -#tests = False -#macosx = True - -[rc_options] -# User-configurable options -# -# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo, -# MacOSX, Pdf, Ps, QtAgg, QtCairo, SVG, TkAgg, WX, WXAgg. -# -# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do -# not choose MacOSX if you have disabled the relevant extension modules. The -# default is determined by fallback. -# -#backend = Agg diff --git a/pyproject.toml b/pyproject.toml index 423d6352ae8f..37d97e02b956 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,8 +40,6 @@ dependencies = [ "pillow >= 8", "pyparsing >= 2.3.1", "python-dateutil >= 2.7", - "setuptools >= 64", - "setuptools_scm >= 7", "importlib-resources >= 3.2.0; python_version < '3.10'", ] requires-python = ">=3.9" @@ -49,11 +47,16 @@ requires-python = ">=3.9" [project.optional-dependencies] # Should be a copy of the build dependencies below. dev = [ - "certifi>=2020.06.20", + "meson-python>=0.13.1", "numpy>=1.25", "pybind11>=2.6", - "setuptools>=64", "setuptools_scm>=7", + # Not required by us but setuptools_scm without a version, cso _if_ + # installed, then setuptools_scm 8 requires at least this version. + # Unfortunately, we can't do a sort of minimum-if-instaled dependency, so + # we need to keep this for now until setuptools_scm _fully_ drops + # setuptools. + "setuptools>=64", ] [project.urls] @@ -66,35 +69,17 @@ dev = [ "Donate" = "https://numfocus.org/donate-to-matplotlib" [build-system] -build-backend = "setuptools.build_meta" +build-backend = "mesonpy" # Also keep in sync with optional dependencies above. requires = [ - "certifi>=2020.06.20", + "meson-python>=0.13.1", "numpy>=1.25", "pybind11>=2.6", - "setuptools>=64", "setuptools_scm>=7", ] -[tool.setuptools] -platforms = ["any"] -py-modules = ["pylab"] -license-files = ["LICENSE/*"] -namespace-packages = ["mpl_toolkits"] - -[tool.setuptools.packages.find] -where = ["lib"] -include = ["matplotlib*", "mpl_toolkits*"] -exclude = [ - "matplotlib.tests*", - "mpl_toolkits.axes_grid1.tests*", - "mpl_toolkits.axisartist.tests*", - "mpl_toolkits.mplot3d.tests*", -] -namespaces = true - -[tool.setuptools.exclude-package-data] -"*" = ["*.png", "*.svg"] +[tool.meson-python.args] +install = ['--tags=data,python-runtime,runtime'] [tool.setuptools_scm] version_scheme = "release-branch-semver" @@ -171,8 +156,6 @@ target-version = "py39" convention = "numpy" [tool.ruff.per-file-ignores] -"setup.py" = ["E402"] - "doc/conf.py" = ["E402"] "galleries/examples/animation/frame_grabbing_sgskip.py" = ["E402"] "galleries/examples/lines_bars_and_markers/marker_reference.py" = ["E402"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9d4cf0e7b72c..000000000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -# NOTE: Matplotlib-specific configuration options have been moved to -# mplsetup.cfg.template. - -[metadata] -license_files = LICENSE/* diff --git a/setup.py b/setup.py deleted file mode 100644 index 66698a3aed6c..000000000000 --- a/setup.py +++ /dev/null @@ -1,290 +0,0 @@ -""" -The Matplotlib build options can be modified with a mplsetup.cfg file. See -mplsetup.cfg.template for more information. -""" - -# NOTE: This file must remain Python 2 compatible for the foreseeable future, -# to ensure that we error out properly for people with outdated setuptools -# and/or pip. -import sys - -py_min_version = (3, 9) # minimal supported python version -since_mpl_version = (3, 8) # py_min_version is required since this mpl version - -if sys.version_info < py_min_version: - error = """ -Beginning with Matplotlib {0}, Python {1} or above is required. -You are using Python {2}. - -This may be due to an out of date pip. - -Make sure you have pip >= 9.0.1. -""".format('.'.join(str(n) for n in since_mpl_version), - '.'.join(str(n) for n in py_min_version), - '.'.join(str(n) for n in sys.version_info[:3])) - sys.exit(error) - -import os -from pathlib import Path -import shutil -import subprocess - -from setuptools import setup, Distribution, Extension -import setuptools.command.build_ext -import setuptools.command.build_py -import setuptools.command.sdist - -# sys.path modified to find setupext.py during pyproject.toml builds. -sys.path.append(str(Path(__file__).resolve().parent)) - -import setupext -from setupext import print_raw, print_status - - -# These are the packages in the order we want to display them. -mpl_packages = [ - setupext.Matplotlib(), - setupext.Python(), - setupext.Platform(), - setupext.FreeType(), - setupext.Qhull(), - setupext.Tests(), - setupext.BackendMacOSX(), - ] - - -# From https://bugs.python.org/issue26689 -def has_flag(self, flagname): - """Return whether a flag name is supported on the specified compiler.""" - import tempfile - with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: - f.write('int main (int argc, char **argv) { return 0; }') - try: - self.compile([f.name], extra_postargs=[flagname]) - except Exception as exc: - # https://github.com/pypa/setuptools/issues/2698 - if type(exc).__name__ != "CompileError": - raise - return False - return True - - -class BuildExtraLibraries(setuptools.command.build_ext.build_ext): - def finalize_options(self): - # If coverage is enabled then need to keep the .o and .gcno files in a - # non-temporary directory otherwise coverage info not collected. - cppflags = os.getenv('CPPFLAGS') - if cppflags and '--coverage' in cppflags: - self.build_temp = 'build' - - self.distribution.ext_modules[:] = [ - ext - for package in good_packages - for ext in package.get_extensions() - ] - super().finalize_options() - - def add_optimization_flags(self): - """ - Add optional optimization flags to extension. - - This adds flags for LTO and hidden visibility to both compiled - extensions, and to the environment variables so that vendored libraries - will also use them. If the compiler does not support these flags, then - none are added. - """ - - env = os.environ.copy() - if sys.platform == 'win32': - return env - enable_lto = setupext.config.getboolean('libs', 'enable_lto', - fallback=None) - - def prepare_flags(name, enable_lto): - """ - Prepare *FLAGS from the environment. - - If set, return them, and also check whether LTO is disabled in each - one, raising an error if Matplotlib config explicitly enabled LTO. - """ - if name in os.environ: - if '-fno-lto' in os.environ[name]: - if enable_lto is True: - raise ValueError('Configuration enable_lto=True, but ' - '{0} contains -fno-lto'.format(name)) - enable_lto = False - return [os.environ[name]], enable_lto - return [], enable_lto - - _, enable_lto = prepare_flags('CFLAGS', enable_lto) # Only check lto. - cppflags, enable_lto = prepare_flags('CPPFLAGS', enable_lto) - cxxflags, enable_lto = prepare_flags('CXXFLAGS', enable_lto) - ldflags, enable_lto = prepare_flags('LDFLAGS', enable_lto) - - if enable_lto is False: - return env - - if has_flag(self.compiler, '-fvisibility=hidden'): - for ext in self.extensions: - ext.extra_compile_args.append('-fvisibility=hidden') - cppflags.append('-fvisibility=hidden') - if has_flag(self.compiler, '-fvisibility-inlines-hidden'): - for ext in self.extensions: - if self.compiler.detect_language(ext.sources) != 'cpp': - continue - ext.extra_compile_args.append('-fvisibility-inlines-hidden') - cxxflags.append('-fvisibility-inlines-hidden') - ranlib = 'RANLIB' in env - if not ranlib and self.compiler.compiler_type == 'unix': - try: - result = subprocess.run(self.compiler.compiler + - ['--version'], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - universal_newlines=True) - except Exception: - pass - else: - version = result.stdout.lower() - if 'gcc' in version: - ranlib = shutil.which('gcc-ranlib') - elif 'clang' in version: - if sys.platform == 'darwin': - ranlib = True - else: - ranlib = shutil.which('llvm-ranlib') - if ranlib and has_flag(self.compiler, '-flto'): - for ext in self.extensions: - ext.extra_compile_args.append('-flto') - cppflags.append('-flto') - ldflags.append('-flto') - # Needed so FreeType static library doesn't lose its LTO objects. - if isinstance(ranlib, str): - env['RANLIB'] = ranlib - - env['CPPFLAGS'] = ' '.join(cppflags) - env['CXXFLAGS'] = ' '.join(cxxflags) - env['LDFLAGS'] = ' '.join(ldflags) - - return env - - def build_extensions(self): - if (self.compiler.compiler_type == 'msvc' and - os.environ.get('MPL_DISABLE_FH4')): - # Disable FH4 Exception Handling implementation so that we don't - # require VCRUNTIME140_1.dll. For more details, see: - # https://devblogs.microsoft.com/cppblog/making-cpp-exception-handling-smaller-x64/ - # https://github.com/joerick/cibuildwheel/issues/423#issuecomment-677763904 - for ext in self.extensions: - ext.extra_compile_args.append('/d2FH4-') - - env = self.add_optimization_flags() - for package in good_packages: - package.do_custom_build(env) - # Make sure we don't accidentally use too modern C++ constructs, even - # though modern compilers default to enabling them. Enabling this for - # a single platform is enough; also only do this for C++-only - # extensions as clang refuses to compile C/ObjC with -std=c++11. - if sys.platform != "win32": - for ext in self.distribution.ext_modules[:]: - if not any(src.endswith((".c", ".m")) for src in ext.sources): - ext.extra_compile_args.append("-std=c++11") - return super().build_extensions() - - def build_extension(self, ext): - # When C coverage is enabled, the path to the object file is saved. - # Since we re-use source files in multiple extensions, libgcov will - # complain at runtime that it is trying to save coverage for the same - # object file at different timestamps (since each source is compiled - # again for each extension). Thus, we need to use unique temporary - # build directories to store object files for each extension. - orig_build_temp = self.build_temp - self.build_temp = os.path.join(self.build_temp, ext.name) - try: - super().build_extension(ext) - finally: - self.build_temp = orig_build_temp - - -def update_matplotlibrc(path): - # If packagers want to change the default backend, insert a `#backend: ...` - # line. Otherwise, use the default `##backend: Agg` which has no effect - # even after decommenting, which allows _auto_backend_sentinel to be filled - # in at import time. - template_lines = path.read_text(encoding="utf-8").splitlines(True) - backend_line_idx, = [ # Also asserts that there is a single such line. - idx for idx, line in enumerate(template_lines) - if "#backend:" in line] - template_lines[backend_line_idx] = ( - "#backend: {}\n".format(setupext.options["backend"]) - if setupext.options["backend"] - else "##backend: Agg\n") - path.write_text("".join(template_lines), encoding="utf-8") - - -class BuildPy(setuptools.command.build_py.build_py): - def run(self): - super().run() - if not getattr(self, 'editable_mode', False): - update_matplotlibrc( - Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc")) - - -class Sdist(setuptools.command.sdist.sdist): - def make_release_tree(self, base_dir, files): - super().make_release_tree(base_dir, files) - update_matplotlibrc( - Path(base_dir, "lib/matplotlib/mpl-data/matplotlibrc")) - -# Start with type hint data -# Will be further filled below by the various components. -package_data = {"matplotlib": ["py.typed", "**/*.pyi"]} - -# If the user just queries for information, don't bother figuring out which -# packages to build or install. -if not (any('--' + opt in sys.argv - for opt in Distribution.display_option_names + ['help']) - or 'clean' in sys.argv): - # Go through all of the packages and figure out which ones we are - # going to build/install. - print_raw() - print_raw("Edit mplsetup.cfg to change the build options; " - "suppress output with --quiet.") - print_raw() - print_raw("BUILDING MATPLOTLIB") - - good_packages = [] - for package in mpl_packages: - try: - message = package.check() - except setupext.Skipped as e: - print_status(package.name, "no [{e}]".format(e=e)) - continue - if message is not None: - print_status(package.name, - "yes [{message}]".format(message=message)) - good_packages.append(package) - - print_raw() - - # Now collect all of the information we need to build all of the packages. - for package in good_packages: - # Extension modules only get added in build_ext, as numpy will have - # been installed (as setup_requires) at that point. - data = package.get_package_data() - for key, val in data.items(): - package_data.setdefault(key, []) - package_data[key] = list(set(val + package_data[key])) - -setup( # Finally, pass this all along to setuptools to do the heavy lifting. - # Dummy extension to trigger build_ext, which will swap it out with - # real extensions that can depend on numpy for the build. - ext_modules=[Extension("", [])], - package_data=package_data, - - cmdclass={ - "build_ext": BuildExtraLibraries, - "build_py": BuildPy, - "sdist": Sdist, - }, -) diff --git a/setupext.py b/setupext.py deleted file mode 100644 index 049f46c65c7d..000000000000 --- a/setupext.py +++ /dev/null @@ -1,799 +0,0 @@ -import configparser -import functools -import hashlib -from io import BytesIO -import logging -import os -from pathlib import Path -import platform -import shlex -import shutil -import subprocess -import sys -import sysconfig -import tarfile -from tempfile import TemporaryDirectory -import textwrap -import urllib.request - -from pybind11.setup_helpers import Pybind11Extension -from setuptools import Distribution, Extension - -_log = logging.getLogger(__name__) - - -def _get_xdg_cache_dir(): - """ - Return the `XDG cache directory`__. - - __ https://specifications.freedesktop.org/basedir-spec/latest/ - """ - cache_dir = os.environ.get('XDG_CACHE_HOME') - if not cache_dir: - cache_dir = os.path.expanduser('~/.cache') - if cache_dir.startswith('~/'): # Expansion failed. - return None - return Path(cache_dir, 'matplotlib') - - -def _get_hash(data): - """Compute the sha256 hash of *data*.""" - hasher = hashlib.sha256() - hasher.update(data) - return hasher.hexdigest() - - -@functools.cache -def _get_ssl_context(): - import certifi - import ssl - return ssl.create_default_context(cafile=certifi.where()) - - -def get_from_cache_or_download(url, sha): - """ - Get bytes from the given url or local cache. - - Parameters - ---------- - url : str - The url to download. - sha : str - The sha256 of the file. - - Returns - ------- - BytesIO - The file loaded into memory. - """ - cache_dir = _get_xdg_cache_dir() - - if cache_dir is not None: # Try to read from cache. - try: - data = (cache_dir / sha).read_bytes() - except OSError: - pass - else: - if _get_hash(data) == sha: - return BytesIO(data) - - # jQueryUI's website blocks direct downloads from urllib.request's - # default User-Agent, but not (for example) wget; so I don't feel too - # bad passing in an empty User-Agent. - with urllib.request.urlopen( - urllib.request.Request(url, headers={"User-Agent": ""}), - context=_get_ssl_context()) as req: - data = req.read() - - file_sha = _get_hash(data) - if file_sha != sha: - raise Exception( - f"The downloaded file does not match the expected sha. {url} was " - f"expected to have {sha} but it had {file_sha}") - - if cache_dir is not None: # Try to cache the downloaded file. - try: - cache_dir.mkdir(parents=True, exist_ok=True) - with open(cache_dir / sha, "xb") as fout: - fout.write(data) - except OSError: - pass - - return BytesIO(data) - - -def get_and_extract_tarball(urls, sha, dirname): - """ - Obtain a tarball (from cache or download) and extract it. - - Parameters - ---------- - urls : list[str] - URLs from which download is attempted (in order of attempt), if the - tarball is not in the cache yet. - sha : str - SHA256 hash of the tarball; used both as a cache key (by - `get_from_cache_or_download`) and to validate a downloaded tarball. - dirname : path-like - Directory where the tarball is extracted. - """ - toplevel = Path("build", dirname) - if not toplevel.exists(): # Download it or load it from cache. - try: - import certifi # noqa - except ImportError as e: - raise ImportError( - f"`certifi` is unavailable ({e}) so unable to download any of " - f"the following: {urls}.") from None - - Path("build").mkdir(exist_ok=True) - for url in urls: - try: - tar_contents = get_from_cache_or_download(url, sha) - break - except Exception: - pass - else: - raise OSError( - f"Failed to download any of the following: {urls}. " - f"Please download one of these urls and extract it into " - f"'build/' at the top-level of the source repository.") - print(f"Extracting {urllib.parse.urlparse(url).path}") - with tarfile.open(fileobj=tar_contents, mode="r:gz") as tgz: - if os.path.commonpath(tgz.getnames()) != dirname: - raise OSError( - f"The downloaded tgz file was expected to have {dirname} " - f"as sole top-level directory, but that is not the case") - tgz.extractall("build") - return toplevel - - -# SHA256 hashes of the FreeType tarballs -_freetype_hashes = { - '2.6.1': - '0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014', - '2.6.2': - '8da42fc4904e600be4b692555ae1dcbf532897da9c5b9fb5ebd3758c77e5c2d4', - '2.6.3': - '7942096c40ee6fea882bd4207667ad3f24bff568b96b10fd3885e11a7baad9a3', - '2.6.4': - '27f0e38347a1850ad57f84fc4dfed68ba0bc30c96a6fa6138ef84d485dd9a8d7', - '2.6.5': - '3bb24add9b9ec53636a63ea8e867ed978c4f8fdd8f1fa5ccfd41171163d4249a', - '2.7': - '7b657d5f872b0ab56461f3bd310bd1c5ec64619bd15f0d8e08282d494d9cfea4', - '2.7.1': - '162ef25aa64480b1189cdb261228e6c5c44f212aac4b4621e28cf2157efb59f5', - '2.8': - '33a28fabac471891d0523033e99c0005b95e5618dc8ffa7fa47f9dadcacb1c9b', - '2.8.1': - '876711d064a6a1bd74beb18dd37f219af26100f72daaebd2d86cb493d7cd7ec6', - '2.9': - 'bf380e4d7c4f3b5b1c1a7b2bf3abb967bda5e9ab480d0df656e0e08c5019c5e6', - '2.9.1': - 'ec391504e55498adceb30baceebd147a6e963f636eb617424bcfc47a169898ce', - '2.10.0': - '955e17244e9b38adb0c98df66abb50467312e6bb70eac07e49ce6bd1a20e809a', - '2.10.1': - '3a60d391fd579440561bf0e7f31af2222bc610ad6ce4d9d7bd2165bca8669110', - '2.11.1': - 'f8db94d307e9c54961b39a1cc799a67d46681480696ed72ecf78d4473770f09b' -} -# This is the version of FreeType to use when building a local version. It -# must match the value in lib/matplotlib.__init__.py, and the cache path in -# `.circleci/config.yml`. Also update the docs in -# `docs/devel/dependencies.rst`. -TESTING_VERSION_OF_FREETYPE = '2.6.1' -if sys.platform.startswith('win') and platform.machine() == 'ARM64': - # older versions of freetype are not supported for win/arm64 - # Matplotlib tests will not pass - LOCAL_FREETYPE_VERSION = '2.11.1' -else: - LOCAL_FREETYPE_VERSION = TESTING_VERSION_OF_FREETYPE - -LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown') - -# Also update the cache path in `.circleci/config.yml`. -# Also update the docs in `docs/devel/dependencies.rst`. -LOCAL_QHULL_VERSION = '2020.2' -LOCAL_QHULL_HASH = ( - 'b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e') - - -# Matplotlib build options, which can be altered using mplsetup.cfg -mplsetup_cfg = os.environ.get('MPLSETUPCFG') or 'mplsetup.cfg' -config = configparser.ConfigParser() -if os.path.exists(mplsetup_cfg): - config.read(mplsetup_cfg) -options = { - 'backend': config.get('rc_options', 'backend', fallback=None), - 'system_freetype': config.getboolean( - 'libs', 'system_freetype', - fallback=sys.platform.startswith(('aix', 'os400')) - ), - 'system_qhull': config.getboolean( - 'libs', 'system_qhull', fallback=sys.platform.startswith('os400') - ), -} - - -if '-q' in sys.argv or '--quiet' in sys.argv: - def print_raw(*args, **kwargs): pass # Suppress our own output. -else: - print_raw = print - - -def print_status(package, status): - initial_indent = "%12s: " % package - indent = ' ' * 18 - print_raw(textwrap.fill(status, width=80, - initial_indent=initial_indent, - subsequent_indent=indent)) - - -@functools.cache # We only need to compute this once. -def get_pkg_config(): - """ - Get path to pkg-config and set up the PKG_CONFIG environment variable. - """ - if sys.platform == 'win32': - return None - pkg_config = os.environ.get('PKG_CONFIG') or 'pkg-config' - if shutil.which(pkg_config) is None: - print( - "IMPORTANT WARNING:\n" - " pkg-config is not installed.\n" - " Matplotlib may not be able to find some of its dependencies.") - return None - pkg_config_path = sysconfig.get_config_var('LIBDIR') - if pkg_config_path is not None: - pkg_config_path = os.path.join(pkg_config_path, 'pkgconfig') - try: - os.environ['PKG_CONFIG_PATH'] += ':' + pkg_config_path - except KeyError: - os.environ['PKG_CONFIG_PATH'] = pkg_config_path - return pkg_config - - -def pkg_config_setup_extension( - ext, package, - atleast_version=None, alt_exec=None, default_libraries=()): - """Add parameters to the given *ext* for the given *package*.""" - - # First, try to get the flags from pkg-config. - - pkg_config = get_pkg_config() - cmd = [pkg_config, package] if pkg_config else alt_exec - if cmd is not None: - try: - if pkg_config and atleast_version: - subprocess.check_call( - [*cmd, f"--atleast-version={atleast_version}"]) - # Use sys.getfilesystemencoding() to allow round-tripping - # when passed back to later subprocess calls; do not use - # locale.getpreferredencoding() which universal_newlines=True - # would do. - cflags = shlex.split( - os.fsdecode(subprocess.check_output([*cmd, "--cflags"]))) - libs = shlex.split( - os.fsdecode(subprocess.check_output([*cmd, "--libs"]))) - except (OSError, subprocess.CalledProcessError): - pass - else: - ext.extra_compile_args.extend(cflags) - ext.extra_link_args.extend(libs) - return - - # If that fails, fall back on the defaults. - - # conda Windows header and library paths. - # https://github.com/conda/conda/issues/2312 re: getting the env dir. - if sys.platform == 'win32': - conda_env_path = (os.getenv('CONDA_PREFIX') # conda >= 4.1 - or os.getenv('CONDA_DEFAULT_ENV')) # conda < 4.1 - if conda_env_path and os.path.isdir(conda_env_path): - conda_env_path = Path(conda_env_path) - ext.include_dirs.append(str(conda_env_path / "Library/include")) - ext.library_dirs.append(str(conda_env_path / "Library/lib")) - - # Default linked libs. - ext.libraries.extend(default_libraries) - - -class Skipped(Exception): - """ - Exception thrown by `SetupPackage.check` to indicate that a package should - be skipped. - """ - - -class SetupPackage: - - def check(self): - """ - If the package should be installed, return an informative string, or - None if no information should be displayed at all. - - If the package should be skipped, raise a `Skipped` exception. - - If a missing build dependency is fatal, call `sys.exit`. - """ - - def get_package_data(self): - """ - Get a package data dictionary to add to the configuration. - These are merged into to the *package_data* list passed to - `setuptools.setup`. - """ - return {} - - def get_extensions(self): - """ - Return or yield a list of C extensions (`distutils.core.Extension` - objects) to add to the configuration. These are added to the - *extensions* list passed to `setuptools.setup`. - """ - return [] - - def do_custom_build(self, env): - """ - If a package needs to do extra custom things, such as building a - third-party library, before building an extension, it should - override this method. - """ - - -class OptionalPackage(SetupPackage): - default_config = True - - def check(self): - """ - Check whether ``mplsetup.cfg`` requests this package to be installed. - - May be overridden by subclasses for additional checks. - """ - if config.getboolean("packages", self.name, - fallback=self.default_config): - return "installing" - else: # Configuration opt-out by user - raise Skipped("skipping due to configuration") - - -class Platform(SetupPackage): - name = "platform" - - def check(self): - return sys.platform - - -class Python(SetupPackage): - name = "python" - - def check(self): - return sys.version - - -def _pkg_data_helper(pkg, subdir): - """Glob "lib/$pkg/$subdir/**/*", returning paths relative to "lib/$pkg".""" - base = Path("lib", pkg) - return [str(path.relative_to(base)) for path in (base / subdir).rglob("*")] - - -class Matplotlib(SetupPackage): - name = "matplotlib" - - def get_package_data(self): - return { - 'matplotlib': [ - 'mpl-data/matplotlibrc', - *_pkg_data_helper('matplotlib', 'mpl-data'), - *_pkg_data_helper('matplotlib', 'backends/web_backend'), - '*.dll', # Only actually matters on Windows. - ], - } - - def get_extensions(self): - # agg - ext = Extension( - "matplotlib.backends._backend_agg", [ - "src/py_converters.cpp", - "src/_backend_agg.cpp", - "src/_backend_agg_wrapper.cpp", - ]) - add_numpy_flags(ext) - add_libagg_flags_and_sources(ext) - FreeType.add_flags(ext) - yield ext - # c_internal_utils - ext = Extension( - "matplotlib._c_internal_utils", ["src/_c_internal_utils.c"], - libraries=({ - "linux": ["dl"], - "win32": ["ole32", "shell32", "user32"], - }.get(sys.platform, []))) - yield ext - # ft2font - ext = Extension( - "matplotlib.ft2font", [ - "src/ft2font.cpp", - "src/ft2font_wrapper.cpp", - "src/py_converters.cpp", - ]) - FreeType.add_flags(ext) - add_numpy_flags(ext) - add_libagg_flags(ext) - yield ext - # image - ext = Pybind11Extension( - "matplotlib._image", [ - "src/_image_wrapper.cpp", - "src/py_converters_11.cpp", - ], - cxx_std=11) - # Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp - add_libagg_flags_and_sources(ext) - yield ext - # path - ext = Extension( - "matplotlib._path", [ - "src/py_converters.cpp", - "src/_path_wrapper.cpp", - ]) - add_numpy_flags(ext) - add_libagg_flags_and_sources(ext) - yield ext - # qhull - ext = Extension( - "matplotlib._qhull", ["src/_qhull_wrapper.cpp"], - define_macros=[("MPL_DEVNULL", os.devnull)]) - add_numpy_flags(ext) - Qhull.add_flags(ext) - yield ext - # tkagg - ext = Extension( - "matplotlib.backends._tkagg", [ - "src/_tkagg.cpp", - ], - include_dirs=["src"], - # psapi library needed for finding Tcl/Tk at run time. - libraries={"linux": ["dl"], "win32": ["comctl32", "psapi"], - "cygwin": ["comctl32", "psapi"]}.get(sys.platform, []), - extra_link_args={"win32": ["-mwindows"]}.get(sys.platform, [])) - add_numpy_flags(ext) - add_libagg_flags(ext) - yield ext - # tri - ext = Pybind11Extension( - "matplotlib._tri", [ - "src/tri/_tri.cpp", - "src/tri/_tri_wrapper.cpp", - ], - cxx_std=11) - yield ext - # ttconv - ext = Pybind11Extension( - "matplotlib._ttconv", [ - "src/_ttconv.cpp", - "extern/ttconv/pprdrv_tt.cpp", - "extern/ttconv/pprdrv_tt2.cpp", - "extern/ttconv/ttutil.cpp", - ], - include_dirs=["extern"], - cxx_std=11) - yield ext - - -class Tests(OptionalPackage): - name = "tests" - default_config = False - - def get_package_data(self): - return { - 'matplotlib': [ - *_pkg_data_helper('matplotlib', 'tests/baseline_images'), - *_pkg_data_helper('matplotlib', 'tests/tinypages'), - 'tests/cmr10.pfb', - 'tests/Courier10PitchBT-Bold.pfb', - 'tests/mpltest.ttf', - 'tests/test_*.ipynb', - ], - 'mpl_toolkits': [ - *_pkg_data_helper('mpl_toolkits', - 'axes_grid1/tests/baseline_images'), - *_pkg_data_helper('mpl_toolkits', - 'axisartist/tests/baseline_images'), - *_pkg_data_helper('mpl_toolkits', - 'mplot3d/tests/baseline_images'), - ] - } - - -def add_numpy_flags(ext): - import numpy as np - ext.include_dirs.append(np.get_include()) - ext.define_macros.extend([ - # Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each - # extension. - ('PY_ARRAY_UNIQUE_SYMBOL', - 'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'), - ('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'), - # Allow NumPy's printf format specifiers in C++. - ('__STDC_FORMAT_MACROS', 1), - ]) - - -def add_libagg_flags(ext): - # We need a patched Agg not available elsewhere, so always use the vendored - # version. - ext.include_dirs.insert(0, "extern/agg24-svn/include") - - -def add_libagg_flags_and_sources(ext): - # We need a patched Agg not available elsewhere, so always use the vendored - # version. - ext.include_dirs.insert(0, "extern/agg24-svn/include") - agg_sources = [ - "agg_bezier_arc.cpp", - "agg_curves.cpp", - "agg_image_filters.cpp", - "agg_trans_affine.cpp", - "agg_vcgen_contour.cpp", - "agg_vcgen_dash.cpp", - "agg_vcgen_stroke.cpp", - "agg_vpgen_segmentator.cpp", - ] - ext.sources.extend( - os.path.join("extern", "agg24-svn", "src", x) for x in agg_sources) - - -def get_ccompiler(): - """ - Return a new CCompiler instance. - - CCompiler used to be constructible via `distutils.ccompiler.new_compiler`, - but this API was removed as part of the distutils deprecation. Instead, - we trick setuptools into instantiating it by creating a dummy Distribution - with a list of extension modules that claims to be truthy, but is actually - empty, and then running the Distribution's build_ext command. (If using - a plain empty ext_modules, build_ext would early-return without doing - anything.) - """ - - class L(list): - def __bool__(self): - return True - - build_ext = Distribution({"ext_modules": L()}).get_command_obj("build_ext") - build_ext.finalize_options() - build_ext.run() - return build_ext.compiler - - -class FreeType(SetupPackage): - name = "freetype" - - @classmethod - def add_flags(cls, ext): - # checkdep_freetype2.c immediately aborts the compilation either with - # "foo.h: No such file or directory" if the header is not found, or an - # appropriate error message if the header indicates a too-old version. - ext.sources.insert(0, 'src/checkdep_freetype2.c') - if options.get('system_freetype'): - pkg_config_setup_extension( - # FreeType 2.3 has libtool version 9.11.3 as can be checked - # from the tarball. For FreeType>=2.4, there is a conversion - # table in docs/VERSIONS.txt in the FreeType source tree. - ext, 'freetype2', - atleast_version='9.11.3', - alt_exec=['freetype-config'], - default_libraries=['freetype']) - ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system')) - else: - src_path = Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}') - # Statically link to the locally-built freetype. - ext.include_dirs.insert(0, str(src_path / 'include')) - ext.extra_objects.insert( - 0, str((src_path / 'objs/.libs/libfreetype').with_suffix( - '.lib' if sys.platform == 'win32' else '.a'))) - ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'local')) - if sys.platform == 'darwin': - name = ext.name.split('.')[-1] - ext.extra_link_args.append( - f'-Wl,-exported_symbol,_PyInit_{name}') - - def do_custom_build(self, env): - # We're using a system freetype - if options.get('system_freetype'): - return - - tarball = f'freetype-{LOCAL_FREETYPE_VERSION}.tar.gz' - src_path = get_and_extract_tarball( - urls=[ - (f'https://downloads.sourceforge.net/project/freetype' - f'/freetype2/{LOCAL_FREETYPE_VERSION}/{tarball}'), - (f'https://download.savannah.gnu.org/releases/freetype' - f'/{tarball}'), - (f'https://download.savannah.gnu.org/releases/freetype' - f'/freetype-old/{tarball}') - ], - sha=LOCAL_FREETYPE_HASH, - dirname=f'freetype-{LOCAL_FREETYPE_VERSION}', - ) - - libfreetype = (src_path / "objs/.libs/libfreetype").with_suffix( - ".lib" if sys.platform == "win32" else ".a") - if libfreetype.is_file(): - return # Bail out because we have already built FreeType. - - print(f"Building freetype in {src_path}") - if sys.platform != 'win32': # compilation on non-windows - env = { - **{ - var: value - for var, value in sysconfig.get_config_vars().items() - if var in {"CC", "CFLAGS", "CXX", "CXXFLAGS", "LD", - "LDFLAGS"} - }, - **env, - } - configure_ac = Path(src_path, "builds/unix/configure.ac") - if ((src_path / "autogen.sh").exists() - and not configure_ac.exists()): - print(f"{configure_ac} does not exist. " - f"Using sh autogen.sh to generate.") - subprocess.check_call( - ["sh", "./autogen.sh"], env=env, cwd=src_path) - env["CFLAGS"] = env.get("CFLAGS", "") + " -fPIC" - configure = [ - "./configure", "--with-zlib=no", "--with-bzip2=no", - "--with-png=no", "--with-harfbuzz=no", "--enable-static", - "--disable-shared" - ] - host = sysconfig.get_config_var('HOST_GNU_TYPE') - if host is not None: # May be unset on PyPy. - configure.append(f"--host={host}") - subprocess.check_call(configure, env=env, cwd=src_path) - if 'GNUMAKE' in env: - make = env['GNUMAKE'] - elif 'MAKE' in env: - make = env['MAKE'] - else: - try: - output = subprocess.check_output(['make', '-v'], - stderr=subprocess.DEVNULL) - except subprocess.CalledProcessError: - output = b'' - if b'GNU' not in output and b'makepp' not in output: - make = 'gmake' - else: - make = 'make' - subprocess.check_call([make], env=env, cwd=src_path) - else: # compilation on windows - shutil.rmtree(src_path / "objs", ignore_errors=True) - base_path = Path( - f"build/freetype-{LOCAL_FREETYPE_VERSION}/builds/windows" - ) - vc = 'vc2010' - sln_path = base_path / vc / "freetype.sln" - # https://developercommunity.visualstudio.com/comments/190992/view.html - (sln_path.parent / "Directory.Build.props").write_text( - "" - "" - "" - # WindowsTargetPlatformVersion must be given on a single line. - "$(" - "[Microsoft.Build.Utilities.ToolLocationHelper]" - "::GetLatestSDKTargetPlatformVersion('Windows', '10.0')" - ")" - "" - "", - encoding="utf-8") - # It is not a trivial task to determine PlatformToolset to plug it - # into msbuild command, and Directory.Build.props will not override - # the value in the project file. - # The DefaultPlatformToolset is from Microsoft.Cpp.Default.props - with open(base_path / vc / "freetype.vcxproj", 'r+b') as f: - toolset_repl = b'PlatformToolset>$(DefaultPlatformToolset)<' - vcxproj = f.read().replace(b'PlatformToolset>v100<', - toolset_repl) - assert toolset_repl in vcxproj, ( - 'Upgrading Freetype might break this') - f.seek(0) - f.truncate() - f.write(vcxproj) - - cc = get_ccompiler() - cc.initialize() - # On setuptools versions that use "local" distutils, - # ``cc.spawn(["msbuild", ...])`` no longer manages to locate the - # right executable, even though they are correctly on the PATH, - # because only the env kwarg to Popen() is updated, and not - # os.environ["PATH"]. Instead, use shutil.which to walk the PATH - # and get absolute executable paths. - with TemporaryDirectory() as tmpdir: - dest = Path(tmpdir, "path") - cc.spawn([ - sys.executable, "-c", - "import pathlib, shutil, sys\n" - "dest = pathlib.Path(sys.argv[1])\n" - "dest.write_text(shutil.which('msbuild'))\n", - str(dest), - ]) - msbuild_path = dest.read_text() - msbuild_platform = ( - "ARM64" if platform.machine() == "ARM64" else - "x64" if platform.architecture()[0] == "64bit" else - "Win32") - # Freetype 2.10.0+ support static builds. - msbuild_config = ( - "Release Static" - if [*map(int, LOCAL_FREETYPE_VERSION.split("."))] >= [2, 10] - else "Release" - ) - - cc.spawn([msbuild_path, str(sln_path), - "/t:Clean;Build", - f"/p:Configuration={msbuild_config};" - f"Platform={msbuild_platform}"]) - # Move to the corresponding Unix build path. - libfreetype.parent.mkdir() - # Be robust against change of FreeType version. - lib_paths = Path(src_path / "objs").rglob('freetype*.lib') - # Select FreeType library for required platform - lib_path, = [ - p for p in lib_paths - if msbuild_platform in p.resolve().as_uri() - ] - print(f"Copying {lib_path} to {libfreetype}") - shutil.copy2(lib_path, libfreetype) - - -class Qhull(SetupPackage): - name = "qhull" - _extensions_to_update = [] - - @classmethod - def add_flags(cls, ext): - if options.get("system_qhull"): - ext.libraries.append("qhull_r") - else: - cls._extensions_to_update.append(ext) - - def do_custom_build(self, env): - if options.get('system_qhull'): - return - - toplevel = get_and_extract_tarball( - urls=["http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz"], - sha=LOCAL_QHULL_HASH, - dirname=f"qhull-{LOCAL_QHULL_VERSION}", - ) - shutil.copyfile(toplevel / "COPYING.txt", "LICENSE/LICENSE_QHULL") - - for ext in self._extensions_to_update: - qhull_path = Path(f'build/qhull-{LOCAL_QHULL_VERSION}/src') - ext.include_dirs.insert(0, str(qhull_path)) - ext.sources.extend( - map(str, sorted(qhull_path.glob('libqhull_r/*.c')))) - if sysconfig.get_config_var("LIBM") == "-lm": - ext.libraries.extend("m") - - -class BackendMacOSX(OptionalPackage): - name = 'macosx' - - def check(self): - if sys.platform != 'darwin': - raise Skipped("Mac OS-X only") - return super().check() - - def get_extensions(self): - ext = Extension( - 'matplotlib.backends._macosx', [ - 'src/_macosx.m' - ]) - ext.extra_compile_args.extend(['-Werror']) - ext.extra_link_args.extend(['-framework', 'Cocoa']) - if platform.python_implementation().lower() == 'pypy': - ext.extra_compile_args.append('-DPYPY=1') - yield ext From 05b664f09fed1fea8e13985f3e075e85f431990a Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Aug 2023 23:30:16 -0400 Subject: [PATCH 4/8] Try to generate a version from Meson --- lib/matplotlib/__init__.py | 23 ++++++++++++++--------- lib/matplotlib/_version.py.in | 1 + lib/matplotlib/meson.build | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 lib/matplotlib/_version.py.in diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 3ffe046e6ba9..821d1bdeb5ea 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -219,15 +219,20 @@ def _get_version(): if ((root / ".matplotlib-repo").exists() and (root / ".git").exists() and not (root / ".git/shallow").exists()): - import setuptools_scm - return setuptools_scm.get_version( - root=root, - version_scheme="release-branch-semver", - local_scheme="node-and-date", - fallback_version=_version.version, - ) - else: # Get the version from the _version.py setuptools_scm file. - return _version.version + try: + import setuptools_scm + except ImportError: + pass + else: + return setuptools_scm.get_version( + root=root, + version_scheme="release-branch-semver", + local_scheme="node-and-date", + fallback_version=_version.version, + ) + # Get the version from the _version.py file if not in repo or setuptools_scm is + # unavailable. + return _version.version @_api.caching_module_getattr diff --git a/lib/matplotlib/_version.py.in b/lib/matplotlib/_version.py.in new file mode 100644 index 000000000000..a809c61c2099 --- /dev/null +++ b/lib/matplotlib/_version.py.in @@ -0,0 +1 @@ +version = @VCS_TAG@ diff --git a/lib/matplotlib/meson.build b/lib/matplotlib/meson.build index 4f8d93d1f01d..7847e7c8b438 100644 --- a/lib/matplotlib/meson.build +++ b/lib/matplotlib/meson.build @@ -138,6 +138,20 @@ typing_sources = [ py3.install_sources(python_sources, typing_sources, subdir: 'matplotlib') +fs = import('fs') +if fs.exists('_version.py') + py3.install_sources('_version.py', subdir: 'matplotlib') +else + cfg = configuration_data() + cfg.set_quoted('VCS_TAG', meson.project_version()) + configure_file( + input: '_version.py.in', output: '_version.py', + configuration: cfg, + install: true, + install_tag: 'python-runtime', + install_dir: py3.get_install_dir() / 'matplotlib') +endif + subdir('_api') subdir('axes') subdir('backends') From 0c0a9d3d15e7969663c99440e1dfcf33e1b5cff6 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 30 Aug 2023 00:46:59 -0400 Subject: [PATCH 5/8] Implement backend setup in matplotlibrc --- lib/matplotlib/meson.build | 6 +----- lib/matplotlib/mpl-data/meson.build | 24 ++++++++++++++++++++++++ tools/generate_matplotlibrc.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 lib/matplotlib/mpl-data/meson.build create mode 100755 tools/generate_matplotlibrc.py diff --git a/lib/matplotlib/meson.build b/lib/matplotlib/meson.build index 7847e7c8b438..c4b66fc1b336 100644 --- a/lib/matplotlib/meson.build +++ b/lib/matplotlib/meson.build @@ -155,14 +155,10 @@ endif subdir('_api') subdir('axes') subdir('backends') +subdir('mpl-data') subdir('projections') subdir('sphinxext') subdir('style') subdir('testing') subdir('tests') subdir('tri') - -install_subdir( - 'mpl-data', - install_tag: 'data', - install_dir: py3.get_install_dir(subdir: 'matplotlib')) diff --git a/lib/matplotlib/mpl-data/meson.build b/lib/matplotlib/mpl-data/meson.build new file mode 100644 index 000000000000..00a825fbbbea --- /dev/null +++ b/lib/matplotlib/mpl-data/meson.build @@ -0,0 +1,24 @@ +custom_target('matplotlibrc', + command: [ + find_program(meson.project_source_root() / 'tools/generate_matplotlibrc.py'), + '@INPUT@', + '@OUTPUT@', + get_option('rcParams-backend') + ], + input: 'matplotlibrc', + output: 'matplotlibrc', + install: true, + install_tag: 'data', + install_dir: py3.get_install_dir(subdir: 'matplotlib/mpl-data')) + +install_data( + 'kpsewhich.lua', + install_tag: 'data', + install_dir: py3.get_install_dir(subdir: 'matplotlib/mpl-data')) + +foreach dir : ['fonts', 'images', 'plot_directive', 'sample_data', 'stylelib'] + install_subdir( + dir, + install_tag: 'data', + install_dir: py3.get_install_dir(subdir: 'matplotlib/mpl-data')) +endforeach diff --git a/tools/generate_matplotlibrc.py b/tools/generate_matplotlibrc.py new file mode 100755 index 000000000000..33d6277870da --- /dev/null +++ b/tools/generate_matplotlibrc.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +""" +Generate matplotlirc for installs. + +If packagers want to change the default backend, insert a `#backend: ...` line. +Otherwise, use the default `##backend: Agg` which has no effect even after +decommenting, which allows _auto_backend_sentinel to be filled in at import +time. +""" + +import sys +from pathlib import Path + + +if len(sys.argv) != 4: + raise SystemExit('usage: {sys.argv[0]} ') + +input = Path(sys.argv[1]) +output = Path(sys.argv[2]) +backend = sys.argv[3] + +template_lines = input.read_text(encoding="utf-8").splitlines(True) +backend_line_idx, = [ # Also asserts that there is a single such line. + idx for idx, line in enumerate(template_lines) + if "#backend:" in line] +template_lines[backend_line_idx] = ( + f"#backend: {backend}\n" if backend not in ['', 'auto'] else "##backend: Agg\n") +output.write_text("".join(template_lines), encoding="utf-8") From 8830387a497b3809ff522e0d7eb30f04d91cd266 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 2 Sep 2023 02:47:17 -0400 Subject: [PATCH 6/8] Update CI for Meson build --- .appveyor.yml | 2 +- .circleci/config.yml | 7 +++++-- .github/workflows/cibuildwheel.yml | 9 +++++---- .github/workflows/codeql-analysis.yml | 8 ++++---- .github/workflows/cygwin.yml | 14 ++++--------- .github/workflows/mypy-stubtest.yml | 3 ++- .github/workflows/tests.yml | 29 +++++++-------------------- azure-pipelines.yml | 13 ++++++++---- environment.yml | 5 +++-- requirements/testing/minver.txt | 8 +++++--- 10 files changed, 45 insertions(+), 53 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b48726bb3e51..6e71e94e58f5 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -70,7 +70,7 @@ install: test_script: # Now build the thing.. - set LINK=/LIBPATH:%cd%\lib - - pip install -ve . + - pip install -v --no-build-isolation --config-settings=setup-args="--vsenv" --editable .[dev] # this should show no freetype dll... - set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe" - '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0' diff --git a/.circleci/config.yml b/.circleci/config.yml index 680798abe5fb..e8c8c2fca394 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,7 @@ commands: graphviz \ inkscape \ lmodern \ + ninja-build \ optipng \ texlive-fonts-recommended \ texlive-latex-base \ @@ -97,6 +98,7 @@ commands: - run: name: Install Python dependencies command: | + python -m pip install --user meson-python pybind11 python -m pip install --user \ numpy<< parameters.numpy_version >> \ -r requirements/doc/doc-requirements.txt @@ -114,7 +116,8 @@ commands: version=${version#v} python -m pip install matplotlib==${version} else - python -m pip install --user -ve . + python -m pip install --user --verbose \ + --no-build-isolation --editable .[dev] fi - save_cache: key: build-deps-2 @@ -215,8 +218,8 @@ jobs: - fonts-install - pip-install - - mpl-install - doc-deps-install + - mpl-install - doc-build - doc-show-errors-warnings diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 8c76303cbb85..d4230e8f17ab 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -91,16 +91,17 @@ jobs: runs-on: ${{ matrix.os }} env: CIBW_BEFORE_BUILD: >- - pip install certifi numpy>=1.25 && + pip install numpy>=1.25 && rm -rf {package}/build CIBW_BEFORE_BUILD_WINDOWS: >- - pip install certifi delvewheel numpy>=1.25 && + pip install delvewheel numpy>=1.25 && rm -rf {package}/build CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >- delvewheel repair -w {dest_dir} {wheel} CIBW_AFTER_BUILD: >- twine check {wheel} && python {package}/ci/check_wheel_licenses.py {wheel} + CIBW_CONFIG_SETTINGS: setup-args="--vsenv" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_SKIP: "*-musllinux_aarch64" CIBW_TEST_COMMAND: >- @@ -144,11 +145,11 @@ jobs: CIBW_ARCHS: ${{ matrix.cibw_archs }} # Remove this once NumPy with Python 3.12 wheels is not pre-release. CIBW_BEFORE_BUILD: >- - pip install certifi "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" && + pip install "meson-python>=0.13.1" ninja "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" && pip install --pre "numpy>=1.25" && rm -rf {package}/build CIBW_BEFORE_BUILD_WINDOWS: >- - pip install certifi delvewheel "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" && + pip install delvewheel "meson-python>=0.13.1" ninja "pybind11>=2.6" "setuptools>=42" "setuptools_scm>=7" && pip install --pre "numpy>=1.25" && rm -rf {package}/build CIBW_ENVIRONMENT: PIP_NO_BUILD_ISOLATION=0 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d31973e954d5..5753b17922d6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,9 +41,9 @@ jobs: # dependencies so we don't need another copy here. # https://github.com/jazzband/pip-tools/pull/1681 python -m pip install --upgrade \ - certifi contourpy cycler fonttools kiwisolver importlib_resources \ - numpy packaging pillow pyparsing python-dateutil setuptools-scm \ - pybind11 + build contourpy cycler fonttools kiwisolver \ + importlib_resources meson-python numpy packaging pillow pybind11 \ + pyparsing python-dateutil setuptools-scm echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV - name: Initialize CodeQL @@ -56,7 +56,7 @@ jobs: if: matrix.language == 'cpp' run: | mkdir ~/.cache/matplotlib - $CODEQL_PYTHON setup.py build + $CODEQL_PYTHON -m build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 11ea1377b36d..feded9f0c1ad 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -203,20 +203,14 @@ jobs: AUTOCONF: /usr/bin/autoconf-2.69 MAKEFLAGS: dw run: | + export PATH="/usr/local/bin:$PATH" ccache -s git describe - cat <> mplsetup.cfg - [rc_options] - backend=Agg - - [libs] - system_freetype = False - system_qhull = True - EOT - cat mplsetup.cfg # All dependencies must have been pre-installed, so that the minver # constraints are held. - python -m pip install --no-deps -ve . + python -m pip install --no-deps --no-build-isolation --verbose \ + --config-settings=setup-args="-DrcParams-backend=Agg" \ + --editable .[dev] - name: Find DLLs to rebase shell: bash.exe -eo pipefail -o igncr "{0}" diff --git a/.github/workflows/mypy-stubtest.yml b/.github/workflows/mypy-stubtest.yml index 4cb225258f4f..8d2943e38ecf 100644 --- a/.github/workflows/mypy-stubtest.yml +++ b/.github/workflows/mypy-stubtest.yml @@ -22,7 +22,7 @@ jobs: run: | pip3 install -r requirements/testing/mypy.txt \ -r requirements/testing/all.txt - pip3 install -e . + pip3 install . - name: Set up reviewdog run: | @@ -38,6 +38,7 @@ jobs: run: | set -o pipefail MPLBACKEND=agg python tools/stubtest.py | \ + sed -e "s!$pythonLocation/lib/python3.9/site-packages!lib!g" | \ reviewdog \ -efm '%Eerror: %m' \ -efm '%CStub: in file %f:%l' \ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adff7f1ce292..a3d3d63c64fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,7 +56,6 @@ jobs: pyside2-ver: '==5.15.1' # oldest version with working Py3.9 wheel. pyside6-ver: '==6.0.0' delete-font-cache: true - no-build-isolation: true - os: ubuntu-20.04 python-version: 3.9 extra-requirements: '-r requirements/testing/extra.txt' @@ -81,7 +80,6 @@ jobs: python-version: '3.12-dev' pyside6-ver: '!=6.5.1' pre: true - no-build-isolation: true - os: macos-latest python-version: 3.9 # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 @@ -131,6 +129,7 @@ jobs: libxcb-render-util0 \ libxcb-xinerama0 \ lmodern \ + ninja-build \ pkg-config \ qtbase5-dev \ texlive-fonts-recommended \ @@ -150,7 +149,7 @@ jobs: macOS) brew install ccache brew tap homebrew/cask-fonts - brew install font-noto-sans-cjk gobject-introspection gtk4 + brew install font-noto-sans-cjk gobject-introspection gtk4 ninja ;; esac @@ -205,17 +204,14 @@ jobs: fi # Install dependencies from PyPI. + # Preinstall build requirements to enable no-build-isolation builds. python -m pip install --upgrade $PRE \ 'contourpy>=1.0.1' cycler fonttools kiwisolver importlib_resources \ numpy packaging pillow 'pyparsing!=3.1.0' python-dateutil setuptools-scm \ + 'meson-python>=0.13.1' 'pybind11>=2.6' \ -r requirements/testing/all.txt \ ${{ matrix.extra-requirements }} - # Preinstall pybind11 on no-build-isolation builds. - if [[ "${{ matrix.no-build-isolation }}" == 'true' ]]; then - python -m pip install 'pybind11>=2.6' - fi - # Install optional dependencies from PyPI. # Sphinx is needed to run sphinxext tests python -m pip install --upgrade sphinx!=6.1.2 @@ -300,20 +296,9 @@ jobs: fi fi - cat <> mplsetup.cfg - [rc_options] - backend=Agg - EOT - - cat mplsetup.cfg - - if [[ "${{ matrix.no-build-isolation }}" == 'true' ]]; then - # Minimum versions run does not use build isolation so that it - # builds against the pre-installed minver dependencies. - python -m pip install --no-deps --no-build-isolation -ve . - else - python -m pip install --no-deps -ve . - fi + python -m pip install --no-deps --no-build-isolation --verbose \ + --config-settings=setup-args="-DrcParams-backend=Agg" \ + --editable .[dev] if [[ "${{ runner.os }}" != 'macOS' ]]; then unset CPPFLAGS diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7d00e499fd18..8eb5cacfb55a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,6 +96,7 @@ stages: cm-super \ dvipng \ ffmpeg \ + fonts-freefont-otf \ fonts-noto-cjk \ fonts-wqy-zenhei \ gdb \ @@ -105,23 +106,24 @@ stages: libcairo2 \ libgirepository-1.0-1 \ lmodern \ - fonts-freefont-otf \ + ninja-build \ poppler-utils \ - texlive-pictures \ texlive-fonts-recommended \ texlive-latex-base \ texlive-latex-extra \ texlive-latex-recommended \ texlive-luatex \ + texlive-pictures \ texlive-xetex ;; darwin) brew install --cask xquartz - brew install pkg-config ffmpeg imagemagick mplayer ccache + brew install ccache ffmpeg imagemagick mplayer ninja pkg-config brew tap homebrew/cask-fonts brew install font-noto-sans-cjk-sc ;; win32) + choco install ninja ;; *) exit 1 @@ -131,12 +133,15 @@ stages: - bash: | python -m pip install --upgrade pip + python -m pip install --upgrade meson-python pybind11 python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt || [[ "$PYTHON_VERSION" = 'Pre' ]] displayName: 'Install dependencies with pip' - bash: | - python -m pip install -ve . || + python -m pip install \ + --no-build-isolation --config-settings=setup-args="--vsenv" \ + --verbose --editable .[dev] || [[ "$PYTHON_VERSION" = 'Pre' ]] displayName: "Install self" diff --git a/environment.yml b/environment.yml index 7b13735bb172..095e3d240bd2 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ # # conda env create -f environment.yml # conda activate mpl-dev -# pip install -e . +# pip install -e .[dev] # name: mpl-dev channels: @@ -15,14 +15,15 @@ dependencies: - fonttools>=4.22.0 - importlib-resources>=3.2.0 - kiwisolver>=1.3.1 + - meson-python>=0.13.1 - numpy>=1.21 - pillow>=8 + - pkg-config - pybind11>=2.6.0 - pygobject - pyparsing>=2.3.1 - pyqt - python-dateutil>=2.1 - - setuptools - setuptools_scm - wxpython # building documentation diff --git a/requirements/testing/minver.txt b/requirements/testing/minver.txt index b989922c5527..b399bd996e08 100644 --- a/requirements/testing/minver.txt +++ b/requirements/testing/minver.txt @@ -2,12 +2,14 @@ contourpy==1.0.1 cycler==0.10 -kiwisolver==1.3.1 +fonttools==4.22.0 importlib-resources==3.2.0 +kiwisolver==1.3.1 +meson-python==0.13.1 +meson==1.1.0 numpy==1.21.0 packaging==20.0 pillow==8.0.0 pyparsing==2.3.1 -python-dateutil==2.7 -fonttools==4.22.0 pytest==7.0.0 +python-dateutil==2.7 From 65545ddd98ab0964f3b96f8aecf0514e6d31a118 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 7 Sep 2023 00:42:34 -0400 Subject: [PATCH 7/8] DOC: Update documentation for Meson change --- .gitignore | 7 +- .../next_api_changes/development/26621-ES.rst | 46 +++++++++++++ doc/devel/contribute.rst | 7 +- doc/devel/dependencies.rst | 67 +++++++++---------- doc/devel/development_setup.rst | 34 +++++----- doc/devel/min_dep_policy.rst | 2 +- doc/users/faq.rst | 14 ++-- lib/matplotlib/__init__.py | 8 +-- meson_options.txt | 18 ++--- requirements/doc/doc-requirements.txt | 2 +- src/_qhull_wrapper.cpp | 2 +- 11 files changed, 126 insertions(+), 81 deletions(-) create mode 100644 doc/api/next_api_changes/development/26621-ES.rst diff --git a/.gitignore b/.gitignore index a76efc1cd47a..1514710bd9be 100644 --- a/.gitignore +++ b/.gitignore @@ -29,10 +29,10 @@ # Python files # ################ -# setup.py working directory +# meson-python working directory build -# setup.py dist directory +# meson-python/build frontend dist directory dist # Egg metadata *.egg-info @@ -41,9 +41,6 @@ dist pip-wheel-metadata/* # tox testing tool .tox -mplsetup.cfg -# generated by setuptools_scm -lib/matplotlib/_version.py # build subproject files subprojects/*/ !subprojects/packagefiles/ diff --git a/doc/api/next_api_changes/development/26621-ES.rst b/doc/api/next_api_changes/development/26621-ES.rst new file mode 100644 index 000000000000..ff87f53b3573 --- /dev/null +++ b/doc/api/next_api_changes/development/26621-ES.rst @@ -0,0 +1,46 @@ +Build system ported to Meson +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build system of Matplotlib has been ported from setuptools to `meson-python +`_ and `Meson `_. +Consequently, there have been a few changes for development and packaging purposes. + +1. Installation by ``pip`` of packages with ``pyproject.toml`` use `build isolation + `_ + by default, which interferes with editable installation. Thus for developers using + editable installs, it is now necessary to pass the ``--no-build-isolation`` flag to + ``pip install``. This means that all build-time requirements must be available in the + environment for an editable install. +2. Build configuration has moved from a custom :file:`mplsetup.cfg` (also configurable + via ``MPLSETUP`` environment variable) to Meson options. These may be specified using + `meson-python's build config settings + `_ + for ``setup-args``. See :file:`meson_options.txt` for all options. For example, a + :file:`mplsetup.cfg` containing the following:: + + [rc_options] + backend=Agg + + [libs] + system_qhull = True + + may be replaced by passing the following arguments to ``pip``:: + + --config-settings=setup-args="-DrcParams-backend=Agg" \ + --config-settings=setup-args="-Dsystem-qhull=true" + + Note that you must use ``pip`` >= 23.1 in order to pass more than one setting. +3. Relatedly, Meson's `builtin options `_ + are now used instead of custom options, e.g., the LTO option is now ``b_lto``. +4. On Windows, Meson activates a Visual Studio environment automatically. However, it + will not do so if another compiler is available. See `Meson's documentation + `_ if you wish to + change the priority of chosen compilers. +5. Installation of test data was previously controlled by :file:`mplsetup.cfg`, but has + now been moved to Meson's install tags. To install test data, add the ``tests`` + tag to the requested install (be sure to include the existing tags as below):: + + --config-settings=install-args="--tags=data,python-runtime,runtime,tests" +6. Checking typing stubs with ``stubtest`` does not work easily with editable install. + For the time being, we suggest using a normal (non-editable) install if you wish to + run ``stubtest``. diff --git a/doc/devel/contribute.rst b/doc/devel/contribute.rst index 85c061b7ce8f..976e03c97776 100644 --- a/doc/devel/contribute.rst +++ b/doc/devel/contribute.rst @@ -266,7 +266,7 @@ A brief overview of the workflow is as follows. #. Install the local version of Matplotlib with:: - python -m pip install -e . + python -m pip install --no-build-isolation --editable .[dev] See :ref:`installing_for_devs` for detailed instructions. @@ -476,9 +476,8 @@ take particular care when adding new API: New modules and files: installation ----------------------------------- -* If you have added new files or directories, or reorganized existing - ones, make sure the new files are included in the match patterns in - in *package_data* in :file:`setupext.py`. +* If you have added new files or directories, or reorganized existing ones, make sure the + new files are included in the :file:`meson.build` in the corresponding directories. * New modules *may* be typed inline or using parallel stub file like existing modules. C/C++ extensions diff --git a/doc/devel/dependencies.rst b/doc/devel/dependencies.rst index 400bc63d42ac..77df6e494d50 100644 --- a/doc/devel/dependencies.rst +++ b/doc/devel/dependencies.rst @@ -100,7 +100,8 @@ Matplotlib brings its own copies of the following libraries: Additionally, Matplotlib depends on: - FreeType_ (>= 2.3): a font rendering library -- QHull_ (>= 2020.2): a library for computing triangulations +- QHull_ (>= 8.0.2): a library for computing triangulations (note that this version is + also known as 2020.2) .. _FreeType: https://www.freetype.org/ .. _Qhull: http://www.qhull.org/ @@ -113,24 +114,16 @@ defaults to the system version of FreeType on AIX. Use system libraries ^^^^^^^^^^^^^^^^^^^^ -To force Matplotlib to use a copy of FreeType or Qhull already installed in -your system, create a :file:`mplsetup.cfg` file with the following contents: - -.. code-block:: cfg - - [libs] - system_freetype = true - system_qhull = true - -before running +To force Matplotlib to use a copy of FreeType or Qhull already installed in your system, +you must `pass configuration settings to Meson via meson-python +`_: .. code-block:: sh - python -m pip install . - - -You can also use the :envvar:`MPLSETUPCFG` to specify the path to a cfg file when -installing from pypi. + python -m pip install \ + --config-settings=setup-args="-Dsystem-freetype=true" \ + --config-settings=setup-args="-Dsystem-qhull=true" \ + . In this case, you need to install the FreeType and Qhull library and headers. @@ -187,18 +180,12 @@ remember to clear your artifacts before re-building:: Manual Download ^^^^^^^^^^^^^^^ - -If the automatic download does not work (for example on air-gapped systems) it -is preferable to instead use system libraries. However you can manually -download and unpack the tarballs into:: - - build/freetype-2.6.1 # on all platforms but windows ARM64 - build/freetype-2.11.1 # on windows ARM64 - build/qhull-2020.2 - -at the top level of the checkout repository. The expected sha256 hashes of -the downloaded tarballs is in :file:`setupext.py` if you wish to verify -before unpacking. +If the automatic download does not work (for example, on air-gapped systems) it is +preferable to instead use system libraries. However you can manually download the +tarballs into :file:`subprojects/packagecache` at the top level of the checkout +repository. The expected SHA256 hashes of the downloaded tarballs are in +:file:`subprojects/*.wrap` if you wish to verify them, but they will also be checked by +the build system before unpacking. Minimum pip / manylinux support (linux) @@ -207,7 +194,7 @@ Minimum pip / manylinux support (linux) Matplotlib publishes `manylinux wheels `_ which have a minimum version of pip which will recognize the wheels -- Python 3.9+: ``manylinx2014`` / pip >= 19.3 +- Python 3.9+: ``manylinux2014`` / pip >= 19.3 In all cases the required version of pip is embedded in the CPython source. @@ -223,12 +210,18 @@ Dependencies for building Matplotlib Setup dependencies ------------------ -- `certifi `_ (>= 2020.06.20). Used while - downloading the freetype and QHull source during build. This is not a - runtime dependency. +By default, ``pip`` will build packages using build isolation, and the following +dependencies will be automatically installed in the isolated environment to build +Matplotlib. However, for development, you may wish to make an editable install, which +will require disabling build isolation, so these build dependencies should be installed +in your target environment manually: + +- `meson-python `_ (>= 0.13.1). +- `ninja `_ (>= 1.8.2). This may be available in your package + manager or bundled with Meson, but may be installed via ``pip`` if otherwise not + available. - `PyBind11 `_ (>= 2.6). Used to connect C/C++ code with Python. -- `setuptools `_ (>= 64). - `setuptools_scm `_ (>= 7). Used to update the reported ``mpl.__version__`` based on the current git commit. Also a runtime dependency for editable installs. @@ -288,8 +281,6 @@ Xcode, VS Code or Linux package manager. Choose **one** compiler from this list: - Linux, macOS, Windows - `gcc 4.8.1 `_, `GCC: Binaries `_, - - For gcc <6.5 you will need to set ``$CFLAGS=-std=c++11`` to enable C++11 support. * - Clang (LLVM) - **3.3** - Linux, macOS @@ -330,8 +321,8 @@ testing the following will be used if they are installed. - pytest-xvfb_ to run tests without windows popping up (Linux) - pytz_ used to test pytz int - sphinx_ used to test our sphinx extensions -- WenQuanYi Zen Hei and `Noto Sans CJK `_ - fonts for testing font fallback and non-western fonts +- `WenQuanYi Zen Hei`_ and `Noto Sans CJK`_ fonts for testing font fallback and + non-Western fonts - xarray_ used to test compatibility with xarray If any of these dependencies are not discovered, then the tests that rely on @@ -359,6 +350,8 @@ them will be skipped by pytest. .. _pytest-xvfb: https://pypi.org/project/pytest-xvfb/ .. _pytest: http://doc.pytest.org/en/latest/ .. _sphinx: https://pypi.org/project/Sphinx/ +.. _WenQuanYi Zen Hei: http://wenq.org/en/ +.. _Noto Sans CJK: https://fonts.google.com/noto/use .. _xarray: https://pypi.org/project/xarray/ diff --git a/doc/devel/development_setup.rst b/doc/devel/development_setup.rst index 8537e1229df4..0e7db431163f 100644 --- a/doc/devel/development_setup.rst +++ b/doc/devel/development_setup.rst @@ -157,34 +157,36 @@ must be installed separately. For a full list, see :ref:`dependencies`. Install Matplotlib in editable mode =================================== -Install Matplotlib in editable mode from the :file:`matplotlib` directory -using the command :: +Install Matplotlib in editable mode from the :file:`matplotlib` directory using the +command :: - python -m pip install -ve . + python -m pip install --verbose --no-build-isolation --editable .[dev] -The 'editable/develop mode', builds everything and places links in your Python -environment so that Python will be able to import Matplotlib from your -development source directory. This allows you to import your modified version -of Matplotlib without re-installing after every change. Note that this is only -true for ``*.py`` files. If you change the C-extension source (which might -also happen if you change branches) you will have to re-run -``python -m pip install -ve .`` +The 'editable/develop mode' builds everything and places links in your Python environment +so that Python will be able to import Matplotlib from your development source directory. +This allows you to import your modified version of Matplotlib without re-installing after +every change. Note that before the merging of the `Meson port +`_, this is only true for ``*.py`` +files. If you change the C-extension source based on a commit before the change to the +Meson build system (which might also happen if you change branches), you will have to +re-run the above command. Verify the Installation ======================= -Run the following command to make sure you have correctly installed Matplotlib in editable mode. -The command should be run when the virtual environment is activated :: +Run the following command to make sure you have correctly installed Matplotlib in +editable mode. The command should be run when the virtual environment is activated:: python -c "import matplotlib; print(matplotlib.__file__)" This command should return : ``\lib\matplotlib\__init__.py`` -We encourage you to run tests and build docs to verify that the code installed correctly and that the docs build cleanly, -so that when you make code or document related changes you are aware of the existing issues beforehand. +We encourage you to run tests and build docs to verify that the code installed correctly +and that the docs build cleanly, so that when you make code or document related changes +you are aware of the existing issues beforehand. - * Run test cases to verify installation :ref:`testing` - * Verify documentation build :ref:`documenting-matplotlib` +* Run test cases to verify installation :ref:`testing` +* Verify documentation build :ref:`documenting-matplotlib` Install pre-commit hooks ======================== diff --git a/doc/devel/min_dep_policy.rst b/doc/devel/min_dep_policy.rst index 475985992bbc..dd8e069f0b94 100644 --- a/doc/devel/min_dep_policy.rst +++ b/doc/devel/min_dep_policy.rst @@ -22,7 +22,7 @@ Matplotlib supports: - All minor versions of ``numpy`` released in the 24 months prior to the project, and at minimum the last three minor versions. -In ``setup.py``, the ``python_requires`` variable should be set to +In :file:`pyproject.toml`, the ``requires-python`` variable should be set to the minimum supported version of Python. All supported minor versions of Python should be in the test matrix and have binary artifacts built for the release. diff --git a/doc/users/faq.rst b/doc/users/faq.rst index c4e133d56d73..42747c814f94 100644 --- a/doc/users/faq.rst +++ b/doc/users/faq.rst @@ -355,17 +355,23 @@ provide the following information in your e-mail to the `mailing list If you compiled Matplotlib yourself, please also provide: -* any changes you have made to ``setup.py`` or ``setupext.py``. +* your compiler version -- e.g., ``gcc --version``. * the output of:: - rm -rf build - python setup.py build + pip install --verbose The beginning of the build output contains lots of details about your platform that are useful for the Matplotlib developers to diagnose your problem. -* your compiler version -- e.g., ``gcc --version``. +If you compiled an older version of Matplotlib using the pre-Meson build system, instead +provide: + +* any changes you have made to ``setup.py``/``setupext.py``, +* the output of:: + + rm -rf build + python setup.py build Including this information in your first e-mail to the mailing list will save a lot of time. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 821d1bdeb5ea..0cdfa43b40d1 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1307,8 +1307,8 @@ def _val_or_rc(val, rc_name): def _init_tests(): - # The version of FreeType to install locally for running the - # tests. This must match the value in `setupext.py` + # The version of FreeType to install locally for running the tests. This must match + # the value in `meson.build`. LOCAL_FREETYPE_VERSION = '2.6.1' from matplotlib import ft2font @@ -1316,8 +1316,8 @@ def _init_tests(): ft2font.__freetype_build_type__ != 'local'): _log.warning( f"Matplotlib is not built with the correct FreeType version to " - f"run tests. Rebuild without setting system_freetype=1 in " - f"mplsetup.cfg. Expect many image comparison failures below. " + f"run tests. Rebuild without setting system-freetype=true in " + f"Meson setup options. Expect many image comparison failures below. " f"Expected freetype version {LOCAL_FREETYPE_VERSION}. " f"Found freetype version {ft2font.__freetype_version__}. " "Freetype build type is {}local".format( diff --git a/meson_options.txt b/meson_options.txt index ed753bb26854..77f2b5ec22de 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,18 +1,20 @@ +# Options may be set by passing through `pip` or `build` via meson-python: +# https://meson-python.readthedocs.io/en/stable/how-to-guides/config-settings.html + # By default, Matplotlib downloads and builds its own copies of FreeType and of -# Qhull. You may set the following to True to instead link against a system -# FreeType/Qhull. As an exception, Matplotlib defaults to the system version -# of FreeType on AIX. +# Qhull. You may use the following options to instead link against a system +# FreeType/Qhull. As an exception, Matplotlib defaults to the system version of +# FreeType on AIX. option('system-freetype', type: 'boolean', value: false, description: 'Build against system version of FreeType') option('system-qhull', type: 'boolean', value: false, description: 'Build against system version of Qhull') # Some of Matplotlib's components are optional: the MacOSX backend (installed -# by default on MacOSX; requires the Cocoa headers included with XCode), and -# the test data (i.e., the baseline image files; not installed by default). You -# can control whether they are installed by uncommenting the following lines. -# Note that the MacOSX backend is never built on Linux or Windows, regardless -# of the config value. +# by default on MacOSX; requires the Cocoa headers included with XCode). You +# can control whether they are installed using the following options. Note that +# the MacOSX backend is never built on Linux or Windows, regardless of the +# config value. option('macosx', type: 'boolean', value: true, description: 'Enable MacOSX backend (requires Cocoa)') diff --git a/requirements/doc/doc-requirements.txt b/requirements/doc/doc-requirements.txt index c0b4a19e3dd3..f60e9addf47b 100644 --- a/requirements/doc/doc-requirements.txt +++ b/requirements/doc/doc-requirements.txt @@ -2,7 +2,7 @@ # # You will first need a matching Matplotlib installation # e.g (from the Matplotlib root directory) -# pip install -e . +# pip install --no-build-isolation --editable .[dev] # # Install the documentation requirements with: # pip install -r requirements/doc/doc-requirements.txt diff --git a/src/_qhull_wrapper.cpp b/src/_qhull_wrapper.cpp index 7e4f306305b8..ef374d8e42c0 100644 --- a/src/_qhull_wrapper.cpp +++ b/src/_qhull_wrapper.cpp @@ -162,7 +162,7 @@ delaunay_impl(npy_intp npoints, const double* x, const double* y, if (hide_qhull_errors) { /* qhull errors are ignored by writing to OS-equivalent of /dev/null. * Rather than have OS-specific code here, instead it is determined by - * setupext.py and passed in via the macro MPL_DEVNULL. */ + * meson.build and passed in via the macro MPL_DEVNULL. */ error_file = fopen(STRINGIFY(MPL_DEVNULL), "w"); if (error_file == NULL) { throw std::runtime_error("Could not open devnull"); From 01c1ff610fe89c1425666465b9dc044ffb9dd563 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 27 Sep 2023 15:59:16 -0400 Subject: [PATCH 8/8] ci: Pin NumPy on Cygwin build Cherry-picked out of #26800; also unpin setuptools. --- .github/workflows/cygwin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index feded9f0c1ad..6968d7afb4f5 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -174,8 +174,8 @@ jobs: - name: Install Python dependencies shell: bash.exe -eo pipefail -o igncr "{0}" run: | - python -m pip install --upgrade pip 'setuptools<60' wheel - python -m pip install kiwisolver 'numpy!=1.21.*' pillow importlib_resources + python -m pip install --upgrade pip setuptools wheel + python -m pip install kiwisolver 'numpy>=1.22,<1.26' pillow importlib_resources grep -v -F -e psutil requirements/testing/all.txt >requirements_test.txt python -m pip install meson-python pybind11 export PATH="/usr/local/bin:$PATH"