{
  "__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 there are no special compilation flags used nor include directories beyond the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " one. 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/anaconda3/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/anaconda3/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 | ../scipy/_build_utils/tempita.py /home/username/anaconda3/envs/scipy-dev/bin/python3.10\n COMMAND = /home/username/anaconda3/envs/scipy-dev/bin/python3.10 ../scipy/_build_utils/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-310-x86_64-linux-gnu.so.p/_decomp_update.c: CUSTOM_COMMAND scipy/linalg/_decomp_update.pyx | /home/username/code/scipy/scipy/_build_utils/cythoner.py scipy/__init__.py scipy/linalg/__init__.py scipy/linalg/cython_blas.pyx\n DESC = Generating$ 'scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/_decomp_update.c'.\n COMMAND = /home/username/anaconda3/envs/scipy-dev/bin/python3.10 /home/username/code/scipy/scipy/_build_utils/cythoner.py scipy/linalg/_decomp_update.pyx scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/_decomp_update.c\n\n# step 3: use C compiler to go from `.c` to object file (`.o`)\nbuild scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o: c_COMPILER scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/_decomp_update.c\n DEPFILE = scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o.d\n DEPFILE_UNQUOTED = scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o.d\n ARGS = -Iscipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p -Iscipy/linalg -I../scipy/linalg -I/home/username/anaconda3/envs/scipy-dev/lib/python3.10/site-packages/numpy/core/include -I/home/username/anaconda3/envs/scipy-dev/include/python3.10 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -O2 -g -Wno-unused-but-set-variable -Wno-unused-function -Wno-conversion -Wno-misleading-indentation -fPIC -Wno-cpp\n\n# step 4: generate a symbol file (uses `meson --internal symbolextractor`); you can safely ignore this step\nbuild scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/_decomp_update.cpython-310-x86_64-linux-gnu.so.symbols: SHSYM scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so\n IMPLIB = scipy/linalg/_decomp_update.cpython-310-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-310-x86_64-linux-gnu.so: c_LINKER scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/meson-generated__decomp_update.c.o | /home/username/anaconda3/envs/scipy-dev/x86_64-conda-linux-gnu/sysroot/lib64/libm-2.12.so /home/username/anaconda3/envs/scipy-dev/x86_64-conda-linux-gnu/sysroot/usr/lib64/libm.a\n LINK_ARGS = -L/home/username/anaconda3/envs/scipy-dev/lib -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group -lm -Wl,--end-group -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/username/anaconda3/envs/scipy-dev/lib -Wl,-rpath-link,/home/username/anaconda3/envs/scipy-dev/lib",
          "execution_status": null
        }
      ],
      "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/anaconda3/envs/scipy-dev/bin/python3.10\",\n                \"/home/username/code/scipy/scipy/_build_utils/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    \"installed\": false\n},\n{\n    \"name\": \"_decomp_update.cpython-310-x86_64-linux-gnu\",\n    \"id\": \"b4ac6f0@@_decomp_update.cpython-310-x86_64-linux-gnu@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-310-x86_64-linux-gnu.so\"\n    ],\n    \"build_by_default\": true,\n    \"target_sources\": [\n        {\n            \"language\": \"c\",\n            \"compiler\": [\n                \"/home/username/anaconda3/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-310-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/anaconda3/envs/scipy-dev/lib/python3.10/site-packages/numpy/core/include\",\n                \"-I/home/username/anaconda3/envs/scipy-dev/include/python3.10\",\n                \"-fvisibility=hidden\",\n                \"-fdiagnostics-color=always\",\n                \"-D_FILE_OFFSET_BITS=64\",\n                \"-Wall\",\n                \"-Winvalid-pch\",\n                \"-std=c99\",\n                \"-O2\",\n                \"-g\",\n                \"-Wno-unused-but-set-variable\",\n                \"-Wno-unused-function\",\n                \"-Wno-conversion\",\n                \"-Wno-misleading-indentation\",\n                \"-fPIC\",\n                \"-Wno-cpp\"\n            ],\n            \"sources\": [],\n            \"generated_sources\": [\n                \"/home/username/code/scipy/build/scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so.p/_decomp_update.c\"\n            ]\n        }\n    ],\n    \"extra_files\": [],\n    \"subproject\": null,\n    \"installed\": true,\n    \"install_filename\": [\n        \"/home/username/code/scipy/build-install/lib/python3.10/site-packages/scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so\"\n    ]\n},",
          "execution_status": null
        },
        {
          "__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-310-x86_64-linux-gnu.so\":{\n   \"destination\":\"{py_platlib}/scipy/linalg/_decomp_update.cpython-310-x86_64-linux-gnu.so\",\n   \"tag\":\"runtime\"\n},",
          "execution_status": null
        },
        {
          "__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": ":"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "[\n   {\n      \"name\":\"python\",\n      \"version\":\"3.10\",\n      \"compile_args\":[\n         \"-I/home/username/anaconda3/envs/scipy-dev/include/python3.10\"\n      ],\n      \"link_args\":[\n\n      ]\n   },\n   {\n      \"name\":\"openblas\",\n      \"version\":\"0.3.20\",\n      \"compile_args\":[\n         \"-I/home/username/anaconda3/envs/scipy-dev/include\"\n      ],\n      \"link_args\":[\n         \"/home/username/anaconda3/envs/scipy-dev/lib/libopenblas.so\"\n      ]\n   },\n   {\n      \"name\":\"threads\",\n      \"version\":\"unknown\",\n      \"compile_args\":[\n         \"-pthread\"\n      ],\n      \"link_args\":[\n         \"-pthread\"\n      ]\n   }\n]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This tells us that we have three dependencies that were found. Note: "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and a few other build-time dependencies are missing here because we do not (yet) search for those with the builtin "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dependency()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " Meson command."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "meson-info"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " JSON files"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}