Skip to content

Commit

Permalink
Updating build infrastructure (#161)
Browse files Browse the repository at this point in the history
* Updating build infrastructure

* cibuildwheel tag name

* skip all 32bit builds
  • Loading branch information
dfm authored Nov 20, 2023
1 parent c93aaba commit 698b5fc
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 115 deletions.
37 changes: 21 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]
include:
- python-version: "3.10"
os: macos-latest
- python-version: "3.10"
os: windows-latest
steps:
- name: Clone the repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -38,12 +43,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone the repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
Expand All @@ -60,29 +65,29 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: pypa/cibuildwheel@2.5.0
- uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_SKIP: "*-win32 *-manylinux_i686"
CIBW_SKIP: "*-win32 *_i686"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.9"
Expand All @@ -91,7 +96,7 @@ jobs:
python -m pip install -U pip
python -m pip install -U build
python -m build --sdist .
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

Expand All @@ -100,12 +105,12 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
- uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.15...3.26)
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)

set(PYBIND11_NEWPYTHON ON)
find_package(pybind11 CONFIG REQUIRED)

include_directories(
"src/george/include"
"vendor/eigen"
)

pybind11_add_module(kernel_interface "src/george/kernel_interface.cpp")
install(TARGETS kernel_interface LIBRARY DESTINATION .)

pybind11_add_module(_hodlr "src/george/solvers/_hodlr.cpp")
install(TARGETS _hodlr LIBRARY DESTINATION ./solvers)
22 changes: 20 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
[project]
name = "george"
description = "Blazingly fast Gaussian Processes for regression."
readme = "README.rst"
authors = [{ name = "Daniel Foreman-Mackey", email = "foreman.mackey@gmail.com" }]
requires-python = ">=3.7"
license = { file = "LICENSE" }
urls = { Homepage = "https://github.com/dfm/george" }
dependencies = ["numpy", "scipy"]
dynamic = ["version"]

[build-system]
requires = ["setuptools>=40.6.0", "wheel", "setuptools_scm[toml]", "pybind11"]
build-backend = "setuptools.build_meta"
requires = ["scikit-build-core", "pybind11"]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/george/george_version.py"]
wheel.install-dir = "george"
minimum-version = "0.5"
build-dir = "build/{wheel_tag}"

[tool.setuptools_scm]
write_to = "src/george/george_version.py"
39 changes: 39 additions & 0 deletions scripts/compile_kernels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os

import yaml
from jinja2 import Template


def compile_kernels(fns):
template_dir = "templates"
output_dir = os.path.join("src", "george")

with open(os.path.join(template_dir, "parser.h")) as f:
PARSER_TEMPLATE = Template(f.read())
with open(os.path.join(template_dir, "kernels.h")) as f:
CPP_TEMPLATE = Template(f.read())
with open(os.path.join(template_dir, "kernels.py")) as f:
PYTHON_TEMPLATE = Template(f.read())

specs = []
for i, fn in enumerate(fns):
with open(fn, "r") as f:
spec = yaml.load(f.read(), Loader=yaml.FullLoader)
print("Found kernel '{0}'".format(spec["name"]))
spec["index"] = i
spec["reparams"] = spec.get("reparams", {})
specs.append(spec)
print("Found {0} kernel specifications".format(len(specs)))

fn = os.path.join(output_dir, "include", "george", "parser.h")
with open(fn, "w") as f:
print("Saving parser to '{0}'".format(fn))
f.write(PARSER_TEMPLATE.render(specs=specs))
fn = os.path.join(output_dir, "include", "george", "kernels.h")
with open(fn, "w") as f:
print("Saving C++ kernels to '{0}'".format(fn))
f.write(CPP_TEMPLATE.render(specs=specs))
fn = os.path.join(output_dir, "kernels.py")
with open(fn, "w") as f:
print("Saving Python kernels to '{0}'".format(fn))
f.write(PYTHON_TEMPLATE.render(specs=specs))
97 changes: 0 additions & 97 deletions setup.py

This file was deleted.

0 comments on commit 698b5fc

Please sign in to comment.