Skip to content

Commit

Permalink
#16: bindings: Try buidling python package with cibuildwheel
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 7, 2023
1 parent e7c77f0 commit d6ad0f0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 102 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
name: Pip
name: Build bindings and publish to PyPI

on:
workflow_dispatch:
pull_request:
push:

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.8", "3.9"]

build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2

- uses: actions/setup-python@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: '3.8'

- name: Build wheels
run: |
pip install cibuildwheel
cibuildwheel --output-dir wheelhouse
- name: Set min macOS version
if: runner.os == 'macOS'
- name: Install twine
run: |
echo "MACOS_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV
pip install twine
- name: Build and install
run:
# python -m pip install pytest
pip install --verbose .
# - name: Test wheels
# run: |
# pip install wheelhouse/*.whl
# # Run tests

# - name: Test
# run: python -m pytest
- name: Publish to TestPyPI
if: github.event_name == 'push'
run: |
twine upload testpypi wheelhouse/*.whl
78 changes: 0 additions & 78 deletions .github/workflows/wheels.yml

This file was deleted.

42 changes: 42 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import sys
import setuptools
import nanobind

class get_nanobind_include(object):
"""Helper class to determine the nanobind include path
The purpose of this class is to postpone importing nanobind
until it is actually installed, so that the `get_include()`
method can be invoked."""

def __str__(self):
import nanobind
return nanobind.get_include()

ext_modules = [
Extension(
'vttv',
['bindings/python/tv.cpp'],
include_dirs=[
# Path to nanobind headers
get_nanobind_include(),
'./' # Assuming the root of your C++ project is the current directory
],
language='c++'
),
]

setup(
name='vttv',
version='0.0.1',
author='Pierre Pebay',
author_email='[email protected]',
url='https://github.com/DARMA-tasking/vt-tv',
description='Virtual Transport Task Visualizer',
long_description='',
ext_modules=ext_modules,
setup_requires=['nanobind>=1.3.2'],
cmdclass={'build_ext': build_ext},
zip_safe=False,
)

0 comments on commit d6ad0f0

Please sign in to comment.