diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e5ab6017378648b9a6ed3af91f72b921b17ed90..ccaa4c1f5e7023d9f5e0a705417ca1b1248161e6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,20 @@ # # SPDX-License-Identifier: GPL-3.0-or-later + +# =========================================================== +# Hints +# =========================================================== + +# $PYPI_PKG_NAME +# The variable PYPI_PKG_NAME is used in setup.py to determine +# how to name the tarball package. If not set the package is +# named 'saqc'. + +# $TESTPYPI_TOKEN +# The upload token used for testpypi, set it on the gitlab +# page and enable masking to prevent revealing + # =========================================================== # preparation # =========================================================== @@ -138,6 +152,8 @@ doctest: wheel38: stage: build image: python:3.8 + variables: + PYPI_PKG_NAME: "saqc-dev" script: - pip install wheel - pip wheel . @@ -146,6 +162,8 @@ wheel38: wheel39: stage: build image: python:3.9 + variables: + PYPI_PKG_NAME: "saqc-dev" script: - pip install wheel - pip wheel . @@ -154,6 +172,8 @@ wheel39: wheel310: stage: build image: python:3.10 + variables: + PYPI_PKG_NAME: "saqc-dev" script: - pip install wheel - pip wheel . @@ -162,6 +182,8 @@ wheel310: wheel311: stage: build image: python:3.11 + variables: + PYPI_PKG_NAME: "saqc-dev" script: - pip install wheel - pip wheel . @@ -179,6 +201,24 @@ docs: # Extra Pipeline (run with a successful run of all other jobs on develop) # =========================================================== +upload_testpypi: + stage: deploy + only: + - develop + except: + - schedules + variables: + PYPI_PKG_NAME: "saqc-dev" + TWINE_USERNAME: __token__ + TWINE_PASSWORD: $TESTPYPI_TOKEN + script: + - pip install build twine + - python -m build + - twine check --strict dist/* + - twine upload -r testpypi dist/* + - echo "install latest develop version with (all option flags are necessary):" + - echo "pip install --pre -U -i https://test.pypi.org/simple/ --extra-index-url http://pypi.org/simple saqc-dev`" + # make html docu with sphinx pages: stage: deploy diff --git a/pyproject.toml b/pyproject.toml index 13885dde6f0c2fe7af3d0fadd5503378a43f54c9..6ad7a8f812366ff7baae4d5bda9239af231c1349 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ markers = "slow: marks tests as slow (deselect with '-m \"not slow\"')" [tool.versioneer] VCS = "git" -style = "pep440" +style = "pep440-pre" versionfile_source = "saqc/_version.py" versionfile_build = "saqc/_version.py" tag_prefix = "v" diff --git a/saqc/__init__.py b/saqc/__init__.py index f6e1d7df304d579638f7c578b474290a912e0c94..d2646a84f97aeb8fd00c6ab357cf8e6f76771d9d 100644 --- a/saqc/__init__.py +++ b/saqc/__init__.py @@ -12,3 +12,7 @@ from saqc.core import Flags, DictOfSeries, SaQC from saqc.core.translation import DmpScheme, FloatScheme, PositionalScheme, SimpleScheme from saqc.parsing.reader import fromConfig from saqc.version import __version__ + +from . import _version + +__version__ = _version.get_versions()["version"] diff --git a/saqc/_version.py b/saqc/_version.py index de714903a7de3d74e389fa68799ffffa88413547..fc95f359787de5ad91b92b4fdced0fb6573c78fe 100644 --- a/saqc/_version.py +++ b/saqc/_version.py @@ -52,7 +52,7 @@ def get_config() -> VersioneerConfig: # _version.py cfg = VersioneerConfig() cfg.VCS = "git" - cfg.style = "pep440" + cfg.style = "pep440-pre" cfg.tag_prefix = "v" cfg.parentdir_prefix = "saqc-" cfg.versionfile_source = "saqc/_version.py" diff --git a/setup.py b/setup.py index f8157644095c16c5794bd3bdcd4e74fa60e44e39..b56d0d23d1ae78e460c015438b211bdc5736799b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ # SPDX-FileCopyrightText: 2021 Helmholtz-Zentrum für Umweltforschung GmbH - UFZ # SPDX-License-Identifier: GPL-3.0-or-later +import os import versioneer from setuptools import find_packages, setup @@ -10,10 +11,35 @@ from setuptools import find_packages, setup with open("README.md", "r") as fh: long_description = fh.read() + +name = os.environ.get("PYPI_PKG_NAME", "saqc") +if not name: + raise ValueError("Environment variable PYPI_PKG_NAME must not be an empty string.") + + +v = versioneer.get_versions() +print(f"saqc version: {v}") + +if v["error"]: + raise RuntimeError(v["error"]) + +if v["dirty"]: + raise ValueError( + f"The repository you build is dirty. Please commit changes first {v}." + ) + +if "dev" in v["version"] and name == "saqc": + raise ValueError( + f"An saqc release must have version in the format X.Y.Z, " + f"which requires a git tag on the same commit. Please set " + f"a tag, then build again. {v}" + ) + + setup( - name="saqc", - version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), + name=name, + version=versioneer.get_version(), # keep this line as it is + cmdclass=versioneer.get_cmdclass(), # keep this line as it is author="Bert Palm, David Schaefer, Florian Gransee, Peter Luenenschloss", author_email="david.schaefer@ufz.de", description="A timeseries data quality control and processing tool/framework",