forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build PyVelox Wheels for Linux and MacOS (x86_64) (facebookincubator#…
…3884) Summary: This PR sets up a CI Job to build pyvelox wheels for x86_64 MacOS and Linux for python 3.9 - 3.11. The wheels are uploaded as artifacts. We can easily add a job to publish them to pypi regularly. Pull Request resolved: facebookincubator#3884 Reviewed By: amitkdutta Differential Revision: D43377917 Pulled By: kgpai fbshipit-source-id: d413c40c9f80189ab9ecd4444685a59cc11091f9
- Loading branch information
1 parent
e4a2c99
commit e09c078
Showing
7 changed files
with
225 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Build Pyvelox Wheels | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'pyvelox version' | ||
required: false | ||
ref: | ||
description: 'git ref to build' | ||
required: false | ||
publish: | ||
description: 'publish to PyPI' | ||
required: false | ||
type: boolean | ||
default: false | ||
# schedule: | ||
# - cron: '15 0 * * *' | ||
pull_request: | ||
paths: | ||
- 'velox/**' | ||
- '!velox/docs/**' | ||
- 'third_party/**' | ||
- 'pyvelox/**' | ||
- '.github/workflows/build_pyvelox.yml' | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.head_ref || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-22.04, macos-11] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ inputs.ref || github.ref }} | ||
fetch-depth: 0 | ||
submodules: recursive | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: "Determine Version" | ||
if: ${{ !inputs.version && github.event_name != 'pull_request' }} | ||
id: version | ||
run: | | ||
# count number of commits since last tag matching a regex | ||
# and use that to determine the version number | ||
# e.g. if the last tag is 0.0.1, and there have been 5 commits since then | ||
# the version will be 0.0.1a5 | ||
git fetch --tags | ||
INITIAL_COMMIT=5d4db2569b7c249644bf36a543ba1bd8f12bf77c | ||
# Can't use PCRE for portability | ||
BASE_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' version.txt) | ||
LAST_TAG=$(git describe --tags --match "pyvelox-v[0-9]*" --abbrev=0 || echo $INITIAL_COMMIT) | ||
COMMITS_SINCE_TAG=$(git rev-list --count ${LAST_TAG}..HEAD) | ||
if [ "$LAST_TAG" = "$INITIAL_COMMIT" ]; then | ||
VERSION=$BASE_VERSION | ||
else | ||
VERSION=$(echo $LAST_TAG | sed '/pyvelox-v//') | ||
fi | ||
# NEXT_VERSION=$(echo $VERSION | awk -F. -v OFS=. '{$NF++ ; print}') | ||
echo "build_version=${VERSION}a${COMMITS_SINCE_TAG}" >> $GITHUB_OUTPUT | ||
- run: mkdir -p .ccache | ||
- name: "Restore ccache" | ||
uses: actions/cache/restore@v3 | ||
id: restore-cache | ||
with: | ||
path: ".ccache" | ||
key: ccache-wheels-${{ matrix.os }}-${{ github.sha }} | ||
restore-keys: | | ||
ccache-wheels-${{ matrix.os }}- | ||
- if: matrix.os == 'macos-11' | ||
run: | | ||
echo "OPENSSL_ROOT_DIR=/usr/local/opt/[email protected]/" >> $GITHUB_ENV | ||
- name: "Create sdist" | ||
if: matrix.os == 'ubuntu-22.04' | ||
env: | ||
BUILD_VERSION: "${{ inputs.version || steps.version.outputs.build_version }}" | ||
run: | | ||
python setup.py sdist --dist-dir wheelhouse | ||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
# required for preadv/pwritev | ||
MACOSX_DEPLOYMENT_TARGET: "11.0" | ||
CIBW_ARCHS: "x86_64" | ||
# On PRs only build for Python 3.7 | ||
CIBW_BUILD: ${{ github.event_name == 'pull_request' && 'cp37-*' || 'cp3*' }} | ||
CIBW_SKIP: "*musllinux* cp36-*" | ||
CIBW_MANYLINUX_X86_64_IMAGE: "ghcr.io/facebookincubator/velox-dev:torcharrow-avx" | ||
CIBW_BEFORE_ALL_MACOS: > | ||
bash {package}/scripts/setup-macos.sh && | ||
bash {package}/scripts/setup-macos.sh install_folly | ||
CIBW_BEFORE_ALL_LINUX: > | ||
mkdir -p /output && | ||
cp -R /host${{ github.workspace }}/.ccache /output/.ccache && | ||
ccache -s | ||
CIBW_ENVIRONMENT_PASS_LINUX: CCACHE_DIR BUILD_VERSION | ||
CIBW_TEST_COMMAND: "cd {project}/pyvelox && python -m unittest -v" | ||
CIBW_TEST_SKIP: "*macos*" | ||
CCACHE_DIR: "${{ matrix.os != 'macos-11' && '/output' || github.workspace }}/.ccache" | ||
BUILD_VERSION: "${{ inputs.version || steps.version.outputs.build_version }}" | ||
with: | ||
output-dir: wheelhouse | ||
|
||
- name: "Move .ccache to workspace" | ||
if: matrix.os != 'macos-11' | ||
run: | | ||
mkdir -p .ccache | ||
cp -R ./wheelhouse/.ccache/* .ccache | ||
- name: "Save ccache" | ||
uses: actions/cache/save@v3 | ||
id: cache | ||
with: | ||
path: ".ccache" | ||
key: ccache-wheels-${{ matrix.os }}-${{ github.sha }} | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: | | ||
./wheelhouse/*.whl | ||
./wheelhouse/*.tar.gz | ||
publish_wheels: | ||
name: Publish Wheels to PyPI | ||
if: ${{ github.event_name == 'schedule' || inputs.publish }} | ||
needs: build_wheels | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse | ||
|
||
- run: ls wheelhouse | ||
|
||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Publish a Python distribution to PyPI | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
packages_dir: wheelhouse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
inculde *.txt | ||
include *.cmake | ||
graft CMake | ||
graft third_party | ||
graft velox | ||
graft pyvelox | ||
graft scripts | ||
prune velox/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,12 @@ function install_fmt { | |
cmake_install -DFMT_TEST=OFF | ||
} | ||
|
||
function install_folly { | ||
github_checkout facebook/folly "v2022.11.14.00" | ||
OPENSSL_ROOT_DIR=$(brew --prefix [email protected]) \ | ||
cmake_install -DBUILD_TESTS=OFF | ||
} | ||
|
||
function install_double_conversion { | ||
github_checkout google/double-conversion v3.1.5 | ||
cmake_install -DBUILD_TESTING=OFF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ | |
|
||
ROOT_DIR = Path(__file__).parent.resolve() | ||
|
||
with open("README.md") as f: | ||
readme = f.read() | ||
|
||
|
||
# Override build directory | ||
class BuildCommand(distutils.command.build.build): | ||
|
@@ -158,10 +161,12 @@ def build_extension(self, ext): | |
name="pyvelox", | ||
version=VERSION, | ||
description="Python bindings and extensions for Velox", | ||
long_description=readme, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/facebookincubator/velox", | ||
author="Meta", | ||
author_email="[email protected]", | ||
license="BSD", | ||
license="Apache License 2.0", | ||
install_requires=[ | ||
"cffi", | ||
"typing", | ||
|
@@ -172,7 +177,7 @@ def build_extension(self, ext): | |
classifiers=[ | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: BSD License", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: POSIX :: Linux", | ||
"Programming Language :: C++", | ||
"Programming Language :: Python :: 3.7", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters