diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..6cdee4f --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,64 @@ +name: Publish to PyPI + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+' + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + container: # we have to provide a working triqs installation to make the cmake step work + image: flatironinstitute/triqs:latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build toml + --user + - name: prepare python distribution + run: | + mkdir build && cd build + cmake ../ + cp packaging/pypi/* ../ + mv python/hartree_fock/version.py ../python/hartree_fock/version.py + rm ../python/hartree_fock/version.py.in + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish PyPI 🐍 + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/hartree_fock + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true # skip if version name package already exists on pypi + diff --git a/CMakeLists.txt b/CMakeLists.txt index 328b658..8335a89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,9 @@ endif() # Additional configuration files add_subdirectory(share) +# add packaging for automatic Versioning +add_subdirectory(packaging) + # ############# # Debian Package diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 0000000..31cc825 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,9 @@ +# Configure the version of packaging files +configure_file(conda/meta.yaml.in conda/meta.yaml) +configure_file(conda/build.sh conda/build.sh COPYONLY) +configure_file(conda/conda_build_config.yaml conda/conda_build_config.yaml COPYONLY) +configure_file(pypi/MANIFEST.in pypi/MANIFEST.in COPYONLY) +configure_file(pypi/pyproject.toml.in pypi/pyproject.toml) +configure_file(TRIQS-hartree_fock-foss-2021b.eb.in TRIQS-hartree_fock-foss-2021b.eb) + + diff --git a/packaging/TRIQS-hartree_fock-3.2.0-foss-2021b.eb b/packaging/TRIQS-hartree_fock-foss-2021b.eb.in similarity index 98% rename from packaging/TRIQS-hartree_fock-3.2.0-foss-2021b.eb rename to packaging/TRIQS-hartree_fock-foss-2021b.eb.in index ae28711..f8998be 100644 --- a/packaging/TRIQS-hartree_fock-3.2.0-foss-2021b.eb +++ b/packaging/TRIQS-hartree_fock-foss-2021b.eb.in @@ -1,7 +1,7 @@ easyblock = 'CMakeMake' name = 'TRIQS-hartree_fock' -version = '3.1.0' +version = '@PROJECT_VERSION@' homepage = 'https://triqs.github.io/hartree_fock/' description = """ diff --git a/packaging/conda/meta.yaml b/packaging/conda/meta.yaml.in similarity index 96% rename from packaging/conda/meta.yaml rename to packaging/conda/meta.yaml.in index 8d4bf4b..3719e46 100644 --- a/packaging/conda/meta.yaml +++ b/packaging/conda/meta.yaml.in @@ -1,4 +1,4 @@ -{% set version = "3.2.0" %} +{% set version = "@PROJECT_VERSION@" %} package: name: triqs_hartree_fock diff --git a/packaging/pypi/MANIFEST.in b/packaging/pypi/MANIFEST.in new file mode 100644 index 0000000..2cad09e --- /dev/null +++ b/packaging/pypi/MANIFEST.in @@ -0,0 +1,13 @@ +prune test +prune .git +prune .github +prune doc +prune share +prune Docker +prune deps +prune packaging +prune paper +prune bin +prune build + +global-exclude .clang-format .clang-tidy .dockerignore .gitignore CMakeLists.txt Jenkinsfile diff --git a/packaging/pypi/pyproject.toml.in b/packaging/pypi/pyproject.toml.in new file mode 100644 index 0000000..819c76e --- /dev/null +++ b/packaging/pypi/pyproject.toml.in @@ -0,0 +1,35 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["python"] + +[project] +name = "hartree_fock" +version = "@PROJECT_VERSION@" +authors = [ + { name="TRIQS", email="triqs@flatironinstitute.org" } +] +description = "PROVIDE HERE A DESCRIPTION OF YOUR APPLICATION" +readme = "README.md" +keywords = [triqs"] +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", +] +dependencies = [ + "numpy", + "scipy" +] + +[project.urls] +"Homepage" = "https://triqs.github.io/hartree_fock" +"Bug Tracker" = "https://github.com/triqs/hartree_fock/issues" + +# in case you want an executable hook of your app +# [project.scripts] +# solid_dmft = "solid_dmft.main:main" +