From 79628ba7b38902e4a9de80bd7ea89a3871e183ba Mon Sep 17 00:00:00 2001 From: Henry Schreiner <HenrySchreinerIII@gmail.com> Date: Tue, 29 Nov 2022 09:45:24 -0500 Subject: [PATCH] feat: move to scikit-build-core (#54) * feat: move to scikit-build-core Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update CMakeLists.txt * WIP: try some things * ci: try Windows Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * ci: Windows change Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update meta.yaml * Update meta.yaml * Update meta.yaml * Update meta.yaml * Update meta.yaml * chore: use scikit-build-core 0.1.0 Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * ci: try 2019 * Update meta.yaml * Update conda.recipe/meta.yaml * Update .github/workflows/conda.yml Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --- .github/workflows/conda.yml | 2 +- .github/workflows/wheels.yml | 2 +- .pre-commit-config.yaml | 2 +- CMakeLists.txt | 20 +++----------------- conda.recipe/meta.yaml | 9 ++++----- pyproject.toml | 26 +++++++++++++++++++------- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 5c44f57..31ee52c 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, macos-latest] # TODO: windows after 2016 doesn't config correctly + platform: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.10"] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8120546..f3de814 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,7 +49,7 @@ jobs: - uses: pypa/cibuildwheel@v2.11.2 env: - CIBW_ARCHS_MACOS: auto universal2 + CIBW_ARCHS_MACOS: universal2 - name: Verify clean directory run: git diff --exit-code diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 09cd8c9..84bf635 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: rev: v3.2.2 hooks: - id: pyupgrade - args: ["--py36-plus"] + args: ["--py37-plus"] # Changes tabs to spaces - repo: https://github.com/Lucas-C/pre-commit-hooks diff --git a/CMakeLists.txt b/CMakeLists.txt index 17efbaf..f635421 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,10 @@ -cmake_minimum_required(VERSION 3.15...3.22) +cmake_minimum_required(VERSION 3.15...3.25) -project(scikit_build_example VERSION "0.0.1") +project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION}) -if(SKBUILD) - # Scikit-Build does not add your site-packages to the search path - # automatically, so we need to add it _or_ the pybind11 specific directory - # here. - execute_process( - COMMAND "${PYTHON_EXECUTABLE}" -c - "import pybind11; print(pybind11.get_cmake_dir())" - OUTPUT_VARIABLE _tmp_dir - OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) - list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}") -endif() - -# Now we can find pybind11 find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(_core MODULE src/main.cpp) - target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) -install(TARGETS _core DESTINATION .) +install(TARGETS _core DESTINATION scikit_build_example) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 956c909..e0ff66a 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -7,19 +7,18 @@ source: build: number: 0 - script: python -m pip install . -vvv + script: {{ PYTHON }} -m pip install . -vv requirements: build: + - python - {{ compiler('cxx') }} host: - python - pip - - pybind11 >=2.6.0 - - scikit-build - - cmake >=3.18 - - ninja + - scikit-build-core + - pybind11 >=2.10.0 run: - python diff --git a/pyproject.toml b/pyproject.toml index 4aae518..3b389ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,28 @@ [build-system] -requires = [ - "setuptools>=42", - "pybind11>=2.10.1", - "cmake>=3.22", - "scikit-build>=0.15.0", -] -build-backend = "setuptools.build_meta" +requires = ["scikit-build-core", "pybind11"] +build-backend = "scikit_build_core.build" + + +[project] +name = "scikit_build_example" +version = "0.0.1" +requires-python = ">=3.7" + + +[tool.scikit-build] +wheel.expand-macos-universal-tags = true + + +[project.optional-dependencies] +test = ["pytest"] + [tool.isort] profile = "black" + [tool.cibuildwheel] test-command = "pytest {project}/tests" test-extras = ["test"] test-skip = ["*universal2:arm64"] +build-verbosity = 1 -- GitLab