{
  "__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:cross_compilation",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Cross compilation is a complex topic, we only add some hopefully helpful hints here (for now). As of May 2023, cross-compilation based on "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "crossenv"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is known to work, as used (for example) in conda-forge. Cross-compilation without "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "crossenv"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " requires some manual overrides. You instruct these overrides by passing options to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson setup"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " via "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "meson-python"
                }
              ],
              "url": "https://mesonbuild.com/meson-python/",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "meson-python",
          "url": "https://meson-python.readthedocs.io/en/latest/how-to-guides/meson-args.html"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "All distributions that are known to successfully cross compile SciPy are using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "python -m build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " ("
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pypa/build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), but using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pip"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for that should be possible as well. Here are links to the SciPy's \"build recipes\" on those distros:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Void Linux"
                        }
                      ],
                      "url": "https://github.com/void-linux/void-packages/blob/master/srcpkgs/python3-scipy/template",
                      "title": ""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Nix"
                        }
                      ],
                      "url": "https://github.com/nixos/nixpkgs/blob/master/pkgs/development/python-modules/scipy/default.nix",
                      "title": ""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Conda-forge"
                        }
                      ],
                      "url": "https://github.com/conda-forge/scipy-feedstock/blob/main/recipe/build.sh",
                      "title": ""
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "See also "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Meson's documentation on cross compilation"
                }
              ],
              "url": "https://mesonbuild.com/Cross-compilation.html",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to learn what options you may need to pass to Meson to successfully cross compile."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "One common hiccup is that "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pythran"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " requires running Python code in order to obtain its include directory. This tends to not work well, either accidentally picking up the packages from the build (native) Python rather than the host (cross) Python or requiring "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "crossenv"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or QEMU to run the host Python. To avoid this problem, specify the path to the relevant directory in your "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "cross file"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "[constants]\nsitepkg = '/abspath/to/host-pythons/site-packages/'\n\n[properties]\npythran-include-dir = sitepkg + 'pythran'",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " used to require the same treatment, through a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy-include-dir"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " property. That is no longer needed: since SciPy 2.0.0 (when "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "f2py"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " was removed) nothing needs a path to numpy's headers directly, so numpy is looked up with Meson's "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "dependency('numpy')"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Meson resolves that through a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.pc"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " pkg-config file if it can find one, and otherwise by running the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy-config"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " executable. For a cross build, provide a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy.pc"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for the numpy you are targeting; it takes precedence over a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " in the build environment."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For more details and the current status around cross compilation, see:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Tracking issue for SciPy cross-compilation needs and issues:   "
                    },
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "scipy#14812"
                        }
                      ],
                      "url": "https://github.com/scipy/scipy/issues/14812",
                      "title": ""
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The state of cross compilation in Python:   "
                    },
                    {
                      "__type": "Link",
                      "__tag": 4049,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "pypackaging-native key issue page"
                        }
                      ],
                      "url": "https://pypackaging-native.github.io/key-issues/cross_compilation/",
                      "title": ""
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Cross compilation"
        }
      ],
      "level": 0,
      "target": null
    }
  ],
  "local_refs": []
}