Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: ARM64 Support for OSX / Linux + Windows 32 bit support #342

Merged
merged 5 commits into from May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions .cirrus.yml
@@ -0,0 +1,55 @@
BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
arch_check_script:
- uname -am
test_script:
- python --version
- python -m pip install --upgrade pip
- python -m pip install -r requirements_dev.txt
- python -m flake8
- python -m pydocstyle pact
- python -m tox -e test
# - make examples

linux_arm64_task:
env:
matrix:
# - IMAGE: python:3.6-slim # This works locally, with cirrus run, but fails in CI
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- IMAGE: python:3.7-slim
- IMAGE: python:3.8-slim
- IMAGE: python:3.9-slim
- IMAGE: python:3.10-slim
arm_container:
image: $IMAGE
install_script:
- apt update --yes && apt install --yes gcc make
<< : *BUILD_TEST_TASK_TEMPLATE


macosx_arm64_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
PATH: ${HOME}/.pyenv/shims:${PATH}
matrix:
- PYTHON: 3.6
- PYTHON: 3.7
- PYTHON: 3.8
- PYTHON: 3.9
- PYTHON: 3.10
install_script:
# Per the pyenv homebrew recommendations.
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment
# - xcode-select --install # Unnecessary on Cirrus
- brew update
# - brew install openssl readline sqlite3 xz zlib
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preinstalled in cirrus's base image

- brew install pyenv
- pyenv install ${PYTHON}
- pyenv global ${PYTHON}
- pyenv rehash
## To install rosetta
# - softwareupdate --install-rosetta --agree-to-license
Copy link
Member Author

@YOU54F YOU54F Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rosetta isn't installed by default, so this is using arm64 binaries, and would fail if using x86_64 binaries without rosetta

<< : *BUILD_TEST_TASK_TEMPLATE




5 changes: 3 additions & 2 deletions .github/workflows/build_and_test.yml
Expand Up @@ -19,7 +19,7 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adds additional os's but skips the examples steps, as they require a broker and spin one up with docker-compose.

docker isn't available in GH runners for macOS or Windows, hence skipped on line 53 unless Linux


# These versions are no longer supported by Python team, and may
# eventually be dropped from GitHub Actions.
Expand All @@ -29,7 +29,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix deprecation warnings in build


- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -50,4 +50,5 @@ jobs:
run: tox -e test

- name: Test examples
if: runner.os == 'Linux'
run: make examples
4 changes: 2 additions & 2 deletions .github/workflows/package_and_push_to_pypi.yml
Expand Up @@ -9,9 +9,9 @@ jobs:
environment: "Upload Python Package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matches .github/workflows/build_and_test.yml

with:
python-version: '3.x'
- name: Install dependencies
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
@@ -0,0 +1,17 @@
ARG PYTHON_VERSION=3.6
FROM python:$PYTHON_VERSION-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update --yes && apt install --yes gcc make

WORKDIR /app
COPY . /app

RUN python -m pip install --upgrade pip
RUN python -m pip install -r requirements_dev.txt
RUN python -m flake8
RUN python -m pydocstyle pact
RUN python -m tox -e test

CMD ["sh","-c","python -m tox -e test"]
30 changes: 30 additions & 0 deletions Dockerfile.ubuntu
@@ -0,0 +1,30 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION 3.9

#Set of all dependencies needed for pyenv to work on Ubuntu
RUN apt-get update \
&& apt-get install -y --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8 git

# Set-up necessary Env vars for PyEnv
ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

# Install pyenv
RUN set -ex \
&& curl https://pyenv.run | bash \
&& pyenv update \
&& pyenv install $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION \
&& pyenv rehash

WORKDIR /app
COPY . /app

RUN python -m pip install --upgrade pip
RUN python -m pip install -r requirements_dev.txt
RUN python -m flake8
RUN python -m pydocstyle pact
RUN python -m tox -e test

CMD ["sh","-c","python -m tox -e test"]
9 changes: 5 additions & 4 deletions MANIFEST
Expand Up @@ -21,9 +21,10 @@ pact/pact.py
pact/provider.py
pact/verifier.py
pact/verify_wrapper.py
pact/bin/pact-1.88.83-linux-x86.tar.gz
pact/bin/pact-1.88.83-linux-x86_64.tar.gz
pact/bin/pact-1.88.83-osx.tar.gz
pact/bin/pact-1.88.83-win32.zip
pact/bin/pact-3.1.2.2-alpha-linux-arm64.tar.gz
pact/bin/pact-3.1.2.2-alpha-linux-x86_64.tar.gz
pact/bin/pact-3.1.2.2-alpha-osx-arm64.tar.gz
pact/bin/pact-3.1.2.2-alpha-osx-x86_64.tar.gz
pact/bin/pact-3.1.2.2-alpha-windows-x86_64.zip
pact/cli/__init__.py
pact/cli/verify.py
9 changes: 9 additions & 0 deletions run-docker.sh
@@ -0,0 +1,9 @@
#!/bin/bash

for arch in arm64 amd64; do
# for version in 3.6; do
for version in 3.7 3.8 3.9 3.10 3.11; do
docker build -t python-$arch-$version --build-arg PYTHON_VERSION=$version --platform=linux/$arch .
docker run -it --rm python-$arch-$version
done
done
30 changes: 18 additions & 12 deletions setup.py
Expand Up @@ -15,11 +15,14 @@


IS_64 = sys.maxsize > 2 ** 32
PACT_STANDALONE_VERSION = '1.88.83'
PACT_STANDALONE_SUFFIXES = ['osx.tar.gz',
PACT_STANDALONE_VERSION = '3.1.2.2-alpha'
PACT_STANDALONE_SUFFIXES = ['osx-x86_64.tar.gz',
'osx-arm64.tar.gz',
'linux-x86_64.tar.gz',
'linux-x86.tar.gz',
'win32.zip']
'linux-arm64.tar.gz',
'windows-x86_64.zip',
'windows-x86.zip',
]

here = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -131,15 +134,18 @@ def ruby_app_binary():
target_platform = platform.platform().lower()

binary = ('pact-{version}-{suffix}')

if 'darwin' in target_platform or 'macos' in target_platform:
suffix = 'osx.tar.gz'
elif 'linux' in target_platform and IS_64:
suffix = 'linux-x86_64.tar.gz'
if ("darwin" in target_platform or "macos" in target_platform) and ("aarch64" in platform.machine() or "arm64" in platform.machine()):
suffix = 'osx-arm64.tar.gz'
elif ("darwin" in target_platform or "macos" in target_platform) and IS_64:
suffix = 'osx-x86_64.tar.gz'
elif 'linux' in target_platform and IS_64 and "aarch64" in platform.machine():
suffix = 'linux-arm64.tar.gz'
elif 'linux' in target_platform:
suffix = 'linux-x86.tar.gz'
suffix = 'linux-x86_64.tar.gz'
elif 'windows' in target_platform and IS_64:
suffix = 'windows-x86_64.zip'
elif 'windows' in target_platform:
suffix = 'win32.zip'
suffix = 'windows-x86.zip'
else:
msg = ('Unfortunately, {} is not a supported platform. Only Linux,'
' Windows, and OSX are currently supported.').format(
Expand All @@ -157,7 +163,7 @@ def download_ruby_app_binary(path_to_download_to, filename, suffix):
:param filename: The filename that should be installed.
:param suffix: The suffix of the standalone app to install.
"""
uri = ('https://github.com/pact-foundation/pact-ruby-standalone/releases'
uri = ('https://github.com/you54f/pact-ruby-standalone/releases'
'/download/v{version}/pact-{version}-{suffix}')

if sys.version_info.major == 2:
Expand Down