Skip to content

[Python] Start syncing also cppyy-backend with upstream cppyy #19144

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions bindings/pyroot/cppyy/cppyy-backend/.circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 2.1

parameters:
build_aarch64_wheel:
description: "Whether to build aarch64 wheel on CircleCI"
default: false
type: boolean


jobs:
linux-aarch64-wheels:
working_directory: ~/linux-aarch64-wheels
machine:
image: ubuntu-2004:2022.04.1
# resource_class is what tells CircleCI to use an ARM worker for native arm builds
# https://circleci.com/product/features/resource-classes/
resource_class: arm.large
environment:
STDCXX: 20
MAKE_NPROCS: 4
steps:
- checkout
- run:
name: Build the Linux aarch64 wheels.
command: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install pip --upgrade
python3 -m pip install cibuildwheel==2.12.0
python3 -m cibuildwheel cling --print-build-identifiers
python3 -m cibuildwheel cling --output-dir wheelhouse
- store_artifacts:
path: wheelhouse/


workflows:
version: 2
build-aarch64-wheels:
when: << pipeline.parameters.build_aarch64_wheel >>
jobs:
- linux-aarch64-wheels

Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Build and upload to PyPI

on: [workflow_dispatch]

jobs:
#build-aarch64-wheels:
# runs-on: ubuntu-latest
# outputs:
# job_number: ${{ steps.aarch64-job-number.outputs.job_number }}
# steps:
# - uses: actions/checkout@v3
#
# - name: Setup python
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - name: Trigger circleci build for ARM
# id: aarch64-job-number
# run: |
# export JOB_NUMBER=$(python3 circleci.py job --token ${{ secrets.CIRCLE_API_TOKEN }})
# echo "job_number=$JOB_NUMBER" >> "$GITHUB_OUTPUT"

build_wheels:
name: Build wheels on ${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}

env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: "${{ matrix.cibw.arch || 'auto' }}"
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}

strategy:
fail-fast: false
matrix:
include:
#- os: macos-14
# name: mac-cpython
# python: 310
# platform_id: macosx_x86_64

# cross-compilation platform, disabled because tools build
# during the build process won't run
#- os: macos-latest
# name: mac-cpython-arm
# python: 310
# platform_id: macosx_arm64
# cibw:
# arch: arm64

- os: ubuntu-latest
name: manylinux2014-x86_64
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

#- os: ubuntu-latest
# name: manylinux2014-i686
# python: 310
# platform_id: manylinux_i686
# manylinux_image: manylinux2014

- os: windows-latest
name: win32
python: 310
platform_id: win32

- os: windows-latest
name: win_amd64
python: 310
platform_id: win_amd64

# cross-compilation platform (requires cross-compilation setup
# for cmake configuration), disabled because tools build during
# the build process won't run
#- os: windows-latest
# name: win32-arm64
# python: 310
# platform_id: win_arm64
# cibw:
# arch: ARM64

steps:
- uses: actions/checkout@v3

- name: setup python
uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: ${{ matrix.architecture }}

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

#- name: customize mac-arm-64
# if: contains(matrix.os, 'macos') && matrix.platform_id == 'macosx_arm64'
# run: |
# echo 'MACOSX_DEPLOYMENT_TARGET=10.15' >> "$GITHUB_ENV"

- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==2.12.0

- name: list target wheels
run: |
python -m cibuildwheel cling --print-build-identifiers

- name: Build wheels
timeout-minutes: 600
run: |
python -m cibuildwheel cling --output-dir wheelhouse

- uses: actions/upload-artifact@v4
with:
# add unique name as artifact@v4 workaround, after cibuildwheel
name: cppyy-cling-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

#build_sdist:
# name: Build source distribution
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
#
# - name: Build sdist
# run: cd cling && pipx run build --sdist
#
# - uses: actions/upload-artifact@v3
# with:
# path: ./cling/dist/*.tar.gz

#upload_aarch64_wheel:
# needs: [build_wheels, build-aarch64-wheels] # Just wait until this workflow is done - then aarch64 should be done
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Setup python
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"
#
# - name: Get wheel from CircleCI artifact
# env:
# JOB_NUMBER: ${{ needs.build-aarch64-wheels.outputs.job_number }}
# run: |
# export WHEEL_PATH=$(python circleci.py artifact --job-number $JOB_NUMBER --token ${{ secrets.CIRCLE_API_TOKEN }})
# echo "wheel_path=$WHEEL_PATH" >> "$GITHUB_ENV"
#
# - uses: actions/upload-artifact@v3
# with:
# path: ${{ env.wheel_path }}
3 changes: 1 addition & 2 deletions bindings/pyroot/cppyy/cppyy-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
releases/
root-*/
cling/src/
cling/src/interpreter
builddir/

# Byte-compiled / optimized / DLL files
Expand All @@ -14,7 +14,6 @@ __pycache__/
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
Expand Down
139 changes: 139 additions & 0 deletions bindings/pyroot/cppyy/cppyy-backend/circleci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import http.client
from typing import Sequence
import argparse
import os
import urllib.request
from pathlib import Path
import time
import json

import sys

Check failure on line 10 in bindings/pyroot/cppyy/cppyy-backend/circleci.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy-backend/circleci.py:10:8: F401 `sys` imported but unused

Check failure on line 10 in bindings/pyroot/cppyy/cppyy-backend/circleci.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/cppyy/cppyy-backend/circleci.py:1:1: I001 Import block is un-sorted or un-formatted


def get_artifact(
token: str,
vcs: str = "github",
org: str = "wlav",
project: str = "cppyy-backend",
job_number: int = 0,
**kwargs,
) -> int:

conn = http.client.HTTPSConnection("circleci.com")

headers = {"Circle-Token": token}

conn.request(
"GET",
f"/api/v2/project/{vcs}/{org}/{project}/{job_number}/artifacts",
headers=headers,
)

res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
url = data["items"][0]["url"]
path = Path(data["items"][0]["path"])
path.parent.mkdir(exist_ok=True)

urllib.request.urlretrieve(url, path)
time.sleep(1.0)
print(path)
return 0


def start_job(
token: str,
vcs: str = "github",
org: str = "wlav",
project: str = "cppyy-backend",
build_aarch64_wheel: bool = True,
branch: str = "master",
**kwargs,
) -> int:
import http.client

conn = http.client.HTTPSConnection("circleci.com")

headers = {
"content-type": "application/json",
"Circle-Token": f"{token}",
}

# Start pipeline
payload = {
"branch": branch,
"parameters": {"build_aarch64_wheel": build_aarch64_wheel},
}
conn.request(
"POST",
f"/api/v2/project/{vcs}/{org}/{project}/pipeline",
json.dumps(payload),
headers,
)
res = conn.getresponse()
pipeline_data = json.loads(res.read().decode("utf-8"))
time.sleep(1.0)

# Get pipeline id
conn.request(
"GET",
f"/api/v2/project/{vcs}/{org}/{project}/pipeline/{pipeline_data['number']}",
headers=headers,
)
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))

time.sleep(1.0)

# Get workflow id
conn.request(
"GET",
f"/api/v2/pipeline/{data['id']}/workflow",
headers=headers,
)

res = conn.getresponse()
workflow_data = json.loads(res.read().decode("utf-8"))

time.sleep(1.0)

# Get job id
conn.request(
"GET",
f"/api/v2/workflow/{workflow_data['items'][0]['id']}/job",
headers=headers,
)

res = conn.getresponse()
job_data = json.loads(res.read().decode("utf-8"))

Check failure on line 108 in bindings/pyroot/cppyy/cppyy-backend/circleci.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/cppyy/cppyy-backend/circleci.py:108:5: F841 Local variable `job_data` is assigned to but never used

return 0


def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()

parser.add_argument("--token", default=os.environ.get("CIRCLE_API_TOKEN"))
parser.add_argument("mode", choices=["artifact", "job"])
parser.add_argument("--vcs", default="github")
parser.add_argument("--org", default="wlav")
parser.add_argument("--project", default="cppyy-backend")
parser.add_argument("--job-number", default=0)
parser.add_argument("--build-aarch64-wheel", default=True)

kwargs = vars(parser.parse_args(argv))
mode = kwargs.pop("mode")

if mode == "artifact":
return get_artifact(**kwargs)

if mode == "job":
return start_job(**kwargs)

print("Invaild arguments")
print(f"You entered: {kwargs}")
return 1


if __name__ == "__main__":
raise SystemExit(main())
Loading
Loading