CNES / pangeo-pyinterp

Python library for optimized interpolation.
https://pangeo-pyinterp.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
117 stars 16 forks source link

Provide manylinux wheels #21

Open mcleantom opened 1 year ago

mcleantom commented 1 year ago

Is your feature request related to a problem? Please describe. Providing pre-built wheels built inside a manylinux container makes the package easier and faster to install on Linux.

Describe the solution you'd like Create python wheels inside a manylinux container and publish those to pypi.

Describe alternatives you've considered I could build the package myself inside a manylinux container and move it onto my server but may as well add it to the main package if possible :)

Additional context I have done this sort of thing before but I haven't ran it with github workflows (i've done it with Jenkins).

There are some example workflows here:

And an example in the cibuildwheel package

name: Build and upload to PyPI

# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
# on:
#   push:
#   pull_request:
#   release:
#     types:
#       - published

jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-20.04, windows-2019, macos-11]

    steps:
      - uses: actions/checkout@v3

      - name: Build wheels
        uses: pypa/cibuildwheel@v2.12.1

      - uses: actions/upload-artifact@v3
        with:
          path: ./wheelhouse/*.whl

  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Build sdist
        run: pipx run build --sdist

      - uses: actions/upload-artifact@v3
        with:
          path: dist/*.tar.gz

  upload_pypi:
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    # upload to PyPI on every tag starting with 'v'
    if: github.event_name == 'push' && startsWith(github.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@v3
        with:
          # unpacks default artifact into dist/
          # if `name: artifact` is omitted, the action will create extra parent dir
          name: artifact
          path: dist

      - uses: pypa/gh-action-pypi-publish@v1.5.0
        with:
          user: __token__
          password: ${{ secrets.pypi_password }}
          # To test: repository_url: https://test.pypi.org/legacy/

I am happy to try implement this myself and do a PR.

fbriol commented 1 year ago

If you have some time you can try to implement it with a PR.

mcleantom commented 1 year ago

@fbriol I am working on this now, Do you know how I can pass in the root folder of boost as an argument into setup.py, rather than it being auto-detected?

fbriol commented 1 year ago

I apologize for the delay in getting back to you. Let's address your question about specifying the root folder of Boost as an argument in setup.py.

To pass the Boost root folder as an argument, you can use the --boost-root option when running setup.py. This option allows you to manually set the Preferred Boost installation prefix rather than having it auto-detected.

Here's the command you can use to pass the Boost root folder path:

python3 setup.py build_ext --boost-root=/path/to/boost

Make sure to replace /path/to/boost with the actual path to your Boost installation directory.

When you specify the --boost-root option, the build process will use the Boost installation in the directory you provided, rather than searching for it in the system's default locations.

If you need information on other available options, you can run the following command:

python3 setup.py build_ext --help

This will display all the available options for building the library.

If you want to take a look at the source code of setup.py to better understand its implementation, you can find it in the repository. Usually, the setup.py file is located at the root of the project.

If you have any more questions or need further assistance, feel free to ask. Happy coding!

Again, I apologize for the delay in responding. If there's anything else I can help you with, please let me know.

Best regards, Frederic

mcleantom commented 2 months ago

I managed to get a working version (https://github.com/mcleantom/pangeo-pyinterp) however it required a fair bit of restructuring to get it to work so I haven't made a PR, however I am able to create wheels for both windows and linux 👍 Just thought I would show incase you thought It was worth continuing to make a PR.