From c0e6265825e89cf9f4dfcda44ed83a3fa0284eb2 Mon Sep 17 00:00:00 2001 From: pciturri Date: Wed, 2 Oct 2024 12:59:05 +0200 Subject: [PATCH] ci: set up automatic versioning. --- .github/workflows/publish-pypi.yml | 10 ++++---- .gitignore | 2 +- docs/conf.py | 39 ++++++++++++------------------ pyproject.toml | 9 +++++-- requirements_dev.txt | 1 + setup.cfg | 3 ++- setup.py | 6 ++++- 7 files changed, 37 insertions(+), 33 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index f8f540a..493854f 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -23,16 +23,16 @@ jobs: create-args: >- python=3.10 - - name: Install py-build + - name: Install py-build and setuptools-scm run: | - python3 -m pip install --upgrade build + micromamba run -n floatcsep python3 -m pip install --upgrade build setuptools-scm - name: Build run: | - python3 -m build --sdist --wheel --outdir dist/ + micromamba run -n your_env_name python3 -m build --sdist --wheel --outdir dist/ - name: Publish Package - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@v1.9.0 with: user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index fd66bd7..78c2091 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .idea/ __pycache__ - +version diff --git a/docs/conf.py b/docs/conf.py index d2b4e4f..46f1ae2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,6 +5,7 @@ import os import sys from sphinx_gallery.sorting import FileNameSortKey +from importlib.metadata import version as get_version sys.path.insert(0, os.path.abspath("..")) @@ -16,7 +17,8 @@ project = "floatCSEP" copyright = "2024, Pablo Iturrieta" author = "Pablo Iturrieta" -release = "v0.2.0" +release = get_version("floatcsep") # Automatically gets the version from setuptools_scm + # -- General configuration --------------------------------------------------- @@ -25,8 +27,8 @@ "sphinx.ext.todo", "sphinx.ext.autosummary", "sphinx.ext.coverage", - 'sphinx_toolbox.github', - 'sphinx_toolbox.sidebar_links', + "sphinx_toolbox.github", + "sphinx_toolbox.sidebar_links", "sphinx.ext.mathjax", "sphinx.ext.viewcode", "sphinx.ext.napoleon", @@ -35,10 +37,10 @@ "sphinx_design", ] -github_username = 'cseptesting' -github_repository = 'floatcsep' +github_username = "cseptesting" +github_repository = "floatcsep" -language = 'en' +language = "en" autosummary_generate = False autoclass_content = "both" suppress_warnings = [ @@ -82,30 +84,21 @@ html_context = { "github_links": [ + ("Getting help", "https://github.com/cseptesting/floatcsep/issues"), ( - 'Getting help', - "https://github.com/cseptesting/floatcsep/issues" - ), - ( - 'Contributing', - "https://github.com/cseptesting/floatcsep/blob/master/CONTRIBUTING.md" - ), - ( - 'Code of Conduct', - "https://github.com/cseptesting/floatcsep/blob/master/CODE_OF_CONDUCT.md" - ), - ( - 'License', - "https://github.com/cseptesting/floatcsep/blob/master/LICENSE" + "Contributing", + "https://github.com/cseptesting/floatcsep/blob/master/CONTRIBUTING.md", ), ( - 'Source Code', - "https://github.com/cseptesting/floatcsep" + "Code of Conduct", + "https://github.com/cseptesting/floatcsep/blob/master/CODE_OF_CONDUCT.md", ), + ("License", "https://github.com/cseptesting/floatcsep/blob/master/LICENSE"), + ("Source Code", "https://github.com/cseptesting/floatcsep"), ], } extlinks = { - 'github_contrib': ('https://github.com/cseptesting/floatcsep/main/blob/%s', ''), + "github_contrib": ("https://github.com/cseptesting/floatcsep/main/blob/%s", ""), } rst_epilog = """ .. raw:: html diff --git a/pyproject.toml b/pyproject.toml index 1972590..117a689 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=52.0", "wheel"] +requires = ["setuptools>=52.0", "wheel", "setuptools-scm"] build-backend = "setuptools.build_meta" [tool.pytest.ini_options] @@ -16,4 +16,9 @@ target-version = ["py39", "py310", "py311"] [tool.flake8] ignore = ["E203", "W503", "F401"] -max-line-length = 96 \ No newline at end of file +max-line-length = 96 + +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "no-local-version" +fallback_version = "0.2.0" \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index d056c16..68a65c6 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -21,6 +21,7 @@ pyyaml requests scipy seaborn +setuptools-scm shapely sphinx sphinx-autoapi diff --git a/setup.cfg b/setup.cfg index 32e31d1..7285b3a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ long_description_content_type = text/markdown author = Pablo Iturrieta author_email = pciturri@gfz-potsdam.de license = BSD 3-Clause License -version = 0.1.4 +version = attr: setuptools_scm.get_version platforms = unix, linux, osx, win32 classifiers = Programming Language :: Python :: 3 @@ -69,6 +69,7 @@ dev = requests scipy seaborn + setuptools-scm shapely sphinx sphinx-autoapi diff --git a/setup.py b/setup.py index 7f1a176..d747ba3 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,8 @@ from setuptools import setup if __name__ == "__main__": - setup() + setup( + name="floatcsep", + use_scm_version=True, + setup_requires=["setuptools-scm"], + )