From a093f6d918ebc6d0abbdee7dfc4ca69779b1caa3 Mon Sep 17 00:00:00 2001 From: x-io Technologies Date: Fri, 16 Aug 2024 11:33:46 +0100 Subject: [PATCH] Modernise Python build --- .github/workflows/main.yml | 5 ++--- pyproject.toml | 20 ++++++++++++++++++++ setup.py | 26 +------------------------- 3 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2df1cd..309e701 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,12 +45,11 @@ jobs: platforms: all - name: Build wheel - uses: pypa/cibuildwheel@v2.17.0 + uses: pypa/cibuildwheel@v2.20.0 env: CIBW_ARCHS: all CIBW_BUILD: ${{ matrix.python-version }}${{ matrix.target[1] }} - CIBW_BEFORE_BUILD: pip install numpy - CIBW_BEFORE_TEST: pip install numpy matplotlib + CIBW_BEFORE_TEST: pip install matplotlib CIBW_TEST_COMMAND: cd {project}/Python && python advanced_example.py no_block && python simple_example.py no_block CIBW_TEST_COMMAND_WINDOWS: cd /D {project}/Python && python advanced_example.py no_block && python simple_example.py no_block CIBW_TEST_SKIP: "*-macosx_arm64" # fix CI warning diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..71de19b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +requires = ["setuptools", "numpy"] +build-backend = "setuptools.build_meta" + +[project] +name = "imufusion" +version = "1.2.5" +description = "Fusion Python package" +readme = { text = "See [github](https://github.com/xioTechnologies/Fusion) for documentation and examples.", content-type = "text/markdown" } +authors = [{ name = "x-io Technologies Limited", email = "info@x-io.co.uk" }] +license = { file = "LICENSE.md" } +classifiers = ["Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12"] # versions shown by pyversions badge in README + +[project.urls] +Repository = "https://github.com/xioTechnologies/Fusion" + +[tool.setuptools] +py-modules = [] # fix cibuildwheel error: "Multiple top-level packages discovered in a flat-layout" diff --git a/setup.py b/setup.py index 309fbe1..891af06 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,7 @@ import numpy -import os -import shutil import sys from setuptools import setup, Extension -for folder in ["build", "dist", "imufusion.egg-info"]: - if os.path.exists(folder) and os.path.isdir(folder): - shutil.rmtree(folder) - -if len(sys.argv) == 1: # if this script was called without arguments - sys.argv.append("install") - sys.argv.append("--user") - -github_url = "https://github.com/xioTechnologies/Fusion" - ext_modules = Extension("imufusion", ["Python/Python-C-API/imufusion.c", "Fusion/FusionAhrs.c", "Fusion/FusionCompass.c", @@ -22,16 +10,4 @@ define_macros=[("FUSION_USE_NORMAL_SQRT", None)], libraries=(["m"] if "linux" in sys.platform else [])) # link math library for Linux -setup(name="imufusion", - version="1.2.5", - description="Fusion Python package", - long_description="See [github](" + github_url + ") for documentation and examples.", - long_description_content_type='text/markdown', - url=github_url, - author="x-io Technologies Limited", - author_email="info@x-io.co.uk", - license="MIT", - classifiers=["Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12"], # versions shown by pyversions badge in README - ext_modules=[ext_modules]) +setup(ext_modules=[ext_modules])