{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "building:introspecting_a_build",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When you have an issue with a particular Python extension module or other build target, there are a number of ways to figure out what the build system is doing exactly. Beyond looking at the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson.build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " content for the target of interest, these include:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Reading the generated "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "build.ninja"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " file in the build directory,"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Using "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "meson introspect"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " to learn more about build options, dependencies    and flags used for the target,"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Reading "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "<build-dir>/meson-info/*.json"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for details on discovered    dependencies, where Meson plans to install files to, etc."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "These things are all available after the configure stage of the build (i.e., "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson setup"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") has run. It is typically more effective to look at this information, rather than running the build and reading the full build log."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Introspecting build steps"
        }
      ],
      "level": 0,
      "target": "meson-introspection"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As an example, let's say we are interested in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scipy.linalg._decomp_update"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". From "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scipy/linalg/meson.build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " we learn that this extension is written in templated Cython code, and that beyond the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " dependency there are no special compilation flags used nor extra include directories. So the next step is to look at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "build.ninja"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Open that file in an editor and search for "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_decomp_update"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". You will find this set of generic and target-specific rules that apply (note, comments in this code block are not present in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "build.ninja"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " but only added in this doc section to explain what is happening):"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "# These rules are usually not needed to understand the problem, but can be looked up at the top of the file:\nrule c_COMPILER\n command = /home/username/mambaforge/envs/scipy-dev/bin/x86_64-conda-linux-gnu-cc $ARGS -MD -MQ $out -MF $DEPFILE -o $out -c $in\n deps = gcc\n depfile = $DEPFILE_UNQUOTED\n description = Compiling C object $out\n\nrule c_LINKER\n command = /home/username/mambaforge/envs/scipy-dev/bin/x86_64-conda-linux-gnu-cc $ARGS -o $out $in $LINK_ARGS\n description = Linking target $out\n\n# step 1: `.pyx.in` to `.pyx` code generation with Tempita\nbuild scipy/linalg/_decomp_update.pyx: CUSTOM_COMMAND ../scipy/linalg/_decomp_update.pyx.in | /home/username/code/scipy/tools/building/tempita.py\n COMMAND = /home/username/mambaforge/envs/scipy-dev/bin/python3.14 /home/username/code/scipy/tools/building/tempita.py ../scipy/linalg/_decomp_update.pyx.in -o scipy/linalg\n description = Generating$ scipy/linalg/_decomp_update$ with$ a$ custom$ command\n\n# step 2: `.pyx` to `.c` compilation with Cython\nbuild scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.c: CUSTOM_COMMAND scipy/linalg/_decomp_update.pyx | /home/username/mambaforge/envs/scipy-dev/bin/cython scipy/__init__.py scipy/linalg/__init__.pxd scipy/linalg/__init__.py scipy/linalg/cython_blas.pxd\n DESC = Generating$ 'scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.c'\n COMMAND = /home/username/mambaforge/envs/scipy-dev/bin/cython -3 --fast-fail --output-file scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.c --include-dir . scipy/linalg/_decomp_update.pyx -Xfreethreading_compatible=True --shared=scipy._cyutility\n\n# step 3: use C compiler to go from `.c` to object file (`.o`)\nbuild scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o: c_COMPILER scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.c\n DEPFILE = scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o.d\n DEPFILE_UNQUOTED = scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o.d\n ARGS = -Iscipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p -Iscipy/linalg -I../scipy/linalg -I/home/username/mambaforge/envs/scipy-dev/lib/python3.14/site-packages/numpy/_core/include -I/home/username/mambaforge/envs/scipy-dev/include/python3.14 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c17 -O2 -g -Wno-unused-but-set-variable -Wno-unused-function -Wno-conversion -Wno-misleading-indentation -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -DCYTHON_CCOMPLEX=0\n\n# step 4: generate a symbol file (uses `meson --internal symbolextractor`); you can safely ignore this step\nbuild scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.cpython-314-x86_64-linux-gnu.so.symbols: SHSYM scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\n IMPLIB = scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\n\n# step 5: link the `.o` file to obtain the file extension module (`.so`)\nbuild scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so: c_LINKER scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o\n LINK_ARGS = -L/home/username/mambaforge/envs/scipy-dev/lib -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -lm -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--allow-shlib-undefined -Wl,-rpath,/home/username/mambaforge/envs/scipy-dev/lib -Wl,-rpath-link,/home/username/mambaforge/envs/scipy-dev/lib -Wl,--version-script=/home/username/code/scipy/tools/building/link-version-pyinit.map",
          "execution_status": null,
          "out": ""
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "The "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "ninja.build"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " file"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If we want to look at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_decomp_update"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " from another perspective, we can use (for example) "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson introspect --targets -i <build-dir> > targets.json"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to generate readable JSON. Searching that generated file for our target of interest shows:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "{\n    \"name\": \"_decomp_update\",\n    \"id\": \"b4ac6f0@@_decomp_update@cus\",\n    \"type\": \"custom\",\n    \"defined_in\": \"/home/username/code/scipy/scipy/linalg/meson.build\",\n    \"filename\": [\n        \"/home/username/code/scipy/build/scipy/linalg/_decomp_update.pyx\"\n    ],\n    \"build_by_default\": false,\n    \"target_sources\": [\n        {\n            \"language\": \"unknown\",\n            \"compiler\": [\n                \"/home/username/mambaforge/envs/scipy-dev/bin/python3.14\",\n                \"/home/username/code/scipy/tools/building/tempita.py\",\n                \"@INPUT@\",\n                \"-o\",\n                \"@OUTDIR@\"\n            ],\n            \"parameters\": [],\n            \"sources\": [\n                \"/home/username/code/scipy/scipy/linalg/_decomp_update.pyx.in\"\n            ],\n            \"generated_sources\": []\n        }\n    ],\n    \"extra_files\": [],\n    \"subproject\": null,\n    \"dependencies\": [],\n    \"depends\": [],\n    \"installed\": false\n},\n{\n    \"name\": \"_decomp_update.cpython-314-x86_64-linux-gnu\",\n    \"id\": \"b4ac6f0@@_decomp_update.cpython-314-x86_64-linux-gnu.so@sha\",\n    \"type\": \"shared module\",\n    \"defined_in\": \"/home/username/code/scipy/scipy/linalg/meson.build\",\n    \"filename\": [\n        \"/home/username/code/scipy/build/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\"\n    ],\n    \"build_by_default\": true,\n    \"target_sources\": [\n        {\n            \"language\": \"c\",\n            \"machine\": \"host\",\n            \"compiler\": [\n                \"/home/username/mambaforge/envs/scipy-dev/bin/x86_64-conda-linux-gnu-cc\"\n            ],\n            \"parameters\": [\n                \"-I/home/username/code/scipy/build/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p\",\n                \"-I/home/username/code/scipy/build/scipy/linalg\",\n                \"-I/home/username/code/scipy/scipy/linalg\",\n                \"-I/home/username/mambaforge/envs/scipy-dev/lib/python3.14/site-packages/numpy/_core/include\",\n                \"-I/home/username/mambaforge/envs/scipy-dev/include/python3.14\",\n                \"-fvisibility=hidden\",\n                \"-fdiagnostics-color=always\",\n                \"-D_FILE_OFFSET_BITS=64\",\n                \"-Wall\",\n                \"-Winvalid-pch\",\n                \"-std=c17\",\n                \"-O2\",\n                \"-g\",\n                \"-Wno-unused-but-set-variable\",\n                \"-Wno-unused-function\",\n                \"-Wno-conversion\",\n                \"-Wno-misleading-indentation\",\n                \"-fPIC\",\n                \"-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION\",\n                \"-DCYTHON_CCOMPLEX=0\"\n            ],\n            \"sources\": [],\n            \"generated_sources\": [\n                \"/home/username/code/scipy/build/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so.p/_decomp_update.c\"\n            ],\n            \"unity_sources\": []\n        },\n        {\n            \"linker\": [\n                \"/home/username/mambaforge/envs/scipy-dev/bin/x86_64-conda-linux-gnu-cc\"\n            ],\n            \"parameters\": [\n                \"-L/home/username/mambaforge/envs/scipy-dev/lib\",\n                \"-Wl,--as-needed\",\n                \"-Wl,--allow-shlib-undefined\",\n                \"-shared\",\n                \"-fPIC\",\n                \"-lm\",\n                \"-Wl,-O2\",\n                \"-Wl,--sort-common\",\n                \"-Wl,--as-needed\",\n                \"-Wl,-z,relro\",\n                \"-Wl,-z,now\",\n                \"-Wl,--allow-shlib-undefined\",\n                \"-Wl,-rpath,/home/username/mambaforge/envs/scipy-dev/lib\",\n                \"-Wl,-rpath-link,/home/username/mambaforge/envs/scipy-dev/lib\",\n                \"-Wl,--version-script=/home/username/code/scipy/tools/building/link-version-pyinit.map\"\n            ]\n        }\n    ],\n    \"extra_files\": [],\n    \"subproject\": null,\n    \"dependencies\": [\n        \"dep17362272261413320709411132636391318505\",\n        \"numpy\",\n        \"python-3.14\"\n    ],\n    \"depends\": [],\n    \"installed\": true,\n    \"install_filename\": [\n        \"/home/username/code/scipy/build-install/lib/python3.14/site-packages/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\"\n    ]\n},",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This tells us a lot of things, like which include directories will be used, where the Cython-generated C code can be found, and what compile flags are used. "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson introspect --help"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has good documentation on the full range of capabilities and how to use them."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Using "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "meson introspect"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There are a number of different JSON files in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "<build-dir>/meson-info/"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". These have descriptive names, hinting at their content. For example, where the final "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "_decomp_update"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " extension gets installed to is described in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "intro-install_plan.json"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (note, these files aren't pretty-printed, running them through a JSON formatter helps):"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "\"/home/username/code/scipy/build/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\":{\n   \"destination\":\"{py_platlib}/scipy/linalg/_decomp_update.cpython-314-x86_64-linux-gnu.so\",\n   \"tag\":\"runtime\",\n   \"subproject\":null,\n   \"install_rpath\":null,\n   \"build_rpaths\":[]\n},",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "We may also be interested in knowing what dependencies were detected by the configure stage of the build. So we look in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "intro-dependencies.json"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (abbreviated here - the full file also lists "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "threads"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cblas"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "lapack"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and has a few more keys per entry):"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "[\n   {\n      \"name\":\"python-3.14\",\n      \"type\":\"pkgconfig\",\n      \"version\":\"3.14\",\n      \"compile_args\":[\n         \"-I/home/username/mambaforge/envs/scipy-dev/include/python3.14\"\n      ],\n      \"link_args\":[\n\n      ],\n      \"meson_variables\":[]\n   },\n   {\n      \"name\":\"numpy\",\n      \"type\":\"config-tool\",\n      \"version\":\"2.4.4\",\n      \"compile_args\":[\n         \"-I/home/username/mambaforge/envs/scipy-dev/lib/python3.14/site-packages/numpy/_core/include\"\n      ],\n      \"link_args\":[\n\n      ],\n      \"meson_variables\":[\n         \"_numpy_dep\"\n      ]\n   },\n   {\n      \"name\":\"blas\",\n      \"type\":\"pkgconfig\",\n      \"version\":\"0.3.33\",\n      \"compile_args\":[\n         \"-I/home/username/mambaforge/envs/scipy-dev/include\"\n      ],\n      \"link_args\":[\n         \"/home/username/mambaforge/envs/scipy-dev/lib/libopenblas.so\"\n      ],\n      \"meson_variables\":[\n         \"blas\"\n      ]\n   }\n]",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This tells us which dependencies were found, and how. Note the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "type"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " field: "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is found through the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy-config"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " executable (\"config-tool\"), while "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "blas"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "python"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are found through pkg-config. The "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson_variables"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " field is handy for mapping an entry back to the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson.build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " code that looked it up."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "meson-info"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " JSON files"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}