From 1b269658847759c04504c19b5c2ddc52eaedbeef Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Mon, 12 Aug 2024 10:10:20 +0100 Subject: [PATCH] initial github action test --- .github/workflows/make_wheels.yaml | 41 ++++++++++++++++++ .gitignore | 1 + README.md | 3 ++ pyarrow/meta.yaml | 55 ++++++++++++++++++++++++ pyarrow/patches/autoload_timezones.patch | 13 ++++++ scripts/get_pyodide_versions.sh | 6 +++ 6 files changed, 119 insertions(+) create mode 100644 .github/workflows/make_wheels.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 pyarrow/meta.yaml create mode 100644 pyarrow/patches/autoload_timezones.patch create mode 100644 scripts/get_pyodide_versions.sh diff --git a/.github/workflows/make_wheels.yaml b/.github/workflows/make_wheels.yaml new file mode 100644 index 0000000..3525359 --- /dev/null +++ b/.github/workflows/make_wheels.yaml @@ -0,0 +1,41 @@ +name: main + +on: + push: + pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + strategy: + matrix: + include: + - pyodide: 0.27.3 + python: 3.12 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: install pyodide build + run: pip install pyodide-build=${{ matrix.pyodide }} + - name: Get emscripten version + run: python -c 'from pyodide_build.build_env import emscripten_version;print(f"EMVERSION={emscripten_version()}")' >> $GITHUB_ENV + - name: Install emsdk ${{env.EMVERSION}} + uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{env.EMVERSION}} + actions-cache-folder: 'emsdk-cache' + - run: mkdir dist + - name: Arrow build + run: pyodide build-recipe-no-deps --recipe-dir . --target-dir dist pyarrow + - uses: actions/upload-artifact@v4 + with: + name: build_wheel + path: dist + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98e0579 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.pyodide* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae5ef9f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# PyArrow build for pyodide + +This builds pyarrow wheels for use in pyodide. It is separate to the main pyodide build because pyarrow is a SLOW build. \ No newline at end of file diff --git a/pyarrow/meta.yaml b/pyarrow/meta.yaml new file mode 100644 index 0000000..f3030af --- /dev/null +++ b/pyarrow/meta.yaml @@ -0,0 +1,55 @@ +package: + name: pyarrow + version: 17.0.0 + top-level: + - pyarrow +source: + url: https://github.com/apache/arrow/releases/download/apache-arrow-17.0.0/apache-arrow-17.0.0.tar.gz + sha256: 9d280d8042e7cf526f8c28d170d93bfab65e50f94569f6a790982a878d8d898d + # extract_dir: arrow-57ac40ca23ebcaa4d42ae808137033689d3be9b1 + patches: + - patches/autoload_timezones.patch +build: + script: | + # move things around so that the top level folder is the python folder + # with the pyproject.toml, so pyodide build works + cd .. + # build libarrow as static library without the pyodide toolchain file + # because that does bad things to the build + BACKUP_TOOLCHAIN=${CMAKE_TOOLCHAIN_FILE} + unset CMAKE_TOOLCHAIN_FILE + if [ ! -d "${PKG_BUILD_DIR}_cpp" ]; then + mv $PKG_BUILD_DIR ${PKG_BUILD_DIR}_cpp + cp -r ${PKG_BUILD_DIR}_cpp/python $PKG_BUILD_DIR + # build arrow cpp library and install to emscripten sysroot + # n.b. the if statements below mean that you can call pyodide build-packages-no-deps + # pyarrow --continue to debug build errors without having to do a full rebuild + mkdir cppbuild + cd cppbuild + emcmake cmake --preset ninja-release-emscripten ${PKG_BUILD_DIR}_cpp/cpp + else + cd cppbuild + fi + cmake --build . --target=protobuf_ep_host -j 4 + cmake --build . --target=install -j 4 + cd ${PKG_BUILD_DIR} + export CMAKE_TOOLCHAIN_FILE=${BACKUP_TOOLCHAIN} + rm -f CMakeCache.txt + rm -rf CMakeFiles + cross-script: | + cmake --version +about: + home: https://arrow.apache.org/ + PyPI: https://pypi.org/project/pyarrow + summary: Python library for Apache Arrow + license: Apache License, Version 2.0 +requirements: + run: + - numpy + - pandas + - pyodide-unix-timezones + host: + - numpy +extra: + recipe-maintainers: + - joemarshall diff --git a/pyarrow/patches/autoload_timezones.patch b/pyarrow/patches/autoload_timezones.patch new file mode 100644 index 0000000..9e239dc --- /dev/null +++ b/pyarrow/patches/autoload_timezones.patch @@ -0,0 +1,13 @@ +diff --git a/python/pyarrow/__init__.py.orig b/python/pyarrow/__init__.py +index e52e0d24..9982f41c 100644 +--- a/python/pyarrow/__init__.py ++++ b/python/pyarrow/__init__.py +@@ -28,7 +28,7 @@ streaming messaging and interprocess communication. + + For more information see the official page at https://arrow.apache.org + """ +- ++import unix_timezones + import gc as _gc + import importlib as _importlib + import os as _os diff --git a/scripts/get_pyodide_versions.sh b/scripts/get_pyodide_versions.sh new file mode 100644 index 0000000..47da0f9 --- /dev/null +++ b/scripts/get_pyodide_versions.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +PACKAGE_JSON_URL="https://pypi.org/pypi/pyodide-build/json" + +wget --no-check-certificate "$PACKAGE_JSON_URL" -O- | jq -r '.releases | keys | .[]' |sort -V