Skip to content

Commit

Permalink
Use scikit-build-core and pyproject.toml for top-level install (#673)
Browse files Browse the repository at this point in the history
* Try out scikit-build-core

* Install checking packages

* Disable mypy

* Config update

* pytest-xdist

* dependencies

* In right place...

* Install optional dependencies

* Add scipy

* Sort out package name

* Tweak

* More tweaking

* Add sphinx

* Add markdown

* yaml

* pyyaml

* pylit

* Revert python folder

* Path with SKbuild

* Use ci tag for Mac build

* Use CI tag

* remove ffcx test - should be in ffcx not here

* Break up optional dependencies

* Copy over from setup.py

* Try re-enabling mypy

* Remove macos-11, C++ compiler too old.

* Bump cibuildwheel action and use build to create sdist.

* Push.

* Make Python 3.8 the minimum

* Typo.

* Try buildjet for arm64 linux.

* Revert "Try buildjet for arm64 linux."

This reverts commit f938ae6.

---------

Co-authored-by: Jack S. Hale <[email protected]>
  • Loading branch information
chrisrichardson and jhale authored Jun 7, 2023
1 parent b082121 commit 0fc130f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 50 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, macos-12]
os: [ubuntu-latest, macos-12, macos-13]

steps:
- uses: actions/checkout@v3
Expand All @@ -54,7 +54,7 @@ jobs:
platforms: arm64

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.1
uses: pypa/cibuildwheel@v2.13.0

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand All @@ -68,12 +68,15 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.basix_ref }}

- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools

- name: Install skbuild
run: python -m pip install scikit-build
- name: Install build
run: python -m pip install build

- name: Build sdist
run: python setup.py sdist --formats=gztar
run: python -m build --sdist .

- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ffcx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ jobs:

- name: Install FFCx
run: python3 -m pip install ./ffcx[ci]
- name: Run mypy checks
run: python3 -m mypy ffcx/ffcx
- name: Run FFCx tests
run: python3 -m pytest -n auto ffcx/test
14 changes: 6 additions & 8 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.19)

# Set the version
project(Basix VERSION "0.7.0.0" LANGUAGES CXX)
Expand All @@ -8,7 +8,8 @@ if(SKBUILD)
# Always use lib/ in the Python root. Otherwise, environment used for
# wheels might place in lib64/, which CMake on some systems will not
# find.
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_LIBDIR basix/lib)
set(CMAKE_INSTALL_INCLUDEDIR basix/include)
endif()

include(FeatureSummary)
Expand Down Expand Up @@ -92,14 +93,11 @@ target_sources(basix PRIVATE
set_target_properties(basix PROPERTIES PUBLIC_HEADER basix/finite-element.h)
set_target_properties(basix PROPERTIES PRIVATE_HEADER "${HEADERS_basix}")
target_include_directories(basix PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}>")

# The commented lines need CMake >= 3.18
# target_link_libraries(basix PRIVATE BLAS::BLAS)
# target_link_libraries(basix PRIVATE LAPACK::LAPACK)
target_link_libraries(basix PRIVATE ${BLAS_LIBRARIES})
target_link_libraries(basix PRIVATE ${LAPACK_LIBRARIES})
target_link_libraries(basix PRIVATE BLAS::BLAS)
target_link_libraries(basix PRIVATE LAPACK::LAPACK)

# Set compiler flags
list(APPEND BASIX_DEVELOPER_FLAGS -O2;-g;-pipe)
Expand Down
33 changes: 29 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
[project]
name = "fenics-basix"
version = "0.7.0.dev0"
description = "Basix Python interface"
readme = "README.md"
requires-python = ">=3.8.0"
license = {file = "LICENSE"}
authors = [{email="[email protected]"}, {name="FEniCS Project"}]
packages = ["basix"]
dependencies = ["numpy>=1.21"]

[project.optional-dependencies]
docs = ["markdown", "pylit3", "pyyaml", "sphinx==5.0.2", "sphinx_rtd_theme"]
lint = ["flake8", "pydocstyle"]
optional = ["numba", "fenics-ufl@git+https://github.com/fenics/ufl"]
test = ["pytest", "sympy", "scipy", "matplotlib", "fenics-basix[optional]"]
ci = ["mypy", "pytest-xdist", "fenics-basix[docs]", "fenics-basix[lint]",
"fenics-basix[optional]", "fenics-basix[test]"]

[tool.pytest.ini_options]
testpaths = ["test"]
# addopts = "-n auto --durations 20"

[build-system]
requires = ["setuptools>=42", "wheel", "pybind11>=2.9.1", "cmake>=3.16", "scikit-build>=0.12"]
requires = ["pybind11>=2.9.1", "cmake>=3.19", "scikit-build-core"]
build-backend = "scikit_build_core.build"

build-backend = "setuptools.build_meta"
[tool.scikit-build]
wheel.packages = ["python/basix"]

[tool.cibuildwheel]
build = ["cp{37,38,39}-manylinux_x86_64", "cp{37,38,39}-manylinux_aarch64", "cp{37,38,39}-macosx_x86_64", "cp{38,39}-macosx_arm64"]
build = ["cp{38,39,310}-manylinux_x86_64", "cp{38,39,310}-manylinux_aarch64", "cp{38,39,310}-macosx_x86_64", "cp{38,39,310}-macosx_arm64"]

test-command = [
"cmake -G Ninja -DPython3_EXECUTABLE=$(which python) -B build-dir -S {project}/test/test_cmake",
Expand All @@ -16,7 +41,7 @@ test-requires = ["pytest-xdist"]
test-extras = ["test"]
test-skip = "*-macosx_arm64 *-*linux_aarch64"

manylinux-x86_64-image = "manylinux2014"
manylinux-x86_64-image = "manylinux_2_28"

[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"] # Forces arm64 build on x86_64 runner using emulation.
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ if (SKBUILD)
set_target_properties(_basixcpp PROPERTIES INSTALL_RPATH "$ORIGIN/lib")
endif()

install(TARGETS _basixcpp DESTINATION .)
install(TARGETS _basixcpp DESTINATION basix)
endif()
30 changes: 0 additions & 30 deletions setup.py

This file was deleted.

0 comments on commit 0fc130f

Please sign in to comment.