From aac8d39acab094ca09d9efa0cd02cd9e30d72601 Mon Sep 17 00:00:00 2001 From: SaltyChiang Date: Mon, 4 Nov 2024 13:42:07 +0800 Subject: [PATCH] Update for PyPI publish. --- .github/workflows/PyQUDA-Utils.yaml | 15 ++++++++++++--- .github/workflows/PyQUDA.yaml | 19 ++++++++++++++++--- example/1_Quenched_HMC.py | 2 +- example/2_Quark_Propagator.py | 4 ++-- example/3_Pion_Proton_2pt.py | 4 ++-- example/4_Pion_PCAC.py | 4 ++-- example/5_Pion_Dispersion.py | 4 ++-- setup.py | 2 +- 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/.github/workflows/PyQUDA-Utils.yaml b/.github/workflows/PyQUDA-Utils.yaml index 6431d94..d1b02a1 100644 --- a/.github/workflows/PyQUDA-Utils.yaml +++ b/.github/workflows/PyQUDA-Utils.yaml @@ -1,4 +1,4 @@ -name: PyQUDA-Utils sdist +name: PyQUDA-Utils publish on: workflow_dispatch: @@ -9,10 +9,17 @@ on: default: 0.0.0 jobs: - build: + pypi-publish: runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/PyQUDA-Utils + + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: - name: Checkout uses: actions/checkout@v4 @@ -34,6 +41,8 @@ jobs: if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' uses: softprops/action-gh-release@v1 with: - tag_name: v${{ github.event.inputs.tag }} files: dist/pyquda_utils-${{ github.event.inputs.tag }}.tar.gz fail_on_unmatched_files: true + + - name: Publish sdist + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/PyQUDA.yaml b/.github/workflows/PyQUDA.yaml index 6b1034e..33acc2c 100644 --- a/.github/workflows/PyQUDA.yaml +++ b/.github/workflows/PyQUDA.yaml @@ -1,4 +1,4 @@ -name: PyQUDA sdist +name: PyQUDA publish on: workflow_dispatch: @@ -9,10 +9,17 @@ on: default: 0.0.0 jobs: - build: + pypi-publish: runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/PyQUDA + + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: - name: Checkout uses: actions/checkout@v4 @@ -28,7 +35,7 @@ jobs: run: python -m pip install --upgrade pip setuptools wheel Cython build - name: Build sdist - run: cd pyquda_core && python -m build . --sdist + run: python -m build ./pyquda_core --sdist - name: Upload sdist if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' @@ -37,3 +44,9 @@ jobs: tag_name: v${{ github.event.inputs.tag }} files: pyquda_core/dist/pyquda-${{ github.event.inputs.tag }}.tar.gz fail_on_unmatched_files: true + + - name: Prepare sdist + run: mv ./pyquda_core/sdist ./ + + - name: Publish sdist + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/example/1_Quenched_HMC.py b/example/1_Quenched_HMC.py index 383ad74..64f173e 100644 --- a/example/1_Quenched_HMC.py +++ b/example/1_Quenched_HMC.py @@ -3,8 +3,8 @@ from time import perf_counter from pyquda import init -from pyquda.utils import io from pyquda.field import LatticeInfo, LatticeGauge, Nc +from pyquda_utils import io from hmc import HMC diff --git a/example/2_Quark_Propagator.py b/example/2_Quark_Propagator.py index 6aab278..b1b5f08 100644 --- a/example/2_Quark_Propagator.py +++ b/example/2_Quark_Propagator.py @@ -3,9 +3,9 @@ from opt_einsum import contract from matplotlib import pyplot as plt -from pyquda import init, core, LatticeInfo -from pyquda.utils import io, gamma, source +from pyquda import init, LatticeInfo from pyquda.field import LatticePropagator, Ns, Nc +from pyquda_utils import core, io, gamma, source init([1, 1, 1, 2], resource_path=".cache") diff --git a/example/3_Pion_Proton_2pt.py b/example/3_Pion_Proton_2pt.py index 06c6452..660067d 100644 --- a/example/3_Pion_Proton_2pt.py +++ b/example/3_Pion_Proton_2pt.py @@ -4,8 +4,8 @@ from opt_einsum import contract from matplotlib import pyplot as plt -from pyquda import init, core, LatticeInfo -from pyquda.utils import io, gamma +from pyquda import init, LatticeInfo +from pyquda_utils import core, io, gamma init([1, 1, 1, 2], resource_path=".cache") diff --git a/example/4_Pion_PCAC.py b/example/4_Pion_PCAC.py index d940616..92f2a5c 100644 --- a/example/4_Pion_PCAC.py +++ b/example/4_Pion_PCAC.py @@ -3,8 +3,8 @@ from opt_einsum import contract from matplotlib import pyplot as plt -from pyquda import init, core, LatticeInfo -from pyquda.utils import io, gamma +from pyquda import init, LatticeInfo +from pyquda_utils import core, io, gamma init([1, 1, 1, 2], resource_path=".cache") diff --git a/example/5_Pion_Dispersion.py b/example/5_Pion_Dispersion.py index 6f45c4c..b9fa69a 100644 --- a/example/5_Pion_Dispersion.py +++ b/example/5_Pion_Dispersion.py @@ -3,8 +3,8 @@ from opt_einsum import contract from matplotlib import pyplot as plt -from pyquda import init, core, LatticeInfo -from pyquda.utils import io, gamma, phase +from pyquda import init, LatticeInfo +from pyquda_utils import core, io, gamma, phase init([1, 1, 1, 2], resource_path=".cache") diff --git a/setup.py b/setup.py index 01a1741..aba5fb3 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,6 @@ if describe != "": tag, post, hash = describe.strip().split("-") with open(os.path.join(os.path.dirname(__file__), "pyquda_utils", "_version.py"), "w") as f: - f.write(f'__version__ = "{tag[1:]}.post{post}+{hash}"\n') + f.write(f'__version__ = "{tag[1:]}.dev{post}"\n') setup()