From 2112299e6bbf02e18f30a75c6d185fc77ae4f1d1 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 16 Jan 2025 14:23:12 +0100 Subject: [PATCH 1/4] publish python 3.13 pypi packages --- .github/adjust_version.py | 86 +++++++++++++++++++----------- .github/workflows/cibuildwheel.yml | 48 ++++------------- 2 files changed, 66 insertions(+), 68 deletions(-) diff --git a/.github/adjust_version.py b/.github/adjust_version.py index ac723b7ee..972720943 100644 --- a/.github/adjust_version.py +++ b/.github/adjust_version.py @@ -1,6 +1,6 @@ -''' +""" Script to build binary wheels in manylinux 2014 docker container. -''' +""" import argparse from re import finditer, escape, match, sub, search @@ -9,29 +9,29 @@ def adjust_version(url): - ''' + """ Adjust version in setup.py. - ''' - if exists('setup.cfg'): - setup_type = 'cfg' - setup_path = 'setup.cfg' + """ + if exists("setup.cfg"): + setup_type = "cfg" + setup_path = "setup.cfg" else: - setup_type = 'py' - setup_path = 'setup.py' + setup_type = "py" + setup_path = "setup.py" with open(setup_path) as fr: setup = fr.read() - if setup_type == 'cfg': - package_name = search(r'name[ ]*=[ ]*(.*)[ ]*', setup).group(1) - package_regex = package_name.replace('-', '[-_]') + if setup_type == "cfg": + package_name = search(r"name[ ]*=[ ]*(.*)[ ]*", setup).group(1) + package_regex = package_name.replace("-", "[-_]") else: - package_name = search(r'''name[ ]*=[ ]*['"]([^'"]*)['"]''', setup).group(1) - package_regex = package_name.replace('-', '[-_]') + package_name = search(r"""name[ ]*=[ ]*['"]([^'"]*)['"]""", setup).group(1) + package_regex = package_name.replace("-", "[-_]") - pip = check_output(['curl', '-sL', '{}/{}'.format(url, package_name)]).decode() + pip = check_output(["curl", "-sL", "{}/{}".format(url, package_name)]).decode() version = None - with open('libclingo/clingo.h') as fh: + with open("libclingo/clingo.h") as fh: for line in fh: m = match(r'#define CLINGO_VERSION "([0-9]+\.[0-9]+\.[0-9]+)"', line) if m is not None: @@ -39,37 +39,63 @@ def adjust_version(url): assert version is not None post = 0 - if search(r'{}-{}\.tar\.gz'.format(package_regex, escape(version)), pip) is not None: + if ( + search(r"{}-{}\.tar\.gz".format(package_regex, escape(version)), pip) + is not None + ): post = 1 - for m in finditer(r'{}-{}\.post([0-9]+)\.tar\.gz'.format(package_regex, escape(version)), pip): + for m in finditer( + r"{}-{}\.post([0-9]+)\.tar\.gz".format(package_regex, escape(version)), pip + ): post = max(post, int(m.group(1)) + 1) - with open(setup_path, 'w') as fw: - if setup_type == 'cfg': + version = "5.7.1" + post = 0 + + with open(setup_path, "w") as fw: + if setup_type == "cfg": if post > 0: - fw.write(sub('version( *)=.*', 'version = {}.post{}'.format(version, post), setup, 1)) + fw.write( + sub( + "version( *)=.*", + "version = {}.post{}".format(version, post), + setup, + 1, + ) + ) else: - fw.write(sub('version( *)=.*', 'version = {}'.format(version), setup, 1)) + fw.write( + sub("version( *)=.*", "version = {}".format(version), setup, 1) + ) else: if post > 0: - fw.write(sub('version( *)=.*', 'version = \'{}.post{}\','.format(version, post), setup, 1)) + fw.write( + sub( + "version( *)=.*", + "version = '{}.post{}',".format(version, post), + setup, + 1, + ) + ) else: - fw.write(sub('version( *)=.*', 'version = \'{}\','.format(version), setup, 1)) + fw.write( + sub("version( *)=.*", "version = '{}',".format(version), setup, 1) + ) def run(): - ''' + """ Adjust version in setup.py depending on build type. - ''' - parser = argparse.ArgumentParser(description='Build source package.') - parser.add_argument('--release', action='store_true', help='Build release package.') + """ + parser = argparse.ArgumentParser(description="Build source package.") + parser.add_argument("--release", action="store_true", help="Build release package.") args = parser.parse_args() if args.release: - url = 'https://pypi.org/simple' + url = "https://pypi.org/simple" else: - url = 'https://test.pypi.org/simple' + url = "https://test.pypi.org/simple" adjust_version(url) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 4a01f35b2..899104c06 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -4,36 +4,12 @@ on: workflow_dispatch: inputs: wip: - description: 'Publish work in progress package.' + description: "Publish work in progress package." required: false - default: 'true' + default: "true" jobs: - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Adjust version (wip) - if: ${{ github.event.inputs.wip == 'true' }} - run: python .github/adjust_version.py - - - name: Adjust version (release) - if: ${{ github.event.inputs.wip == 'false' }} - run: python .github/adjust_version.py --release - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - build_wheels: - needs: [build_sdist] name: Build ${{ matrix.cfg.name }} wheels runs-on: ${{ matrix.cfg.os }} strategy: @@ -43,45 +19,41 @@ jobs: name: "*-manylinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313*-manylinux*" - os: ubuntu-20.04 name: "*-musllinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "*-musllinux*" + CIBW_BUILD: "cp313*-musllinux*" - os: ubuntu-20.04 name: "*-manylinux_i686" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313*-manylinux*" - os: ubuntu-20.04 name: "*-musllinux-i686" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "*-musllinux*" + CIBW_BUILD: "cp313*-musllinux*" - os: ubuntu-20.04 name: "cp*-manylinux-aarch64" env: CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "cp*-manylinux*" - - os: ubuntu-20.04 - name: "pp*-manylinux-aarch64" - env: - CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "pp*-manylinux*" + CIBW_BUILD: "cp313*-manylinux*" - os: ubuntu-20.04 name: "*-manylinux-ppc64le" env: CIBW_ARCHS_LINUX: ppc64le - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313*-manylinux*" - os: windows-2019 name: "cp*-win*" env: - CIBW_BUILD: "cp*-win*" + CIBW_BUILD: "cp313*-win*" - os: macos-11 name: "*-macos_{x86_64,arm64}" env: CIBW_ARCHS_MACOS: x86_64 arm64 + CIBW_BUILD: "cp313*" steps: - uses: actions/checkout@v3 From 92b27c0162fd46af784ea509eb53b6fd2a3c0acf Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 16 Jan 2025 14:38:48 +0100 Subject: [PATCH 2/4] fix cibuildwheel --- .github/trigger.sh | 82 ++++++++++++++---------------- .github/workflows/cibuildwheel.yml | 2 +- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/.github/trigger.sh b/.github/trigger.sh index 587ebf7c2..80e205ddb 100755 --- a/.github/trigger.sh +++ b/.github/trigger.sh @@ -4,20 +4,20 @@ repo=clingo function list() { curl \ - -X GET \ - -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/potassco/${repo}/actions/workflows" \ - -d "{\"ref\":\"ref\"}" + -X GET \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/potassco/${repo}/actions/workflows" \ + -d "{\"ref\":\"ref\"}" } function dispatch() { token=$(grep -A1 workflow_dispatch ~/.tokens | tail -n 1) curl \ - -u "rkaminsk:$token" \ - -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/potassco/${repo}/actions/workflows/$1/dispatches" \ - -d "{\"ref\":\"$3\",\"inputs\":{\"wip\":\"$2\"${4:+,$4}}}" + -u "rkaminsk:$token" \ + -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/potassco/${repo}/actions/workflows/$1/dispatches" \ + -d "{\"ref\":\"$3\",\"inputs\":{\"wip\":\"$2\"${4:+,$4}}}" } function usage() { @@ -33,10 +33,10 @@ EOF function check_action() { if [[ "$1" == "$2" ]]; then - if (($3 + $4 != $5 )); then - if (( $4 == 0 )); then + if (($3 + $4 != $5)); then + if (($4 == 0)); then echo "action '${2}' expects no arguments" >&2 - elif (( $4 == 1 )); then + elif (($4 == 1)); then echo "action '${2}' expects 1 argument" >&2 else echo "action '${2}' expects ${4} arguments" >&2 @@ -55,22 +55,22 @@ function fail() { while getopts ":h" flag; do case "$flag" in - h) - usage - exit 0 - ;; - :) - echo "ERROR: option '-${OPTARG}' expects an argument" >&2 - exit 1 - ;; - ?) - echo "ERROR: invalid option '-${OPTARG}'" >&2 - exit 1 - ;; + h) + usage + exit 0 + ;; + :) + echo "ERROR: option '-${OPTARG}' expects an argument" >&2 + exit 1 + ;; + ?) + echo "ERROR: invalid option '-${OPTARG}'" >&2 + exit 1 + ;; esac done -if (( $OPTIND > $# )); then +if (($OPTIND > $#)); then echo "ERROR: no action given" >&2 usage exit 1 @@ -79,26 +79,22 @@ fi action="${@:$OPTIND:1}" check_action list "$action" $OPTIND 0 $# || -check_action release "$action" $OPTIND 1 $# || -check_action dev "$action" $OPTIND 1 $# || -fail "$action" + check_action release "$action" $OPTIND 1 $# || + check_action dev "$action" $OPTIND 1 $# || + fail "$action" wip=true case "$action" in - list) - list - ;; - release) - wip=false - ;& - dev) - branch="${@:$OPTIND+1:1}" - # .github/workflows/ppa-dev.yml - dispatch 4881510 "$wip" "$branch" - # .github/workflows/conda-dev.yml - dispatch 4923491 "$wip" "$branch" - # .github/workflows/cibuildwheel.yml - dispatch 34889579 "$wip" "$branch" - ;; +list) + list + ;; +release) + wip=false + ;& +dev) + branch="${@:$OPTIND+1:1}" + # .github/workflows/cibuildwheel.yml + dispatch 34889579 "$wip" "$branch" + ;; esac diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 899104c06..a46d3e4f8 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -83,7 +83,7 @@ jobs: path: ./wheelhouse/*.whl upload_pypi: - needs: [build_wheels, build_sdist] + needs: [build_wheels] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 From 259bba5c1d1a8cca7663b3e1fa7efcc0bc62b376 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 16 Jan 2025 14:51:26 +0100 Subject: [PATCH 3/4] update cibw --- .github/workflows/cibuildwheel.yml | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index a46d3e4f8..5c7b802e4 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -16,44 +16,40 @@ jobs: matrix: cfg: - os: ubuntu-20.04 - name: "*-manylinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "cp313*-manylinux*" + CIBW_BUILD: "cp313-manylinux_x86_64" - os: ubuntu-20.04 - name: "*-musllinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "cp313*-musllinux*" + CIBW_BUILD: "cp313-musllinux_x86_64" - os: ubuntu-20.04 - name: "*-manylinux_i686" + name: "" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "cp313*-manylinux*" + CIBW_BUILD: "cp313-manylinux_i686" - os: ubuntu-20.04 - name: "*-musllinux-i686" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "cp313*-musllinux*" + CIBW_BUILD: "cp313-musllinux_i686" - os: ubuntu-20.04 - name: "cp*-manylinux-aarch64" env: CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "cp313*-manylinux*" + CIBW_BUILD: "cp313-manylinux_aarch64" - os: ubuntu-20.04 - name: "*-manylinux-ppc64le" env: CIBW_ARCHS_LINUX: ppc64le - CIBW_BUILD: "cp313*-manylinux*" + CIBW_BUILD: "cp313-manylinux_ppc64le" - os: windows-2019 - name: "cp*-win*" env: - CIBW_BUILD: "cp313*-win*" + CIBW_BUILD: "cp313-win_amd64" + - os: windows-2019 + env: + CIBW_BUILD: "cp313-win32" - os: macos-11 - name: "*-macos_{x86_64,arm64}" env: CIBW_ARCHS_MACOS: x86_64 arm64 - CIBW_BUILD: "cp313*" + CIBW_BUILD: "cp313-macosx_*" steps: - uses: actions/checkout@v3 @@ -75,7 +71,7 @@ jobs: run: python .github/adjust_version.py --release - name: Build wheels - uses: pypa/cibuildwheel@v2.16.5 + uses: pypa/cibuildwheel@v2.22.0 env: ${{ matrix.cfg.env }} - uses: actions/upload-artifact@v3 From 5fad142af823c0c85c3e4b710fcf92eb976b4374 Mon Sep 17 00:00:00 2001 From: Roland Kaminski Date: Thu, 16 Jan 2025 15:02:33 +0100 Subject: [PATCH 4/4] use macos latest --- .github/workflows/cibuildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 5c7b802e4..041e670c9 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -46,7 +46,7 @@ jobs: - os: windows-2019 env: CIBW_BUILD: "cp313-win32" - - os: macos-11 + - os: macos-latest env: CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BUILD: "cp313-macosx_*"