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/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 4a01f35b2..041e670c9 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -4,84 +4,52 @@ 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: matrix: cfg: - os: ubuntu-20.04 - name: "*-manylinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313-manylinux_x86_64" - os: ubuntu-20.04 - name: "*-musllinux_x86_64" env: CIBW_ARCHS_LINUX: x86_64 - CIBW_BUILD: "*-musllinux*" + CIBW_BUILD: "cp313-musllinux_x86_64" - os: ubuntu-20.04 - name: "*-manylinux_i686" + name: "" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313-manylinux_i686" - os: ubuntu-20.04 - name: "*-musllinux-i686" env: CIBW_ARCHS_LINUX: i686 - CIBW_BUILD: "*-musllinux*" + CIBW_BUILD: "cp313-musllinux_i686" - os: ubuntu-20.04 - name: "cp*-manylinux-aarch64" env: CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "cp*-manylinux*" + CIBW_BUILD: "cp313-manylinux_aarch64" - os: ubuntu-20.04 - name: "pp*-manylinux-aarch64" - env: - CIBW_ARCHS_LINUX: aarch64 - CIBW_BUILD: "pp*-manylinux*" - - os: ubuntu-20.04 - name: "*-manylinux-ppc64le" env: CIBW_ARCHS_LINUX: ppc64le - CIBW_BUILD: "*-manylinux*" + CIBW_BUILD: "cp313-manylinux_ppc64le" + - os: windows-2019 + env: + CIBW_BUILD: "cp313-win_amd64" - os: windows-2019 - name: "cp*-win*" env: - CIBW_BUILD: "cp*-win*" - - os: macos-11 - name: "*-macos_{x86_64,arm64}" + CIBW_BUILD: "cp313-win32" + - os: macos-latest env: CIBW_ARCHS_MACOS: x86_64 arm64 + CIBW_BUILD: "cp313-macosx_*" steps: - uses: actions/checkout@v3 @@ -103,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 @@ -111,7 +79,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