-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from laggykiller/universal2_wheel
Universal2 wheel
- Loading branch information
Showing
4 changed files
with
181 additions
and
94 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 |
---|---|---|
|
@@ -2,8 +2,8 @@ name: Build and upload to PyPI | |
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
# tags: | ||
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
# release: | ||
# types: | ||
# - [published] | ||
|
@@ -16,24 +16,24 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
include: | ||
- os: windows-2019 | ||
arch: x64 | ||
submodules_mode: true | ||
cibw_archs_windows: AMD64 | ||
cibw_environment: APNGASM_COMPILE_TARGET=x64 | ||
cibw_before_all: prepare-win.bat | ||
- os: windows-2019 | ||
arch: x86 | ||
submodules_mode: true | ||
cibw_archs_windows: x86 | ||
cibw_environment: APNGASM_COMPILE_TARGET=x86 | ||
cibw_before_all: prepare-win.bat | ||
- os: windows-2019 | ||
arch: arm64 | ||
submodules_mode: true | ||
cibw_archs_windows: ARM64 | ||
cibw_environment: APNGASM_COMPILE_TARGET=ARM64 | ||
cibw_before_all: prepare-win.bat | ||
# - os: windows-2019 | ||
# arch: x64 | ||
# submodules_mode: true | ||
# cibw_archs_windows: AMD64 | ||
# cibw_environment: APNGASM_COMPILE_TARGET=x64 | ||
# cibw_before_all: prepare-win.bat | ||
# - os: windows-2019 | ||
# arch: x86 | ||
# submodules_mode: true | ||
# cibw_archs_windows: x86 | ||
# cibw_environment: APNGASM_COMPILE_TARGET=x86 | ||
# cibw_before_all: prepare-win.bat | ||
# - os: windows-2019 | ||
# arch: arm64 | ||
# submodules_mode: true | ||
# cibw_archs_windows: ARM64 | ||
# cibw_environment: APNGASM_COMPILE_TARGET=ARM64 | ||
# cibw_before_all: prepare-win.bat | ||
- os: macos-11 | ||
arch: x64 | ||
submodules_mode: true | ||
|
@@ -60,58 +60,70 @@ jobs: | |
VCPKG_C_FLAGS="-mmacosx-version-min=11.0" | ||
VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0" | ||
cibw_before_all: ./prepare-mac.sh | ||
- os: ubuntu-20.04 | ||
arch: x64 | ||
submodules_mode: true | ||
cibw_archs_linux: x86_64 | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: x86 | ||
submodules_mode: true | ||
cibw_archs_linux: i686 | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: arm64 | ||
submodules_mode: true | ||
cibw_archs_linux: aarch64 | ||
cibw_skip: "*-muslinux_* pp*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: arm64 | ||
submodules_mode: true | ||
cibw_archs_linux: aarch64 | ||
cibw_skip: "*-multilinux_* pp*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: arm64 | ||
submodules_mode: true | ||
cibw_archs_linux: aarch64 | ||
cibw_skip: "*-muslinux_* *-multilinux_*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: ppc64le | ||
submodules_mode: true | ||
cibw_archs_linux: ppc64le | ||
cibw_skip: "*-muslinux_*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: ppc64le | ||
submodules_mode: true | ||
cibw_archs_linux: ppc64le | ||
cibw_skip: "*-multilinux_*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: s390x | ||
submodules_mode: true | ||
cibw_archs_linux: s390x | ||
cibw_skip: "*-muslinux_*" | ||
cibw_before_all: ./prepare-linux.sh | ||
- os: ubuntu-20.04 | ||
arch: s390x | ||
- os: macos-11 | ||
arch: universal2 | ||
submodules_mode: true | ||
cibw_archs_linux: s390x | ||
cibw_skip: "*-multilinux_*" | ||
cibw_before_all: ./prepare-linux.sh | ||
cibw_archs_macos: universal2 | ||
cibw_environment: > | ||
APNGASM_COMPILE_TARGET=universal2 | ||
_PYTHON_HOST_PLATFORM=macosx-11.0-universal2 | ||
VCPKG_OSX_DEPLOYMENT_TARGET=11.0 | ||
MACOSX_DEPLOYMENT_TARGET=11.0 | ||
CMAKE_OSX_DEPLOYMENT_TARGET=11.0 | ||
VCPKG_C_FLAGS="-mmacosx-version-min=11.0" | ||
VCPKG_CXX_FLAGS="-mmacosx-version-min=11.0" | ||
# - os: ubuntu-20.04 | ||
# arch: x64 | ||
# submodules_mode: true | ||
# cibw_archs_linux: x86_64 | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: x86 | ||
# submodules_mode: true | ||
# cibw_archs_linux: i686 | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: arm64 | ||
# submodules_mode: true | ||
# cibw_archs_linux: aarch64 | ||
# cibw_skip: "*-muslinux_* pp*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: arm64 | ||
# submodules_mode: true | ||
# cibw_archs_linux: aarch64 | ||
# cibw_skip: "*-multilinux_* pp*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: arm64 | ||
# submodules_mode: true | ||
# cibw_archs_linux: aarch64 | ||
# cibw_skip: "*-muslinux_* *-multilinux_*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: ppc64le | ||
# submodules_mode: true | ||
# cibw_archs_linux: ppc64le | ||
# cibw_skip: "*-muslinux_*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: ppc64le | ||
# submodules_mode: true | ||
# cibw_archs_linux: ppc64le | ||
# cibw_skip: "*-multilinux_*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: s390x | ||
# submodules_mode: true | ||
# cibw_archs_linux: s390x | ||
# cibw_skip: "*-muslinux_*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
# - os: ubuntu-20.04 | ||
# arch: s390x | ||
# submodules_mode: true | ||
# cibw_archs_linux: s390x | ||
# cibw_skip: "*-multilinux_*" | ||
# cibw_before_all: ./prepare-linux.sh | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -171,18 +183,18 @@ jobs: | |
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
# repository_url: https://test.pypi.org/legacy/ | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
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 | ||
# upload_pypi: | ||
# needs: [build_wheels, build_sdist] | ||
# runs-on: ubuntu-latest | ||
# 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/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
# - uses: pypa/[email protected] | ||
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.PYPI_API_TOKEN }} |
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,61 @@ | ||
# Copyright (C) Falko Axmann. All rights reserved. | ||
# Licensed under the GPL v3 license. | ||
# | ||
# This script merges two directories containing static libraries for | ||
# two different architectures into one directory with universal binaries. | ||
# Files that don't end in ".a" will just be copied over from the first directory. | ||
# | ||
# Run it like this: | ||
# `python3 lipo-dir-merge.py <arm64-dir-tree> <x64-dir-tree> <universal-output-dir>` | ||
|
||
import sys | ||
import shutil | ||
import os | ||
import subprocess | ||
|
||
# | ||
# Make sure we got enough arguments on the command line | ||
# | ||
if len(sys.argv) < 4: | ||
print("Not enough args") | ||
print(f"{sys.argv[0]} <primary directory> <other architecture source> <destination>") | ||
sys.exit(-1) | ||
|
||
# This is where we take most of the files from | ||
primary_path = sys.argv[1] | ||
# This is the directory tree from which we take libraries of the alternative arch | ||
secondary_path = sys.argv[2] | ||
# This is where we copy stuff to | ||
destination_path = sys.argv[3] | ||
|
||
|
||
# Merge the libraries at `src1` and `src2` and create a | ||
# universal binary at `dst` | ||
def merge_libs(src1, src2, dst): | ||
subprocess.run(["lipo", "-create", src1, src2, "-output", dst]) | ||
|
||
# Find the library at `src` in the `secondary_path` and then | ||
# merge the two versions, creating a universal binary at `dst`. | ||
def find_and_merge_libs(src, dst): | ||
rel_path = os.path.relpath(src, primary_path) | ||
lib_in_secondary = os.path.join(secondary_path, rel_path) | ||
|
||
if os.path.exists(lib_in_secondary) == False: | ||
print("Lib not found in secondary source: {lib_in_secondary}") | ||
return | ||
|
||
merge_libs(src, lib_in_secondary, dst) | ||
|
||
# Either copy the file at `src` to `dst`, or, if it is a static | ||
# library, merge it with its version from `secondary_path` and | ||
# write the universal binary to `dst`. | ||
def copy_file_or_merge_libs(src, dst, *, follow_symlinks=True): | ||
_, file_ext = os.path.splitext(src) | ||
if file_ext == ".a": | ||
find_and_merge_libs(src, dst) | ||
else: | ||
shutil.copy2(src, dst, follow_symlinks=follow_symlinks) | ||
|
||
# Use copytree to do most of the work, with our own `copy_function` doing a little bit | ||
# of magic in case of static libraries. | ||
shutil.copytree(primary_path, destination_path, copy_function=copy_file_or_merge_libs) |
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