diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c4362c2..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Build - -# Run on the main branch and on tags (note conditional below) -on: - push: - branches: - - master - tags: - - v* - pull_request: - branches: - - master - -jobs: - build_wheels: - - # Only run if the commit message contains '[ci build]' OR always run if it's a tag - # This will not respect the tag if it appears in a pull request commit message. Those builds always show up as 'synchronize' events, and there is no easy way to get the corresponding commit messages. We instead pull the PR title to check for tags. - # More info here: https://github.community/t/accessing-commit-message-in-pull-request-event/17158/13 - if: "contains(toJSON(github.event.commits.*.message), '[ci build]') || contains(toJSON(github.event.pull_request.title), '[ci build]') || contains(github.ref, 'refs/tags')" - - strategy: - matrix: - include: - - runs-on: ubuntu-latest - cibw-arch: manylinux_x86_64 - - runs-on: ubuntu-latest - cibw-arch: manylinux_i686 - - runs-on: macos-latest - cibw-arch: macosx_x86_64 - - runs-on: macos-latest - cibw-arch: macosx_arm64 - - runs-on: macos-latest - cibw-arch: macosx_universal2 - - runs-on: windows-latest - cibw-arch: win_amd64 - - runs-on: windows-latest - cibw-arch: win32 - python-arch: x86 - - name: Build wheels ${{ matrix.cibw-arch }} - runs-on: ${{ matrix.runs-on }} - - env: - CIBW_BUILD_VERBOSITY: 3 - CIBW_BEFORE_BUILD_LINUX : "yum remove -y cmake && python -m pip install cmake" - - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.9' - - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.19.1 - - - name: Configure cibuildwheel - shell: bash - run: | - CMAKE_ARCH="${{ matrix.cibw-arch == 'win32' && '-A Win32' || '' }}" - CMAKE_OSX_ARCHITECTURES=${{ matrix.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.cibw-arch == 'macosx_universal2' && '"arm64;x86_64"' || '' }} - echo "CIBW_ARCHS_MACOS=x86_64 arm64 universal2" >> $GITHUB_ENV - echo "CIBW_BUILD=*-${{ matrix.cibw-arch }}" >> $GITHUB_ENV - echo "CIBW_ENVIRONMENT_MACOS=CMAKE_OSX_ARCHITECTURES=\"$CMAKE_OSX_ARCHITECTURES\"" >> $GITHUB_ENV - - - name: Package source distribution - if: runner.os == 'Linux' - run: | - python setup.py sdist -d wheelhouse --formats=gztar - - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse - - # Upload binaries to github - - uses: actions/upload-artifact@v2 - with: - path: | - ./wheelhouse/*.whl - ./wheelhouse/*.tar.gz - - # Push the resulting binaries to pypi on a tag starting with 'v' - upload_pypi: - needs: [build_wheels] - runs-on: ubuntu-latest - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' - steps: - - uses: actions/download-artifact@v2 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - skip_existing: true - # To test: repository_url: https://test.pypi.org/legacy/ - diff --git a/.github/workflows/cibuildwheel_config.toml b/.github/workflows/cibuildwheel_config.toml new file mode 100644 index 0000000..43ddcf7 --- /dev/null +++ b/.github/workflows/cibuildwheel_config.toml @@ -0,0 +1,13 @@ +[tool.cibuildwheel] +skip = "cp36-*" # scikit-build-core requires >=3.7 +build-verbosity = 3 + +[tool.cibuildwheel.linux] +before-all = [ + "yum remove -y cmake", +] + +# musllinux builds on an Alpinx Linux image, no need to mess with cmake there +[[tool.cibuildwheel.overrides]] +select = "*-musllinux*" +before-all = "" \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6550e39 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,91 @@ +name: Build and Publish + +# NOTE: build logic is duplicated here and in test_build.yml + +# Run on the main branch for commits only +on: + push: + branches: + - master + +jobs: + build_wheels: + + # only run if the most recent commit contains '[ci publish]' + if: "contains(github.event.head_commit.message, '[ci publish]')" + + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + name: Build wheels ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Package source distribution + if: runner.os == 'Linux' + run: | + python -m pip install build + python -m build --sdist + + - name: Run cibuildwheel + uses: pypa/cibuildwheel@v2.21 + with: + config-file: ".github/workflows/cibuildwheel_config.toml" + + - name: Copy source distribution into wheelhouse + if: runner.os == 'Linux' + run: mv dist/*.tar.gz wheelhouse/ + + # Upload binaries to the github artifact store + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }} + path: | + ./wheelhouse/*.whl + ./wheelhouse/*.tar.gz + overwrite: true + + # Push the resulting binaries to pypi on a tag starting with 'v' + upload_pypi: + name: Upload release to PyPI + + # only run if the most recent commit contains '[ci publish]' + if: "contains(github.event.head_commit.message, '[ci publish]')" + + needs: [build_wheels] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/potpourri3d + permissions: # we authenticate via PyPI's 'trusted publisher' workflow, this permission is required + id-token: write + steps: + - name: Download built wheels artifact # downloads from the jobs storage from the previous step + uses: actions/download-artifact@v4.1.7 + with: + # omitting the `name: ` field downloads all artifacts from this workflow + path: dist + + - name: List downloaded files from artifact + run: ls dist | cat # piping through cat prints one per line + + # dist directory has subdirs from the different jobs, merge them into one directory and delete + # the empty leftover dirs + - name: Flatten directory + run: find dist -mindepth 2 -type f -exec mv -t dist {} + && find dist -type d -empty -delete + + - name: List downloaded files from artifact after flatten + run: ls dist | cat # piping through cat prints one per line + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # To test: repository_url: https://test.pypi.org/legacy/ + diff --git a/.github/workflows/test_build.yml b/.github/workflows/test_build.yml new file mode 100644 index 0000000..b7a75f0 --- /dev/null +++ b/.github/workflows/test_build.yml @@ -0,0 +1,53 @@ +name: Test Build + +# NOTE: build logic is duplicated here and in publish.yml + +# Run on the master branch commit push and PRs to master (note conditional below) +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build_wheels: + + # Only run if the commit message contains '[ci build]' + if: "contains(toJSON(github.event.commits.*.message), '[ci build]') || contains(toJSON(github.event.pull_request.title), '[ci build]')" + + strategy: + fail-fast: false + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + name: Build wheels ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Package source distribution + if: runner.os == 'Linux' + run: | + python -m pip install build + python -m build --sdist + + - name: Run cibuildwheel + uses: pypa/cibuildwheel@v2.21 + with: + config-file: ".github/workflows/cibuildwheel_config.toml" + + # Upload binaries to the github artifact store + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }} + path: | + ./wheelhouse/*.whl + ./wheelhouse/*.tar.gz + overwrite: true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5e79f76 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[project] +name = "potpourri3d" +version = "1.2.0" +description = "An invigorating blend of 3D geometry tools in Python." +readme = "README.md" +license.file = "LICENSE" +authors = [ + { name = "Nicholas Sharp", email = "nmwsharp@gmail.com" }, +] +maintainers = [ + { name = "Nicholas Sharp", email = "nmwsharp@gmail.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", +] +requires-python = ">=3.7" + +dependencies = [ + "numpy", + "scipy" +] + +[project.urls] +Homepage = "https://github.com/nmwsharp/potpourri3d" + +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] +build.verbose = true +logging.level = "INFO" \ No newline at end of file