{"id":29035373,"url":"https://github.com/xmake-io/xmake-python","last_synced_at":"2025-06-26T12:09:13.712Z","repository":{"id":272112176,"uuid":"915563213","full_name":"xmake-io/xmake-python","owner":"xmake-io","description":"xmake Python build system (PEP 517)","archived":false,"fork":false,"pushed_at":"2025-06-18T09:43:26.000Z","size":289,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-18T10:06:25.369Z","etag":null,"topics":["pep517","python","xmake"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/xmake-python","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xmake-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"waruqi","open_collective":"xmake","custom":"https://xmake.io/#/sponsor"}},"created_at":"2025-01-12T07:23:16.000Z","updated_at":"2025-06-18T09:40:06.000Z","dependencies_parsed_at":"2025-06-08T19:28:15.027Z","dependency_job_id":"4367fdfe-1ac9-4225-93e8-6a60b3a9f4a6","html_url":"https://github.com/xmake-io/xmake-python","commit_stats":null,"previous_names":["xmake-io/xmake-python"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/xmake-io/xmake-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmake-io%2Fxmake-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmake-io%2Fxmake-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmake-io%2Fxmake-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmake-io%2Fxmake-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmake-io","download_url":"https://codeload.github.com/xmake-io/xmake-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmake-io%2Fxmake-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262063548,"owners_count":23252766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pep517","python","xmake"],"created_at":"2025-06-26T12:09:12.314Z","updated_at":"2025-06-26T12:09:13.706Z","avatar_url":"https://github.com/xmake-io.png","language":"Python","funding_links":["https://github.com/sponsors/waruqi","https://opencollective.com/xmake","https://xmake.io/#/sponsor"],"categories":[],"sub_categories":[],"readme":"# xmake Python build system (PEP 517)\n\nA python build system based on xmake to output sdist/wheel file respecting PEP517.\n\n## Related Projects\n\nCurrently, the methods to build a python wheel containing C/C++ code are as\nfollowing:\n\n- [distutils](http://pypi.org/project/distutils/): A simple C/C++ build system\n  written in pure python. Before python 3.13, it is one of python standard\n  libraries. Slow.\n  - [setuptools](http://pypi.org/project/setuptools/): default python build\n    system, which can use distutils to build python/C mixed project.\n- [scons](https://pypi.org/project/SCons/): A C/C++ build system written in pure\n  python. It is very slow. So Evan Martin, the maintainer of google chrome, has\n  to create ninja and\n  [switch](https://neugierig.org/software/chromium/notes/2011/02/ninja.html)\n  chrome's build system to ninja.\n  - [enscons](https://pypi.org/project/enscons/): A python build system based\n    on scons. Advantage: no extra dependency except python.\n- [cmake](https://pypi.org/project/cmake/): A classic C/C++ build system. A\n  standard in fact while bad-designed syntax.\n  [scikit-build](https://github.com/scikit-build/) organization package it to\n  PYPI to let python developer enjoy it. cmake in PYPI uses\n  [ninja](https://pypi.org/project/ninja/) as its backend, which is also\n  packaged by scikit-build organization. That means that python, cmake, ninja is\n  needed. Although the latter two will be installed from PYPI.\n  - [scikit-build](https://pypi.org/project/scikit-build/): first python build\n    system based on cmake developed by scikit-build organization. Replaced by\n    scikit-build-core.\n  - [scikit-build-core](https://pypi.org/project/scikit-build-core/):\n    scikit-build organization recommends it.\n  - [cmeel](https://pypi.org/project/cmeel/): Another wheel.\n  - [py-build-cmake](https://pypi.org/project/py-build-cmake/): Another wheel\n    forked from [flit](https://pypi.org/project/flit/).\n- [meson](https://pypi.org/project/meson/): A C/C++ build system written in pure\n  python. However, it uses ninja as its backend.\n  - [meson-python](https://pypi.org/project/meson-python/): A python build\n    system based on meson.\n\nExcept slow distutils/scons, both cmake and meson use ninja as their backend. So\nif a python developer want to build a python/C mixed project in high speed,\nninja is the only one choice. We hope xmake can be another choice -- it\nshould be as fast as ninja, as easy as meson, as powerful as cmake.\n\n- [xmake](https://pypi.org/project/xmake-wheel):\n  [package it](https://github.com/xmake-io/xmake-wheel/) to PYPI.\n  - [xmake-python](https://pypi.org/project/xmake-python/): A python build system\n    based on xmake. This project!\n\n## Usage\n\n`pyproject.toml`:\n\n```toml\n[build-system]\nrequires = [\"xmake-python\"]\nbuild-backend = \"xmake_python\"\n```\n\n## Examples\n\n- [examples](tests/examples)\n- [xmake-wheel](https://github.com/xmake-io/xmake-wheel/)\n- [gnumake-wheel](https://github.com/xmake-io/gnumake-wheel/)\n\n## Introduction\n\nPython build system support build sdist, wheel and editable installation.\nAccording to [PEP517](https://peps.python.org/pep-0517/), python build system\nis consist of two parts:\n\n### Frontends\n\n- `pyproject-build`/[`python -m build`](http://pypi.org/project/build/):\n  standard realization.\n- [`uv build`](https://pypi.org/project/uv/): the fastest frontend currently.\n- [`pip wheel`](https://github.com/pypa/pip/): pip is an incomplete frontend\n  because build sdist is still a\n  [feature request](https://github.com/pypa/pip/issues/3513).\n\nIn charge of:\n\n- install required build dependencies from `build-system.requires`\n- install optional build dependencies from the result of calling\n  `build-system.build-backend`'s `get_requires_for_build_{sdist,wheel,editable}()`\n- call `build-system.build-backend`'s `build_{sdist,wheel,editable}()`\n\n### Backends\n\nRefer\n[some python build system backends](https://scikit-build-core.readthedocs.io/en/latest/#other-projects-for-building).\n\nMany build systems are only used to build pure python wheels, such as\nsetuptools, flit-core, poetry, hatchling. And others can build python modules\nwritten in C/C++/Fortran/Rust/etc. For the latter, scikit-build-core will search\nand install pure python files automatically, without adding any related code to\n`CMakeLists.txt`, meson-python is on the contrast. You must add code to\n`meson.build`:\n\n```meson\npy = import('python').find_installation()\npy.install_sources(\n  [\n    'src/example/__init__.py',\n    'src/example/__main__.py',\n  ],\n  subdir: 'example',\n)\n```\n\nThis project is also like meson-python. You must add code to `xmake.lua`:\n\n```lua\ntarget(\"example\")\nset_kind(\"phony\")\nadd_installfiles(\"src/example/*.py\", {prefixdir= \"$(pythondir)/example\"})\n```\n\nNote, xmake supports glob expression which meson doesn't support.\n\nBackend can install optional build dependencies. For example,\n[scikit-build-core](https://pypi.org/project/scikit-build-core/)\nwill install [cmake](http://pypi.org/project/cmake) and [ninja](https://pypi.org/project/ninja/)\nonly when cmake and ninja are not found in `$PATH`.\n\nWe provide two python packages. One is a\n[wheel for xmake](https://github.com/xmake-io/xmake-wheel/), like cmake and\nninja. Another is a python build system backend, which will install xmake wheel\nwhen xmake is not found in `$PATH`.\n\nExcept xmake, if you use [xmake-repo](https://github.com/xmake-io/xmake-repo)'s\npackages, `git` is needed. If package have `set_sources()`, download tools like\ncurl and extract tools like `7z` are also needed. `xmake` will build them from\n`xmake-repo` if they doesn't exist, which is slow for cross compilation.\n\n### Wheel\n\nPython package's format is wheel, which is a zip file naturally. If you try\ncreate a wheel file named `example-0.0.1-cp313-cp313-linux_x86_64.whl`, it\noptionally contains these files, and they will be installed to:\n\n- python module, can be pure python files or dynamic linked library\n  - `example.py`: `/usr/lib/python3.13/site-packages/example.py`\n  - `example/__init__.py`:\n    `/usr/lib/python3.13/site-packages/example/__init__.py`\n  - `example.cpython-313-x86_64-linux-gnu.so`:\n    `/usr/lib/python3.13/site-packages/example.cpython-313-x86_64-linux-gnu.so`\n  - `example/_C.cpython-313-x86_64-linux-gnu.so`:\n    `/usr/lib/python3.13/site-packages/example/_C.cpython-313-x86_64-linux-gnu.so`\n- attached data\n  - `example-0.0.1.data/scripts/example`: `/usr/bin/example`\n  - `example-0.0.1.data/headers/example.h`:\n    `/usr/include/python3.13/example/example.h`\n  - `example-0.0.1.data/data/other/data.txt`: `/usr/other/data.txt`\n- metadata\n  - `example-0.0.1.dist-info/WHEEL`:\n    `/usr/lib/python3.13/site-packages/example-0.0.1.dist-info/WHEEL`\n  - `example-0.0.1.dist-info/METADATA`:\n    `/usr/lib/python3.13/site-packages/example-0.0.1.dist-info/METADATA`\n  - `example-0.0.1.dist-info/RECORD`:\n    `/usr/lib/python3.13/site-packages/example-0.0.1.dist-info/RECORD`\n  - `example-0.0.1.dist-info/licenses/LICENSE`:\n    `/usr/lib/python3.13/site-packages/example-0.0.1.dist-info/licenses/LICENSE`\n\nSo we create a [xmake.lua](src/xmake_python/templates/xmake.lua), which defines\nsome variables, and when `xmake install -o/tmp/tmpXXXXXXXX`, they will be\nsome paths prefixed with `/tmp/tmpXXXXXXXX`, and finally packaged to:\n\n- pythondir: `/platlib` -\u003e `/tmp/tmpXXXXXXXX/platlib` -\u003e `/`, like\n  scikit-build-core's `SKBUILD_PLATLIB_DIR`\n- bindir: `/data/bin` -\u003e `/tmp/tmpXXXXXXXX/data/bin` -\u003e\n  `example-0.0.1.data/scripts/`, like scikit-build-core's `SKBUILD_SCRIPTS_DIR`\n- includedir: `/data/include` -\u003e `/tmp/tmpXXXXXXXX/data/include` -\u003e\n  `example-0.0.1.data/headers/`, like scikit-build-core's `SKBUILD_HEADERS_DIR`\n- prefix: `/data` -\u003e `/tmp/tmpXXXXXXXX/data` -\u003e\n  `example-0.0.1.data/data/`, like scikit-build-core's `SKBUILD_DATA_DIR`\n- metadatadir: `/metadata` -\u003e `/tmp/tmpXXXXXXXX/metadata` -\u003e\n  `example-0.0.1.dist-info/`, like scikit-build-core's `SKBUILD_METADATA_DIR`\n- nulldir: `/null` -\u003e `/tmp/tmpXXXXXXXX/null` -\u003e will not be packaged, like\n  scikit-build-core's `SKBUILD_NULL_DIR`\n\nSo you can create 3 kinds of wheels:\n\n- pure python wheel, which named like `example-0.0.1-py3-none-any.whl`,\n  support any platforms and python 3 version.\n- contains binary program, which named like\n  `example-0.0.1-py3-none-linux_x86_64.whl`, support fixed platforms, python3\n  version. Because different OS and cpu cannot mix binary programs and\n  dynamically linked libraries.\n- dynamic linked python module, which named like\n  `example-0.0.1-cp313-cp313-linux_x86_64.whl`, because dynamic linked python\n  module links different python library like `/usr/lib/libpython3.13.so`.\n\nWe use the following method to judge the kind:\n\n1. If all target's kinds are `phony` and don't use any package, the wheel\n   is a pure python wheel.\n2. Else if all targets don't use rule `python.*`, the wheel is a binary program\n   wheel.\n3. Else the wheel is a dynamic linked python module wheel.\n\n### Cross Compilation\n\npython project usually uses [cibuildwheel](https://github.com/pypa/cibuildwheel)\nto build wheels for all platforms. Github workflow has 3 types of machines.\n\n- Ubuntu on amd64, used to build wheels for manylinux and musllinux\n- macOS on arm64\n- Windows on amd64\n\nFor manylinux (A GNU/Linux distribution forked from CentOS) and musllinux (A\nmusl/linux distribution forked from Alpine), it uses qemu to emulate different\nCPUs and use docker to start the OS. For macOS and Windows, it use cross\ncompiler to build wheels for macOS on amd64 and Windows on arm64, etc. These\ntoolchains respect many environment variables:\n\n- `ARCHFLAGS`: `-a XXX`. Specially, `-a arm64 -a x86_64` is for universal2.\n- `VSCMD_ARG_TARGET_ARCH`: for Visual Studio's MSVC.\n\nThis project also detect them.\n\n### Variables\n\nAll variables suffixed `dir` are kept, like autotools. Except above mentioned\n`bindir`, `includedir`, `pythondir`, etc, the following variables are kept.\n\n- `project_version`: project version\n- `prefixdir`: string `data`, used to combine `prefix`: `/tmp/tmpXXXXXXXXX/data`\n- `project_root`: temporary working directory like `/tmp/tmpXXXXXXXXX`\n- `datadir`: `$(prefix)/share`, because it is usual.\n\n### Autotools/Makefile\n\nExcept xmake, we also support classic GNU/Linux software build procedures:\n\n```sh\nautoreconf -vif\n./configure\nmake\nmake install\n```\n\nThe following build systems respect it:\n\n- [make](https://www.gnu.org/software/make/)/\n  [kati](https://github.com/google/kati/)\n- [xmake.sh](https://github.com/xmake-io/xmake.sh/)\n- [autotools](https://www.gnu.org/software/autoconf/)\n\nFor autotools, you must include\n[`variables.mak`](tests/examples/autotools/program/variables.mak) in your\n`Makefile.am`.\n\n## TODO\n\n- [ ] get version from scm: `dynamic = [\"version\"]` in `pyproject.toml`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmake-io%2Fxmake-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmake-io%2Fxmake-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmake-io%2Fxmake-python/lists"}