-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:sandialabs/SpecUtils
- Loading branch information
Showing
25 changed files
with
1,944 additions
and
17,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# From https://github.com/wjakob/nanobind_example/blob/5ce5ce57143a469e92d9ebaee9c47949ee77caa8/.github/workflows/pip.yml | ||
name: Pip | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
name: Build with Pip | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [windows-latest, macos-latest, ubuntu-latest] | ||
#python-version: ["3.9", "3.12"] | ||
python-version: ["3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Set min macOS version | ||
if: runner.os == 'macOS' | ||
run: | | ||
echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV | ||
- name: Build and install | ||
run: | | ||
python -m pip install pytest | ||
pip install --verbose ./bindings/python | ||
- name: Test | ||
run: python -m unittest discover ./bindings/python/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# From https://github.com/wjakob/nanobind_example/blob/5ce5ce57143a469e92d9ebaee9c47949ee77caa8/.github/workflows/wheels.yml | ||
|
||
name: Wheels | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build_sdist: | ||
name: Build SDist | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Build SDist | ||
run: pipx run build --sdist ./bindings/python | ||
|
||
- name: Check metadata | ||
run: pipx run twine check ./bindings/python/dist/* | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist-sdist | ||
path: dist/*.tar.gz | ||
|
||
|
||
build_wheels: | ||
name: Wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-13, macos-14, macos-latest, windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- uses: pypa/[email protected] | ||
env: | ||
CIBW_ARCHS_MACOS: "universal2" | ||
with: | ||
package-dir: ./bindings/python | ||
|
||
- name: Verify clean directory | ||
run: git diff --exit-code | ||
shell: bash | ||
|
||
- name: Upload wheels | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: wheelhouse/*.whl | ||
name: dist-${{ matrix.os }} | ||
|
||
upload_all: | ||
name: Upload if release | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/SandiaSpecUtils | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
|
||
steps: | ||
- uses: actions/setup-python@v5 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
pattern: dist-* | ||
merge-multiple: true | ||
- shell: bash | ||
run: | | ||
pwd | ||
ls | ||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: /home/runner/work/SpecUtils/SpecUtils | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
|
||
project(SpecUtils_py LANGUAGES CXX) | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
set( SpecUtils_ENABLE_D3_CHART ON CACHE BOOL "" ) | ||
set( SpecUtils_D3_SUPPORT_FILE_STATIC ON CACHE BOOL "" ) | ||
set( SpecUtils_ENABLE_URI_SPECTRA OFF CACHE BOOL "" ) #Lets not worry about linking to zlib right now | ||
set( SpecUtils_PYTHON_BINDINGS ON CACHE BOOL "Build the python bindings" ) | ||
set( SpecUtils_ENABLE_EQUALITY_CHECKS OFF CACHE BOOL "" ) | ||
set( PERFORM_DEVELOPER_CHECKS OFF CACHE BOOL "" ) | ||
set( SpecUtils_SHARED_LIB OFF CACHE BOOL "" ) #we'll statically link SpecUtils into the lib we create here | ||
set( SpecUtils_FLT_PARSE_METHOD "strtod" CACHE STRING "Float parsing method" ) | ||
|
||
add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/LibSpecUtils ) | ||
|
||
if (NOT SKBUILD) | ||
message(FATAL_ERROR "\ | ||
This CMake file is must be executed using 'scikit-build'. | ||
If you are a user trying to install this package, please use the command | ||
below, which will install all necessary build dependencies, compile | ||
the package in an isolated environment, and then install it. | ||
===================================================================== | ||
$ pip install . | ||
===================================================================== | ||
If you are a software developer, and this is your own package, then | ||
it is usually much more efficient to install the build dependencies | ||
in your environment once and use the following command that avoids | ||
a costly creation of a new virtual environment at every compilation: | ||
===================================================================== | ||
$ pip install nanobind scikit-build-core | ||
$ pip install --no-build-isolation -ve . | ||
===================================================================== | ||
You may optionally add -Ceditable.rebuild=true to auto-rebuild when | ||
the package is imported. Otherwise, you need to re-run the above | ||
after editing C++ files.") | ||
endif() | ||
|
||
# Try to import all Python components potentially needed by nanobind | ||
find_package(Python 3.8 | ||
REQUIRED COMPONENTS Interpreter Development.Module | ||
OPTIONAL_COMPONENTS Development.SABIModule) | ||
|
||
# Import nanobind through CMake's find_package mechanism | ||
find_package(nanobind CONFIG REQUIRED) | ||
|
||
# We are now ready to compile the actual extension module | ||
nanobind_add_module( | ||
# Name of the extension | ||
PySpecUtils | ||
|
||
# Target the stable ABI for Python 3.12+, which reduces | ||
# the number of binary wheels that must be built. This | ||
# does nothing on older Python versions | ||
STABLE_ABI | ||
|
||
# Build libnanobind statically and merge it into the | ||
# extension (which itself remains a shared library) | ||
# | ||
# If your project builds multiple extensions, you can | ||
# replace this flag by NB_SHARED to conserve space by | ||
# reusing a shared libnanobind across libraries | ||
NB_STATIC | ||
|
||
#Perform link time optimization. | ||
#LTO | ||
|
||
|
||
# Source code goes here | ||
SpecFile_py.cpp | ||
) | ||
|
||
set_target_properties( PySpecUtils PROPERTIES OUTPUT_NAME "SpecUtils" ) | ||
target_link_libraries( PySpecUtils PUBLIC SpecUtils ) | ||
|
||
# Install directive for scikit-build-core | ||
install(TARGETS PySpecUtils LIBRARY DESTINATION SpecUtils) | ||
install(FILES __init__.py DESTINATION SpecUtils) | ||
|
||
nanobind_add_stub( | ||
SpecUtils_stub | ||
MODULE SpecUtils | ||
OUTPUT SpecUtils.pyi | ||
PYTHON_PATH $<TARGET_FILE_DIR:PySpecUtils> | ||
DEPENDS PySpecUtils | ||
) |
Binary file not shown.
Oops, something went wrong.