-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from iago-suarez/pypi
Adding scripts to automatically publish in PyPI
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 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,77 @@ | ||
name: pytlsd build and publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [ assigned, opened, synchronize, reopened ] | ||
release: | ||
types: [ published, edited ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
linux-build: | ||
name: Wrapper Linux Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
platform: [ manylinux2014_x86_64 ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: Build the Linux wheels | ||
run: | | ||
sudo docker run --rm -e PLAT=${{ matrix.platform }} -v `pwd`:/io quay.io/pypa/${{ matrix.platform }} /io/package/build-wheels-linux.sh | ||
# cleanup for custom runner | ||
sudo chown -R $(whoami):$(whoami) . | ||
- name: Archive wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
# we strip the version number from the artifact name | ||
name: pytlsd-${{ matrix.platform }} | ||
path: wheelhouse/pytlsd-*.whl | ||
|
||
mac-build: | ||
name: Wrapper macOS Build | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ macos-11, macos-12 ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: Build the macOS wheels | ||
run: | | ||
./package/build-wheels-macos.sh | ||
- name: Archive wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pytlsd-${{ matrix.os }} | ||
path: ./wheelhouse/pytlsd-*.whl | ||
|
||
pypi-publish: | ||
name: Publish wheels to PyPI | ||
needs: [ linux-build, mac-build ] | ||
runs-on: ubuntu-latest | ||
# We publish the wheel to pypi when a new tag is pushed, | ||
# either by creating a new GitHub release or explictly with `git tag` | ||
if: ${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags') }} | ||
steps: | ||
- name: Download wheels | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ./artifacts/ | ||
- name: Move wheels | ||
run: mkdir ./wheelhouse && mv ./artifacts/**/*.whl ./wheelhouse/ | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
skip_existing: true | ||
user: __token__ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
PYTHON_VERSIONS=("cp38-cp38" "cp39-cp39" "cp310-cp310") | ||
|
||
uname -a | ||
echo "Current CentOS Version:" | ||
cat /etc/centos-release | ||
|
||
ls -ltrh /io/ | ||
|
||
CURRDIR=$(pwd) | ||
echo "Num. processes to use for building: $(nproc)" | ||
|
||
# ------ Install dependencies from the default repositories ------ | ||
cd $CURRDIR | ||
yum install -y wget git gcc gcc-c++ cmake make build-essential libopencv-dev | ||
|
||
# ------ Build pytlsd wheel ------ | ||
cd /io/ | ||
WHEEL_DIR="wheels/" | ||
for PYTHON_VERSION in ${PYTHON_VERSIONS[@]}; do | ||
PYTHON_EXEC="/opt/python/${PYTHON_VERSION}/bin/python" | ||
${PYTHON_EXEC} -m pip wheel --no-deps -w ${WHEEL_DIR} . | ||
done | ||
|
||
PYTHON_DEFAULT="/opt/python/${PYTHON_VERSIONS[-1]}/bin/python" | ||
${PYTHON_DEFAULT} -m pip install auditwheel | ||
|
||
# Bundle external shared libraries into the wheels | ||
OUT_DIR="/io/wheelhouse" | ||
mkdir -p ${OUT_DIR} | ||
for whl in ${WHEEL_DIR}/*.whl; do | ||
auditwheel repair "$whl" -w ${OUT_DIR} --plat ${PLAT} | ||
done | ||
ls -ltrh ${OUT_DIR} |
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,58 @@ | ||
#!/bin/bash | ||
set -x -e | ||
|
||
PYTHON_VERSIONS=("3.8" "3.9" "3.10") | ||
|
||
# See https://github.com/actions/setup-python/issues/577 | ||
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete | ||
# See https://github.com/actions/setup-python/issues/577#issuecomment-1500828576 | ||
rm /usr/local/bin/go || true | ||
rm /usr/local/bin/gofmt || true | ||
|
||
CURRDIR=$(pwd) | ||
NUM_LOGICAL_CPUS=$(sysctl -n hw.logicalcpu) | ||
echo "Number of logical CPUs is: ${NUM_LOGICAL_CPUS}" | ||
|
||
# Updating requires Xcode 14.0, which cannot be installed on macOS 11. | ||
brew remove swiftlint | ||
brew remove node@18 | ||
|
||
brew update | ||
brew upgrade | ||
brew install git wget cmake | ||
|
||
for PYTHON_VERSION in ${PYTHON_VERSIONS[@]}; do | ||
brew install --force "python@${PYTHON_VERSION}" | ||
python${PYTHON_VERSION} -m pip install -U pip setuptools wheel cffi | ||
done | ||
|
||
brew install llvm | ||
brew info llvm | ||
brew upgrade llvm | ||
brew info llvm | ||
|
||
# Install `delocate` -- OSX equivalent of `auditwheel` | ||
# see https://pypi.org/project/delocate/ for more details | ||
|
||
cd $CURRDIR | ||
# flags must be passed, to avoid the issue: `Unsupported compiler -- pybind11 requires C++11 support!` | ||
# see https://github.com/quantumlib/qsim/issues/242 for more details | ||
WHEEL_DIR="${CURRDIR}/wheelhouse_unrepaired/" | ||
for PYTHON_VERSION in ${PYTHON_VERSIONS[@]}; do | ||
CC=/usr/local/opt/llvm/bin/clang \ | ||
CXX=/usr/local/opt/llvm/bin/clang++ \ | ||
LDFLAGS=-L/usr/local/opt/libomp/lib \ | ||
python${PYTHON_VERSION} -m pip wheel --no-deps -w ${WHEEL_DIR} . | ||
done | ||
|
||
python${PYTHON_VERSIONS[0]} -m pip install -U delocate | ||
|
||
# Bundle external shared libraries into the wheels | ||
OUT_DIR="${CURRDIR}/wheelhouse" | ||
mkdir -p ${OUT_DIR} | ||
for whl in ${WHEEL_DIR}/*.whl; do | ||
delocate-listdeps --all "$whl" | ||
delocate-wheel -w "${OUT_DIR}" -v "$whl" | ||
rm $whl | ||
done | ||
ls -ltrh ${OUT_DIR} |