Skip to content

Convert to pyproject #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 92 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,109 @@ on:
branches: [ main ]

jobs:

build:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
- run: ruff check
- run: ruff format --check --diff
build-binaries:
needs: [ lint ]
strategy:
matrix:
include:
- name: x86-windows
image: windows-2022
arch: x86
- name: x86_64-linux
image: ubuntu-22.04
cmake-args: -D ARCHITECTURE=x86_64
- name: x86_64-windows
image: windows-2022
arch: x86_64
- name: x86_64-linux
image: ubuntu-20.04
arch: x86_64
cmake-args: -A x64 -D ARCHITECTURE=x86_64
- name: x86_64-darwin
image: macos-12
arch: x86_64
image: macos-13
cmake-args: -D CMAKE_OSX_ARCHITECTURES=x86_64 -D ARCHITECTURE=x86_64
- name: aarch64-darwin
image: macos-13
cmake-args: -D CMAKE_OSX_ARCHITECTURES=arm64 -D ARCHITECTURE=aarch64
runs-on: ${{ matrix.image }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Query Python executable
run: which python
- name: Install dependencies
run: python -m pip install h5py matplotlib numpy pytest scipy setuptools wheel
- name: Build Python Wheel
run: python setup.py bdist_wheel
- name: Install Python Wheel
shell: bash
with:
submodules: true
- name: Build NDTable
run: |
for f in dist/SDF-*-py3-none-any.whl; do
python -m pip install $f --no-deps -vv
done
- name: Run Python tests
run: pytest tests
- name: Upload artifacts
uses: actions/upload-artifact@v4
cmake -S C -B C/${{ matrix.name }} ${{ matrix.cmake-args }}
cmake --build C/${{ matrix.name }} --target install
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: dist/*.whl
path: src/sdf/ndtable/${{ matrix.name }}
if-no-files-found: error
build-wheel:
runs-on: ubuntu-22.04
needs: [build-binaries]
steps:
- uses: astral-sh/setup-uv@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: x86_64-linux
path: src/sdf/ndtable/x86_64-linux
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v4
with:
name: x86_64-windows
path: src/sdf/ndtable/x86_64-windows
- uses: actions/download-artifact@v4
with:
name: x86_64-darwin
path: src/sdf/ndtable/x86_64-darwin
- uses: actions/download-artifact@v4
with:
name: aarch64-darwin
path: src/sdf/ndtable/aarch64-darwin
- run: uv build --wheel
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
if-no-files-found: error
run-tests:
needs: [ build-wheel ]
strategy:
matrix:
include:
- name: x86_64-linux
image: ubuntu-22.04
- name: x86_64-windows
image: windows-2022
- name: x86_64-darwin
image: macos-13
- name: aarch64-darwin
image: macos-13
runs-on: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- run: rm pyproject.toml
- uses: astral-sh/setup-uv@v4
- uses: actions/download-artifact@v4
with:
name: dist
- if: matrix.name == 'x86_64-windows'
run: |
uv venv --python 3.10
.venv\Scripts\activate
uv pip install pytest
$files = Get-ChildItem "sdf-*-py3-none-any.whl"
foreach ($f in $files) {
uv pip install $f.FullName
}
uv run pytest
- if: matrix.name != 'x86_64-windows'
run: |
uv venv --python 3.10
source .venv/bin/activate
uv pip install pytest
uv pip install sdf-*-py3-none-any.whl
uv run pytest
62 changes: 10 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,19 @@
# SDF files
*.sdf

# Build artefacts
*.o

# PyCharm projects
.idea/

# compiled code
*.py[cod]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Python artifacts
__pycache__

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# data files
*.h5
*.mat
!DoublePendulum.mat

# temp files
~*

# Eclipse user settings
.settings/

# PDFs
*.pdf

# auto generated manifest
MANIFEST

# automation scripts
# *.bat
# native binaries
*.dll
*.dylib
*.lib
*.so

# test file
!IntegerNetwork1.mat
# build artifacts
C/aarch64-*/
C/x86-*/
C/x86_64-*/
46 changes: 46 additions & 0 deletions C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required (VERSION 3.20)

cmake_policy(SET CMP0177 NEW)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)

project (NDTable)

set(ARCHITECTURE "" CACHE STRING "Architecture")
set_property(CACHE ARCHITECTURE PROPERTY STRINGS "" "aarch64" "x86" "x86_64")

if (NOT ARCHITECTURE)
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "AMD64|x86_64")
set(ARCHITECTURE "x86_64")
elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(ARCHITECTURE "aarch64")
else ()
message(FATAL_ERROR "Unknown System Architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif ()
endif ()

if (WIN32)
set(PLATFORM "${ARCHITECTURE}-windows")
elseif (APPLE)
set(PLATFORM "${ARCHITECTURE}-darwin")
else ()
set(PLATFORM "${ARCHITECTURE}-linux")
endif ()

message(STATUS "PLATFORM: ${PLATFORM}")

add_library(NDTable SHARED
"include/Python.h"
"src/Python.c"
"NDTable/include/NDTable.h"
"NDTable/src/Core.c"
"NDTable/src/Interpolation.c"
)

target_include_directories(NDTable PRIVATE
"include"
"NDTable/include"
)

install(TARGETS NDTable DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/../src/sdf/ndtable/${PLATFORM}")
Loading