Build Python per version

This commit is contained in:
Wilson Lin 2020-01-20 21:55:17 +11:00
parent a09103210e
commit 4a77869049
3 changed files with 26 additions and 12 deletions

View File

@ -11,6 +11,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.5, 3.6, 3.7, 3.8]
include: include:
- os: ubuntu-latest - os: ubuntu-latest
ARCH: linux-x86_64 ARCH: linux-x86_64
@ -33,7 +34,7 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v1 uses: actions/setup-python@v1
with: with:
python-version: '3.5' python-version: ${{ matrix.python }}
architecture: 'x64' architecture: 'x64'
- name: Set up Rust - name: Set up Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@ -50,7 +51,9 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2 AWS_REGION: us-west-2
run: aws s3 cp ./python/target/release/${{ matrix.LIBFILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}/hyperbuild.${{ matrix.PYEXT }} PYTHON_VERSION: ${{ matrix.python }}
# Convert dots to underscores in Python version as Python uses dots to represent import hierarchy.
run: aws s3 cp ./python/target/release/${{ matrix.LIBFILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}-${PYTHON_VERSION//./_}/hyperbuild.${{ matrix.PYEXT }}
package: package:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
@ -66,6 +69,7 @@ jobs:
python-version: '3.5' python-version: '3.5'
architecture: 'x64' architecture: 'x64'
- name: Install Python dependencies - name: Install Python dependencies
# chrislennon/action-aws-cli@v1.1 interferes with installed Python libraries.
run: | run: |
pip install --upgrade awscli pip install --upgrade awscli
pip install --upgrade wheel pip install --upgrade wheel

View File

@ -21,6 +21,7 @@ jobs:
FILE: 'libhyperbuild_ruby_lib.dylib' FILE: 'libhyperbuild_ruby_lib.dylib'
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
# Install Ruby manually as actions/setup-ruby@v1 does not compile with `--enable-shared`.
- name: Prepare for rbenv - name: Prepare for rbenv
run: | run: |
cat << 'EOF' >> "$HOME/.bash_profile" cat << 'EOF' >> "$HOME/.bash_profile"

View File

@ -1,16 +1,20 @@
import platform
import importlib import importlib
import inspect
import os
import platform
import sys
def _load_native_module(): def _load_native_module():
os_raw = platform.system() os_name_raw = platform.system()
if os_raw == "Linux": if os_name_raw == "Linux":
os = "linux" os_name = "linux"
elif os_raw == "Darwin": elif os_name_raw == "Darwin":
os = "macos" os_name = "macos"
elif os_raw == "Windows": elif os_name_raw == "Windows":
os = "windows" os_name = "windows"
else: else:
os = "unknown" os_name = "unknown"
os_arch_raw = platform.machine() os_arch_raw = platform.machine()
if os_arch_raw == "AMD64" or os_arch_raw == "x86_64": if os_arch_raw == "AMD64" or os_arch_raw == "x86_64":
@ -18,6 +22,11 @@ def _load_native_module():
else: else:
os_arch = "unknown" os_arch = "unknown"
return importlib.import_module(os + "-" + os_arch + ".hyperbuild") this_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe()))[0]))
sys.path.insert(0, this_folder)
module = importlib.import_module(''.join([os_name, "-", os_arch, '-', sys.version_info.major, '_', sys.version_info.minor, ".hyperbuild"]))
sys.path.pop(0)
return module
minify = _load_native_module().minify minify = _load_native_module().minify