From 87f474397f3dfd048f6a8e7c900062caf71785fe Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 4 Sep 2023 13:34:36 -0700 Subject: [PATCH 01/31] Read release tag --- .github/workflows/release-python.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 500a90f52..54422c47c 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -5,7 +5,7 @@ # provided by a third-party and are governed by separate terms of service, # privacy policy, and support documentation. -name: release python +name: Build Python Release on: workflow_dispatch: @@ -19,6 +19,9 @@ on: default: true required: false type: boolean + release: + types: [published] + jobs: build_wheels: @@ -34,32 +37,24 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - name: Build wheels on Linux - if: runner.os == 'Linux' - uses: pypa/cibuildwheel@v2.13.1 - env: - # Linux cannot call "sh -c ./python/install-hyperonc.sh" because - # before-all command is also called with "sh -c" - CIBW_BEFORE_ALL: ./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}} - with: - package-dir: ./python + - name: Set env + run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV + run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV - - name: Build wheels on MacOSX - if: runner.os == 'macOS' + - name: Build wheels on {{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - # Mac OS X cannot call "./python/install-hyperonc.sh" probably because - # "/bin/sh" is not correct path for the shell there CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" with: package-dir: ./python - name: Publish artifacts on GitHub + if: ${{github.event_name}} == 'pubished' uses: svenstaro/upload-release-action@v2 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} + repo_token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} file: ./wheelhouse/*.whl - tag: ${{ inputs.release-tag }} + tag: ${{ github.ref_name }} prerelease: ${{ inputs.prerelease }} overwrite: true file_glob: true From 7ee6f5074d9d549c40b7214afc326a15db14fdde Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 4 Sep 2023 16:02:43 -0700 Subject: [PATCH 02/31] Fix step --- .github/workflows/release-python.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 54422c47c..ae6d5fbf1 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -37,9 +37,8 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - name: Set env - run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV - run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV + - run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV + - run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV - name: Build wheels on {{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 @@ -49,7 +48,7 @@ jobs: package-dir: ./python - name: Publish artifacts on GitHub - if: ${{github.event_name}} == 'pubished' + if: github.event_name == 'pubished' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} From 86336cead25f6fbe287c02dd0606d69875d6ca57 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 4 Sep 2023 17:11:07 -0700 Subject: [PATCH 03/31] Minor fix --- .github/workflows/release-python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index ae6d5fbf1..008a710b1 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -40,7 +40,7 @@ jobs: - run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV - run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV - - name: Build wheels on {{ matrix.os }} + - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" @@ -48,7 +48,7 @@ jobs: package-dir: ./python - name: Publish artifacts on GitHub - if: github.event_name == 'pubished' + if: github.event_name == 'release' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} From f81e2d76549b6c3cde6d6e020efe6df99c18d6c6 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 4 Sep 2023 18:55:39 -0700 Subject: [PATCH 04/31] Fix token name --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 008a710b1..d64ba950c 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -51,7 +51,7 @@ jobs: if: github.event_name == 'release' uses: svenstaro/upload-release-action@v2 with: - repo_token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} + repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./wheelhouse/*.whl tag: ${{ github.ref_name }} prerelease: ${{ inputs.prerelease }} From ad5abf7c580958f1c6680a14defb7e2993ebf967 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 18:26:02 -0700 Subject: [PATCH 05/31] Switch to dynamic version --- python/pyproject.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 5cdbdc598..3f5224acf 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,10 +1,9 @@ [build-system] -requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4"] +requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [project] name = "hyperon" -version = "0.1.6" description = "Hyperon API in Python" requires-python = ">=3.7" keywords = ["metta", "hyperon", "opencog"] @@ -19,6 +18,7 @@ classifiers = [ dependencies = [ 'importlib-metadata==6.6.0; python_version<"3.8"', ] +dynamic = ["version"] [project.scripts] metta = "hyperon.metta:main" @@ -39,3 +39,8 @@ before-all = "sh -c ./python/install-hyperonc.sh" skip = "*-musllinux_i686" test-requires = ["pytest==7.3.2"] test-command = "pytest {project}/python/tests" + + +[tool.setuptools_scm] +root = '..' + From 174da79b03dbba1b3906d31b7423e77080c76d64 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 19:12:41 -0700 Subject: [PATCH 06/31] Add publish job --- .github/workflows/release-python.yml | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d64ba950c..8b896fb15 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -10,7 +10,7 @@ name: Build Python Release on: workflow_dispatch: inputs: - release-tag: + release_tag: description: 'GitHub release tag to publish packages' required: false type: string @@ -44,10 +44,11 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" + CIBW_BUILD: cp37-* # For test with: package-dir: ./python - - name: Publish artifacts on GitHub + - name: Publish Artifacts on GitHub Release if: github.event_name == 'release' uses: svenstaro/upload-release-action@v2 with: @@ -57,3 +58,29 @@ jobs: prerelease: ${{ inputs.prerelease }} overwrite: true file_glob: true + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: python-wheels + path: ./wheelhouse/*.whl + + publish-pypi: + name: Publish to PyPI + permissions: + id-token: write + environment: + name: production + runs-on: ubuntu-latest + needs: [build_wheels] + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v3 + with: + name: python-wheels + path: dist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ From c07071b0c4d9370ff13e534905f85ce23d39eb8d Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 19:31:55 -0700 Subject: [PATCH 07/31] Testing --- .github/workflows/release-python.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 8b896fb15..bc50acd6b 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -30,7 +30,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, macos-11] + #os: [ubuntu-20.04, macos-11] + os: [macos-11] max-parallel: 3 steps: @@ -44,7 +45,7 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" - CIBW_BUILD: cp37-* # For test + CIBW_BUILD: cp37-manylinux* # For test with: package-dir: ./python From 8f170ec38a729aadd75a48bf150b32bd6bb0b0fd Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 19:35:24 -0700 Subject: [PATCH 08/31] Testing --- .github/workflows/release-python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index bc50acd6b..309dedbb9 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -45,7 +45,8 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" - CIBW_BUILD: cp37-manylinux* # For test + CIBW_BUILD: cp37-* # For test + CIBW_SKIP: "*musllinux*" with: package-dir: ./python From 36d6b89882fa6e41ad6d8c28ad7af7fff19f0b0a Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 19:55:03 -0700 Subject: [PATCH 09/31] Remove publish condition --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 309dedbb9..fc473070d 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -75,7 +75,7 @@ jobs: name: production runs-on: ubuntu-latest needs: [build_wheels] - if: github.event_name == 'release' && github.event.action == 'published' + #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 with: From 990d8b517ca2ede7779643fffad81fddb03fcd65 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 21:29:11 -0700 Subject: [PATCH 10/31] Add readme --- python/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index 3f5224acf..2a78896c9 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -5,6 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "hyperon" description = "Hyperon API in Python" +readme = "../README.md" requires-python = ">=3.7" keywords = ["metta", "hyperon", "opencog"] license = {text = "MIT License"} From e7b7ae3b74c369b775f37c03a7a4cd627881b971 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 21:32:44 -0700 Subject: [PATCH 11/31] Publish to test pypi --- .github/workflows/release-python.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index fc473070d..02880f6e2 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -85,4 +85,23 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} + + publish-test-pypi: + name: Publish to Test PyPI + permissions: + id-token: write + environment: + name: test + runs-on: ubuntu-latest + needs: [build_wheels] + #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' + steps: + - uses: actions/download-artifact@v3 + with: + name: python-wheels + path: dist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ From 7ed113688088424aceb1dbbe1147e7b70016558f Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 21:39:26 -0700 Subject: [PATCH 12/31] Fix readme path --- python/README.md | 12 ++++++++++++ python/pyproject.toml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 python/README.md diff --git a/python/README.md b/python/README.md new file mode 100644 index 000000000..db518b39f --- /dev/null +++ b/python/README.md @@ -0,0 +1,12 @@ +# Overview + +OpenCog Hyperon is a substantially revised, novel version of OpenCog - which is currently at an active +pre-alpha stage of development and experimentation. One of the focuses in the Hyperon design is a successor +to the OpenCog Classic Atomese language with clear semantics supporting meta-language features, +different types of inference, etc. What we have landed on is an "Atomese 2" language called MeTTa (Meta Type Talk). + +One can run MeTTa script from command line: + +``` +metta .metta +``` diff --git a/python/pyproject.toml b/python/pyproject.toml index 2a78896c9..9e8d2bdff 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "hyperon" description = "Hyperon API in Python" -readme = "../README.md" +readme = "README.md" requires-python = ">=3.7" keywords = ["metta", "hyperon", "opencog"] license = {text = "MIT License"} From 06cec935ef46ab34c249486612c0b206281a993c Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Thu, 7 Sep 2023 21:55:09 -0700 Subject: [PATCH 13/31] Revert "Switch to dynamic version" This reverts commit ad5abf7c580958f1c6680a14defb7e2993ebf967. --- python/pyproject.toml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 9e8d2bdff..75f5f60c3 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,9 +1,10 @@ [build-system] -requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4"] build-backend = "setuptools.build_meta" [project] name = "hyperon" +version = "0.1.6" description = "Hyperon API in Python" readme = "README.md" requires-python = ">=3.7" @@ -19,7 +20,6 @@ classifiers = [ dependencies = [ 'importlib-metadata==6.6.0; python_version<"3.8"', ] -dynamic = ["version"] [project.scripts] metta = "hyperon.metta:main" @@ -40,8 +40,3 @@ before-all = "sh -c ./python/install-hyperonc.sh" skip = "*-musllinux_i686" test-requires = ["pytest==7.3.2"] test-command = "pytest {project}/python/tests" - - -[tool.setuptools_scm] -root = '..' - From ec0b95d3150eb13a515e65601dc1c64561a4e4b7 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 20:40:57 -0700 Subject: [PATCH 14/31] Debugging --- .github/workflows/release-python.yml | 32 ++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 02880f6e2..0c1771067 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -10,10 +10,6 @@ name: Build Python Release on: workflow_dispatch: inputs: - release_tag: - description: 'GitHub release tag to publish packages' - required: false - type: string prerelease: description: 'Flag to create a pre-release' default: true @@ -30,8 +26,7 @@ jobs: strategy: fail-fast: false matrix: - #os: [ubuntu-20.04, macos-11] - os: [macos-11] + os: [ubuntu-20.04, macos-11] max-parallel: 3 steps: @@ -40,6 +35,7 @@ jobs: - run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV - run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV + - run: echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 @@ -67,34 +63,35 @@ jobs: name: python-wheels path: ./wheelhouse/*.whl - publish-pypi: - name: Publish to PyPI + publish-test-pypi: + name: Publish to Test PyPI permissions: id-token: write environment: - name: production + name: test runs-on: ubuntu-latest needs: [build_wheels] - #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' + #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 with: name: python-wheels path: dist - - name: Publish package distributions to PyPI + - name: Publish package distributions to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.PYPI_API_TOKEN }} + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ - publish-test-pypi: - name: Publish to Test PyPI + publish-pypi: + name: Publish to PyPI permissions: id-token: write environment: - name: test + name: production runs-on: ubuntu-latest needs: [build_wheels] - #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' + #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 with: @@ -103,5 +100,4 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository-url: https://test.pypi.org/legacy/ + password: ${{ secrets.PYPI_API_TOKEN }} From 54cfcabe7a90930fb60055f934255d13d4812609 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 20:48:02 -0700 Subject: [PATCH 15/31] Fix empty git ref when it is triggered by a release --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 0c1771067..b60dd3622 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -40,7 +40,7 @@ jobs: - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{github.ref}}" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.GITHUB_REF}}" CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: From 963ea39bc179000287b5853568759bf9f59963eb Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:12:42 -0700 Subject: [PATCH 16/31] Check out specific commit --- .github/workflows/release-python.yml | 11 +++++++---- python/install-hyperonc.sh | 9 +++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index b60dd3622..d0f196a28 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -33,14 +33,17 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - run: echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV - - run: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV - - run: echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV + - run: | + echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV + echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV + echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV + echo "GITHUB_TAG_NAME=${{github.event.release.tag_name}}" | tee $GITHUB_ENV + echo "GITHUB_SHA=${{GITHUB_SHA}}" - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.GITHUB_REF}}" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.GITHUB_SHA}}" CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: diff --git a/python/install-hyperonc.sh b/python/install-hyperonc.sh index 487c2cc91..e40355d15 100755 --- a/python/install-hyperonc.sh +++ b/python/install-hyperonc.sh @@ -34,12 +34,9 @@ python3 -m pip install conan==1.60.2 pip==23.1.2 PATH="${PATH}:${HOME}/.local/bin" conan profile new --detect default -mkdir -p ${HOME}/hyperonc -cd ${HOME}/hyperonc -git init -git remote add origin $HYPERONC_URL -git fetch origin $HYPERONC_REV -git reset --hard FETCH_HEAD +cd ${HOME} +git clone $HYPERONC_URL hyperonc +git reset --hard $HYPERONC_REV mkdir -p ${HOME}/hyperonc/c/build cd ${HOME}/hyperonc/c/build From 7c2b6afb0a5f523c4cb177f67c0869c4979461d9 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:14:00 -0700 Subject: [PATCH 17/31] Fix env var --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d0f196a28..8b708c1e0 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,7 +38,7 @@ jobs: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV echo "GITHUB_TAG_NAME=${{github.event.release.tag_name}}" | tee $GITHUB_ENV - echo "GITHUB_SHA=${{GITHUB_SHA}}" + echo "GITHUB_SHA=${{env.GITHUB_SHA}}" - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 From 14dc0c50ad910ec8cce4848ef11405f913896a57 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:18:12 -0700 Subject: [PATCH 18/31] Set commit head --- .github/workflows/release-python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 8b708c1e0..9f84432ed 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,12 +38,12 @@ jobs: echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV echo "GITHUB_TAG_NAME=${{github.event.release.tag_name}}" | tee $GITHUB_ENV - echo "GITHUB_SHA=${{env.GITHUB_SHA}}" + echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee $GITHUB_ENV - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.GITHUB_SHA}}" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{COMMIT_HEAD}}" CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: From d8f5358572a7bef89d23372f902cc6a8604aa491 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:22:52 -0700 Subject: [PATCH 19/31] Try to share env var cross steps --- .github/workflows/release-python.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 9f84432ed..13872a815 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -34,11 +34,11 @@ jobs: uses: actions/checkout@v3 - run: | - echo "GITHUB_REF_NAME=${{github.ref_name}}" | tee $GITHUB_ENV - echo "GITHUB_EVENT_NAME=${{github.event_name}}" | tee $GITHUB_ENV - echo "GITHUB_PRERELEASE=${{github.event.release.prerelease}}" | tee $GITHUB_ENV - echo "GITHUB_TAG_NAME=${{github.event.release.tag_name}}" | tee $GITHUB_ENV - echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee $GITHUB_ENV + echo "REF_NAME=${{github.ref_name}}" | tee -a $GITHUB_ENV + echo "EVENT_NAME=${{github.event_name}}" | tee -a $GITHUB_ENV + echo "PRERELEASE=${{github.event.release.prerelease}}" | tee -a $GITHUB_ENV + echo "TAG_NAME=${{github.event.release.tag_name}}" | tee -a $GITHUB_ENV + echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee -a $GITHUB_ENV - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 From 9157fa177a4a6d105495633aa1c8ffed7af6f289 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:25:10 -0700 Subject: [PATCH 20/31] Fix unrecognized var --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 13872a815..1de2237a0 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -43,7 +43,7 @@ jobs: - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{COMMIT_HEAD}}" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r $COMMIT_HEAD" CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: From eda851971f534d2d121b2ca1b44415f570d094cf Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:29:17 -0700 Subject: [PATCH 21/31] Fix unrecognized var --- .github/workflows/release-python.yml | 2 +- python/install-hyperonc.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 1de2237a0..aa818f5a5 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -43,7 +43,7 @@ jobs: - name: Build wheels on ${{ matrix.os }} uses: pypa/cibuildwheel@v2.13.1 env: - CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r $COMMIT_HEAD" + CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: diff --git a/python/install-hyperonc.sh b/python/install-hyperonc.sh index e40355d15..e479b2531 100755 --- a/python/install-hyperonc.sh +++ b/python/install-hyperonc.sh @@ -36,6 +36,7 @@ conan profile new --detect default cd ${HOME} git clone $HYPERONC_URL hyperonc +cd ${HOME}/hyperonc git reset --hard $HYPERONC_REV mkdir -p ${HOME}/hyperonc/c/build From 9c042b7e001ad8fda82f3d1d6551fd5599bfc61f Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:50:13 -0700 Subject: [PATCH 22/31] Refine dependency --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index aa818f5a5..fdc1cd6a9 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -93,7 +93,7 @@ jobs: environment: name: production runs-on: ubuntu-latest - needs: [build_wheels] + needs: [publish-test-pypi, build_wheels] #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 From fb754992aabe7e9a45cb9568086c116acb098326 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 21:54:42 -0700 Subject: [PATCH 23/31] Fix uploading artifacts --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index fdc1cd6a9..e7f678fc9 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -55,7 +55,7 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./wheelhouse/*.whl - tag: ${{ github.ref_name }} + tag: ${{ github.ref }} prerelease: ${{ inputs.prerelease }} overwrite: true file_glob: true From ace075fb10ffee0404153a6a59d9b133fe0bb0a9 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 22:06:50 -0700 Subject: [PATCH 24/31] Revert "Revert "Switch to dynamic version"" This reverts commit 06cec935ef46ab34c249486612c0b206281a993c. --- python/pyproject.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 75f5f60c3..9e8d2bdff 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,10 +1,9 @@ [build-system] -requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4"] +requires = ["setuptools==65.6.3", "conan==1.60.2", "cmake==3.26.4", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [project] name = "hyperon" -version = "0.1.6" description = "Hyperon API in Python" readme = "README.md" requires-python = ">=3.7" @@ -20,6 +19,7 @@ classifiers = [ dependencies = [ 'importlib-metadata==6.6.0; python_version<"3.8"', ] +dynamic = ["version"] [project.scripts] metta = "hyperon.metta:main" @@ -40,3 +40,8 @@ before-all = "sh -c ./python/install-hyperonc.sh" skip = "*-musllinux_i686" test-requires = ["pytest==7.3.2"] test-command = "pytest {project}/python/tests" + + +[tool.setuptools_scm] +root = '..' + From 0569e920354a98c3ffbd31e3f7da609d93e4bf74 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 22:07:20 -0700 Subject: [PATCH 25/31] Revert workflow dep --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index e7f678fc9..00b07abe1 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -93,7 +93,7 @@ jobs: environment: name: production runs-on: ubuntu-latest - needs: [publish-test-pypi, build_wheels] + needs: [build_wheels] #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 From 449394f9c0e993af919260d5671081042adbd39a Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 22:14:49 -0700 Subject: [PATCH 26/31] Set condition --- .github/workflows/release-python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 00b07abe1..16708d956 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -74,7 +74,7 @@ jobs: name: test runs-on: ubuntu-latest needs: [build_wheels] - #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' + if: github.event.action == 'published' steps: - uses: actions/download-artifact@v3 with: @@ -94,7 +94,7 @@ jobs: name: production runs-on: ubuntu-latest needs: [build_wheels] - #if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' + if: github.event.action == 'published' steps: - uses: actions/download-artifact@v3 with: From 79d622f7a65b1cd5f7057311c26db6df02e9d1fc Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 22:14:49 -0700 Subject: [PATCH 27/31] Remove trigger inputs --- .github/workflows/release-python.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 16708d956..644f2728d 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -5,16 +5,10 @@ # provided by a third-party and are governed by separate terms of service, # privacy policy, and support documentation. -name: Build Python Release +name: Build Python Package and Publish on: workflow_dispatch: - inputs: - prerelease: - description: 'Flag to create a pre-release' - default: true - required: false - type: boolean release: types: [published] @@ -50,13 +44,13 @@ jobs: package-dir: ./python - name: Publish Artifacts on GitHub Release - if: github.event_name == 'release' + if: github.event.action == 'published' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./wheelhouse/*.whl tag: ${{ github.ref }} - prerelease: ${{ inputs.prerelease }} + prerelease: ${{ github.event.release.prerelease }} overwrite: true file_glob: true From b237f06a1ff952a0f3b4a48aebabf19b28612975 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Mon, 11 Sep 2023 22:50:28 -0700 Subject: [PATCH 28/31] Build full python versions --- .github/workflows/release-python.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 644f2728d..2591d43ab 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,7 +38,6 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" - CIBW_BUILD: cp37-* # For test CIBW_SKIP: "*musllinux*" with: package-dir: ./python From 9a3011488380e1927224710a7277128c759ea94f Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Wed, 13 Sep 2023 11:33:02 -0700 Subject: [PATCH 29/31] Update after PR review --- .github/workflows/release-python.yml | 3 +-- python/install-hyperonc.sh | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 2591d43ab..5312a6cf5 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -5,7 +5,7 @@ # provided by a third-party and are governed by separate terms of service, # privacy policy, and support documentation. -name: Build Python Package and Publish +name: release python on: workflow_dispatch: @@ -38,7 +38,6 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" - CIBW_SKIP: "*musllinux*" with: package-dir: ./python diff --git a/python/install-hyperonc.sh b/python/install-hyperonc.sh index e479b2531..6a3eedf28 100755 --- a/python/install-hyperonc.sh +++ b/python/install-hyperonc.sh @@ -34,10 +34,12 @@ python3 -m pip install conan==1.60.2 pip==23.1.2 PATH="${PATH}:${HOME}/.local/bin" conan profile new --detect default -cd ${HOME} -git clone $HYPERONC_URL hyperonc +mkdir -p ${HOME}/hyperonc cd ${HOME}/hyperonc -git reset --hard $HYPERONC_REV +git init +git remote add origin $HYPERONC_URL +git fetch --depth=1 origin $HYPERONC_REV +git reset --hard FETCH_HEAD mkdir -p ${HOME}/hyperonc/c/build cd ${HOME}/hyperonc/c/build From 93d759117f275ff259908d700e7a70ec28b85961 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Wed, 13 Sep 2023 18:33:15 -0700 Subject: [PATCH 30/31] Opt out musllinux --- .github/workflows/release-python.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 5312a6cf5..4dd22942f 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,6 +38,7 @@ jobs: uses: pypa/cibuildwheel@v2.13.1 env: CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" + CIBW_SKIP: "*musllinux*" with: package-dir: ./python From b9acf2992ce4c7c378ec374ff9c40d5db5db85d4 Mon Sep 17 00:00:00 2001 From: Wenwei Huang Date: Wed, 13 Sep 2023 19:02:32 -0700 Subject: [PATCH 31/31] Configure trusted publisher --- .github/workflows/release-python.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 4dd22942f..a00c0758b 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -76,7 +76,6 @@ jobs: - name: Publish package distributions to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ publish-pypi: @@ -95,5 +94,3 @@ jobs: path: dist - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }}