diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 81ce843d9f..ad6ae695d6 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -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 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index 4ae91f8b3a..0000000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Wheels - -on: - workflow_dispatch: - pull_request: - push: - -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 - - - name: Check metadata - run: pipx run twine check dist/* - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - - - build_wheels: - name: Wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - uses: pypa/cibuildwheel@v2.13.0 - env: - # Cross-compile on macOS - CIBW_ARCHS_MACOS: x86_64 arm64 - - # Temporary: use pre-release Python 3.12 for stable ABI builds - CIBW_PRERELEASE_PYTHONS: True - - - name: Verify clean directory - run: git diff --exit-code - shell: bash - - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - path: wheelhouse/*.whl - - - upload_all: - name: Upload to PyPI - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest - environment: - name: pypi - url: https://test.pypi.org/p/vt-tv - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - - steps: - - uses: actions/setup-python@v4 - - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..d52437de3b --- /dev/null +++ b/setup.py @@ -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='pierre.pebat@ng-analytics.com', + 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, +) \ No newline at end of file