{
  "__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": "f2py:buildtools:skbuild",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scikit-build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " provides two separate concepts geared towards the users of Python extension modules."
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "setuptools"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " replacement (legacy behaviour)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A series of "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "cmake"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " modules with definitions which help building Python extensions"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "It is possible to use "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "scikit-build"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "'s "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "cmake"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " modules to "
                },
                {
                  "__type": "Link",
                  "__tag": 4049,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "bypass the cmake setup mechanism"
                    }
                  ],
                  "url": "https://scikit-build.readthedocs.io/en/latest/cmake-modules/F2PY.html",
                  "title": ""
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " completely, and to write targets which call "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "f2py -c"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": ". This usage is "
                },
                {
                  "__type": "Strong",
                  "__tag": 4048,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "not recommended"
                    }
                  ]
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " since the point of these build system documents are to move away from the internal "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "numpy.distutils"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " methods."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For situations where no "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "setuptools"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " replacements are required or wanted (i.e. if "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "wheels"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are not needed), it is recommended to instead use the vanilla "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " setup described in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "f2py-cmake",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "f2py:buildtools:cmake"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Using via "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "scikit-build"
        }
      ],
      "level": 0,
      "target": "f2py-skbuild"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "We will consider the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fib"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "  example from "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "f2py-getting-started",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "f2py:f2py.getting-started"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " section."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Fibonacci walkthrough (F77)"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Consider using the following "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "CMakeLists.txt"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Much of the logic is the same as in "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "f2py-cmake",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "f2py:buildtools:cmake"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", however notably here the appropriate module suffix is generated via "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "sysconfig.get_config_var(\"SO\")"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The resulting extension can be built and loaded in the standard workflow."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "ls .\n# CMakeLists.txt fib1.f\ncmake -S . -B build\ncmake --build build\ncd build\npython -c \"import numpy as np; import fibby; a = np.zeros(9); fibby.fib(a); print (a)\"\n# [ 0.  1.  1.  2.  3.  5.  8. 13. 21.]",
          "execution_status": null
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "CMake"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " modules only"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Strong",
                  "__tag": 4048,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "As of November 2021"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "The behavior described here of driving the "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "cmake"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " build of a module is considered to be legacy behaviour and should not be depended on."
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The utility of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scikit-build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " lies in being able to drive the generation of more than extension modules, in particular a common usage pattern is the generation of Python distributables (for example for PyPI)."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The workflow with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scikit-build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " straightforwardly supports such packaging requirements. Consider augmenting the project with a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "setup.py"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as defined:"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Along with a commensurate "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pyproject.toml"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Together these can build the extension using "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " in tandem with other standard "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "setuptools"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " outputs. Running "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " through "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "setup.py"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is mostly used when it is necessary to integrate with extension modules not built with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "ls .\n# CMakeLists.txt fib1.f pyproject.toml setup.py\npython setup.py build_ext --inplace\npython -c \"import numpy as np; import fibby.fibby; a = np.zeros(9); fibby.fibby.fib(a); print (a)\"\n# [ 0.  1.  1.  2.  3.  5.  8. 13. 21.]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Where we have modified the path to the module as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "--inplace"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " places the extension module in a subfolder."
            }
          ]
        },
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "bypass the cmake setup mechanism"
        }
      ],
      "title": [
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "setuptools"
        },
        {
          "__type": "Text",
          "__tag": 4046,
          "value": " replacement"
        }
      ],
      "level": 2,
      "target": null
    }
  ],
  "local_refs": []
}