Skip to content

Commit db62b0f

Browse files
authored
Modify GitHub Actions
Adds manual action to publish wheels to CodeArtifact and also fixes the test and build actions.
2 parents fb00b28 + 6e0645d commit db62b0f

File tree

7 files changed

+53
-251
lines changed

7 files changed

+53
-251
lines changed

.github/workflows/cifuzz.yml

-26
This file was deleted.

.github/workflows/cmake.yml

-77
This file was deleted.

.github/workflows/cross_build.yml

-41
This file was deleted.

.github/workflows/wheel.yml

+42-98
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
1-
name: Build Wheels
1+
name: Build and Publish Wheels
22

33
on:
4-
push:
5-
branches: [ master ]
6-
tags:
7-
- 'v*'
8-
pull_request:
9-
branches: [ master ]
4+
workflow_dispatch:
5+
6+
env:
7+
DOMAIN: poolside
8+
REPOSITORY: poolside-dagster
9+
WHEEL_DST: /tmp/sp_wheelhouse
1010

1111
jobs:
1212
build_wheels:
13-
outputs:
14-
digests-linux: ${{ steps.hash-linux.outputs.digests }}
15-
digests-macos: ${{ steps.hash-macos.outputs.digests }}
16-
digests-windows: ${{ steps.hash-windows.outputs.digests }}
1713
strategy:
1814
matrix:
19-
os: [ubuntu-latest, windows-latest, macOS-11]
15+
os: [ubuntu-latest, macOS-latest]
2016
runs-on: ${{ matrix.os }}
2117
name: Build wheels on ${{ matrix.os }}
2218

19+
permissions:
20+
id-token: write # This is required for requesting the JWT
21+
contents: read # This is required for actions/checkout
22+
2323
steps:
24-
- uses: actions/checkout@v3
25-
- uses: actions/setup-python@v4
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
2626
with:
27-
python-version: "3.x"
27+
python-version: "3.12"
2828

2929
- name: Set up QEMU
3030
if: runner.os == 'Linux'
31-
uses: docker/setup-qemu-action@v2
31+
uses: docker/setup-qemu-action@v3
3232
with:
3333
platforms: arm64
3434

35-
- name: Build for Windows
36-
if: runner.os == 'Windows'
35+
- name: Configure AWS Credentials
36+
uses: aws-actions/configure-aws-credentials@v4
37+
with:
38+
role-to-assume: arn:aws:iam::939990436136:role/gh-action-publish-artifacts-role
39+
aws-region: us-east-1
40+
41+
- name: Make sure destination dir exists
3742
run: |
38-
cmake -A Win32 -B ${{github.workspace}}/build_win32 -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/root_win32
39-
cmake --build ${{github.workspace}}/build_win32 --config Release --target install --parallel 8
40-
cmake -A x64 -B ${{github.workspace}}/build_amd64 -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/root_amd64
41-
cmake --build ${{github.workspace}}/build_amd64 --config Release --target install --parallel 8
43+
mkdir -p ${{env.WHEEL_DST}}
44+
if [ ! -d ${{env.WHEEL_DST}} ]; then
45+
echo "wheel dest dir does not exist!"
46+
exit 1
47+
fi
4248
4349
- name: Build for Mac
4450
if: runner.os == 'macOS'
@@ -47,101 +53,39 @@ jobs:
4753
cmake --build ${{github.workspace}}/build --config Release --target install --parallel 8
4854
env:
4955
CMAKE_OSX_ARCHITECTURES: arm64;x86_64
56+
MACOSX_DEPLOYMENT_TARGET: 10.13
5057

51-
- name: Install cibuildwheel
58+
- name: Install dependencies
5259
working-directory: ${{github.workspace}}/python
5360
run: |
5461
python -m pip install --upgrade pip
55-
pip install setuptools wheel twine
56-
python -m pip install cibuildwheel==2.12.0
62+
pip install setuptools wheel twine build cibuildwheel
5763
5864
- name: Build wheels
5965
working-directory: ${{github.workspace}}/python
60-
run: python -m cibuildwheel --output-dir wheelhouse
66+
run: python -m cibuildwheel --output-dir ${{env.WHEEL_DST}}
6167
env:
68+
CIBW_BUILD: "cp311-* cp312-*"
6269
CIBW_ARCHS_LINUX: auto aarch64
6370
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
64-
CIBW_SKIP: "pp* *-musllinux_*"
71+
CIBW_ARCHS_WINDOWS: auto ARM64
72+
CIBW_SKIP: "pp* *-musllinux_* *i686*"
6573
CIBW_BUILD_VERBOSITY: 1
6674

6775
- name: Build sdist archive
6876
working-directory: ${{github.workspace}}/python
6977
run: sh build_sdist.sh
7078

7179
- name: Fetch sdist archive
72-
uses: tj-actions/glob@v17
80+
uses: tj-actions/glob@2944188f585a0ec102a6a82d9eeb3aed69785393 # v22.0.1
7381
id: sdist
7482
with:
7583
files: ./python/dist/*.tar.gz
76-
84+
7785
- name: Build wheel from sdist
78-
run: python -m pip wheel "${{ steps.sdist.outputs.paths }}" --verbose
79-
80-
- name: Copy sdist
81-
working-directory: ${{github.workspace}}/python
82-
if: runner.os == 'macOS'
83-
run: cp -f dist/*.tar.gz wheelhouse/
84-
85-
- name: Upload artifact
86-
uses: actions/upload-artifact@v3
87-
with:
88-
path: |
89-
./python/wheelhouse/*.whl
90-
./python/wheelhouse/*.tar.gz
91-
92-
- name: Upload wheel release
93-
if: startsWith(github.ref, 'refs/tags/')
94-
uses: svenstaro/upload-release-action@v2
95-
with:
96-
repo_token: ${{ secrets.GITHUB_TOKEN }}
97-
file: ./python/wheelhouse/*
98-
tag: ${{ github.ref }}
99-
overwrite: true
100-
prerelease: true
101-
file_glob: true
102-
103-
- name: Generate SLSA subjects - Macos
104-
id: hash-macos
105-
if: runner.os == 'macOS'
106-
run: echo "digests=$(shasum -a 256 ./python/wheelhouse/* | base64)" >> $GITHUB_OUTPUT
107-
108-
- name: Generate SLSA subjects - Linux
109-
id: hash-linux
110-
if: runner.os == 'Linux'
111-
run: echo "digests=$(sha256sum ./python/wheelhouse/* | base64 -w0)" >> $GITHUB_OUTPUT
112-
113-
- name: Generate SLSA subjects - Windows
114-
id: hash-windows
115-
if: runner.os == 'Windows'
116-
run: echo "digests=$(sha256sum ./python/wheelhouse/* | base64 -w0)" >> $GITHUB_OUTPUT
117-
118-
gather-disgests:
119-
needs: [build_wheels]
120-
outputs:
121-
digests: ${{ steps.hash.outputs.digests }}
122-
runs-on: ubuntu-latest
123-
steps:
124-
- name: Merge results
125-
id: hash
126-
env:
127-
LINUX_DIGESTS: "${{ needs.build_wheels.outputs.digests-linux }}"
128-
MACOS_DIGESTS: "${{ needs.build_wheels.outputs.digests-macos }}"
129-
WINDOWS_DIGESTS: "${{ needs.build_wheels.outputs.digests-windows }}"
86+
run: python -m pip wheel "${{ steps.sdist.outputs.paths }}" --wheel-dir ${{env.WHEEL_DST}} --verbose
87+
88+
- name: Publish
13089
run: |
131-
set -euo pipefail
132-
echo "$LINUX_DIGESTS" | base64 -d > checksums.txt
133-
echo "$MACOS_DIGESTS" | base64 -d >> checksums.txt
134-
echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt
135-
echo "digests=$(cat checksums.txt | base64 -w0)" >> $GITHUB_OUTPUT
136-
137-
provenance:
138-
if: startsWith(github.ref, 'refs/tags/')
139-
needs: [build_wheels, gather-disgests]
140-
permissions:
141-
actions: read # To read the workflow path.
142-
id-token: write # To sign the provenance.
143-
contents: write # To add assets to a release.
144-
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
145-
with:
146-
base64-subjects: "${{ needs.gather-disgests.outputs.digests }}"
147-
upload-assets: true # Optional: Upload to a new release
90+
aws codeartifact login --tool twine --domain ${{env.DOMAIN}} --repository ${{ env.REPOSITORY }}
91+
twine upload --verbose --repository codeartifact ${{env.WHEEL_DST}}/*

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ if (APPLE)
9494
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
9595
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
9696
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
97+
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0)
9798
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
9899
if ("${isSystemDir}" STREQUAL "-1")
99100
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

python/build_bundled.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ elif [ -f ../src/CMakeLists.txt ]; then
1313
SRC_DIR=..
1414
else
1515
# Try taged version. Othewise, use head.
16-
git clone https://github.com/google/sentencepiece.git -b v"${VERSION}" --depth 1 || \
17-
git clone https://github.com/google/sentencepiece.git --depth 1
16+
git clone https://github.com/poolsideai/sentencepiece.git -b v"${VERSION}" --depth 1 || \
17+
git clone https://github.com/poolsideai/sentencepiece.git --depth 1
1818
SRC_DIR=./sentencepiece
1919
fi
2020

21-
cmake ${SRC_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSPM_ENABLE_SHARED=OFF -DSPM_ENABLE_TCMALLOC=OFF -DSPM_ONLY_LIB=on -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
22-
cmake --build ${BUILD_DIR} --config RelWithDebInfo --target install --parallel $(nproc)
21+
cmake ${SRC_DIR} -B ${BUILD_DIR} -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
22+
cmake --build ${BUILD_DIR} --config Release --target install --parallel $(nproc)

python/setup.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import subprocess
2323
import sys
2424
import os
25+
import platform
2526

2627
sys.path.append(os.path.join('.', 'test'))
2728

@@ -92,9 +93,10 @@ def build_extension(self, ext):
9293
if sys.platform == 'darwin':
9394
cflags.append('-mmacosx-version-min=10.9')
9495
else:
95-
pass
96-
# cflags.append('-Wl,-strip-all')
97-
# libs.append('-Wl,-strip-all')
96+
cflags.append('-Wl,-strip-all')
97+
libs.append('-Wl,-strip-all')
98+
if sys.platform == 'linux':
99+
libs.append('-Wl,-Bsymbolic')
98100
print('## cflags={}'.format(' '.join(cflags)))
99101
print('## libs={}'.format(' '.join(libs)))
100102
ext.extra_compile_args = cflags
@@ -197,6 +199,5 @@ def build_extension(self, ext):
197199
'Programming Language :: Python',
198200
'Topic :: Text Processing :: Linguistic',
199201
'Topic :: Software Development :: Libraries :: Python Modules',
200-
],
201-
test_suite='sentencepiece_test.suite',
202+
]
202203
)

0 commit comments

Comments
 (0)