From 99d59ccd9fe3e1cdcfb96e70f7b439e1920cba59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Tue, 10 Oct 2023 21:20:09 +0200
Subject: [PATCH] REL: begin new release cycle

- with enhanced tools for releasing and installing caosdb/linkahead
---
 CHANGELOG.md    |  16 ++++
 release.sh      |   3 +-
 setup-caosdb.py | 201 ------------------------------------------------
 setup.py        |  14 +++-
 src/doc/conf.py |   4 +-
 5 files changed, 30 insertions(+), 208 deletions(-)
 delete mode 100755 setup-caosdb.py

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7354b52d..a67bbd86 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [Unreleased] - Date
+
+### Added ###
+
+### Changed ###
+
+### Deprecated ###
+
+### Removed ###
+
+### Fixed ###
+
+### Security ###
+
+### Documentation ###
+
 ## [0.13.0] - 2023-10-10 ##
 
 ### Added ###
diff --git a/release.sh b/release.sh
index a0f9e31c..09c18059 100755
--- a/release.sh
+++ b/release.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 rm -rf dist/ build/ .eggs/
 python setup.py sdist bdist_wheel
-python setup-caosdb.py sdist bdist_wheel
+export PKGNAME=caosdb
+python setup.py sdist bdist_wheel
 python -m twine upload dist/*
diff --git a/setup-caosdb.py b/setup-caosdb.py
deleted file mode 100755
index 801b5f09..00000000
--- a/setup-caosdb.py
+++ /dev/null
@@ -1,201 +0,0 @@
-#!/usr/bin/env python
-# -*- encoding: utf-8 -*-
-#
-#
-"""linkahead"""
-import os
-import subprocess
-import sys
-
-from setuptools import find_packages, setup
-
-########################################################################
-# The following code is largely based on code in numpy
-########################################################################
-#
-# Copyright (c) 2005-2019, NumPy Developers.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#    * Redistributions of source code must retain the above copyright
-#       notice, this list of conditions and the following disclaimer.
-#
-#    * Redistributions in binary form must reproduce the above
-#       copyright notice, this list of conditions and the following
-#       disclaimer in the documentation and/or other materials provided
-#       with the distribution.
-#
-#    * Neither the name of the NumPy Developers nor the names of any
-#       contributors may be used to endorse or promote products derived
-#       from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-########################################################################
-
-ISRELEASED = False
-MAJOR = 0
-MINOR = 12
-MICRO = 1
-# Do not tag as pre-release until this commit
-# https://github.com/pypa/packaging/pull/515
-# has made it into a release. Probably we should wait for pypa/packaging>=21.4
-# https://github.com/pypa/packaging/releases
-PRE = ""  # "dev"  # e.g. rc0, alpha.1, 0.beta-23
-
-if PRE:
-    VERSION = "{}.{}.{}-{}".format(MAJOR, MINOR, MICRO, PRE)
-else:
-    VERSION = "{}.{}.{}".format(MAJOR, MINOR, MICRO)
-
-
-# Return the git revision as a string
-def git_version():
-    def _minimal_ext_cmd(cmd):
-        # construct minimal environment
-        env = {}
-
-        for k in ['SYSTEMROOT', 'PATH', 'HOME']:
-            v = os.environ.get(k)
-
-            if v is not None:
-                env[k] = v
-        # LANGUAGE is used on win32
-        env['LANGUAGE'] = 'C'
-        env['LANG'] = 'C'
-        env['LC_ALL'] = 'C'
-        out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
-
-        return out
-
-    try:
-        out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
-        GIT_REVISION = out.strip().decode('ascii')
-    except (subprocess.SubprocessError, OSError):
-        GIT_REVISION = "Unknown"
-
-    return GIT_REVISION
-
-
-def get_version_info():
-    # Adding the git rev number needs to be done inside write_version_py(),
-    # otherwise the import of linkahead.version messes up the build under
-    # Python 3.
-    FULLVERSION = VERSION
-
-    # Magic which is only really needed in the pipelines. Therefore: a lot of dark pipeline magic.
-    if os.path.exists('.git'):
-        GIT_REVISION = git_version()
-    elif os.path.exists('linkahead_pylib_commit'):
-        with open('linkahead_pylib_commit', 'r') as f:
-            GIT_REVISION = f.read().strip()
-    elif os.path.exists('src/linkahead/version.py'):
-        # must be a source distribution, use existing version file
-        try:
-            from linkahead.version import git_revision as GIT_REVISION
-        except ImportError:
-            raise ImportError("Unable to import git_revision. Try removing "
-                              "src/linkahead/version.py and the build directory "
-                              "before building.")
-    else:
-        GIT_REVISION = "Unknown"
-
-    if not ISRELEASED:
-        FULLVERSION += '.dev0+' + GIT_REVISION[:7]
-
-    return FULLVERSION, GIT_REVISION
-
-
-def write_version_py(filename='src/linkahead/version.py'):
-    cnt = """
-# THIS FILE IS GENERATED FROM linkahead SETUP.PY
-#
-short_version = '%(version)s'
-version = '%(version)s'
-full_version = '%(full_version)s'
-git_revision = '%(git_revision)s'
-release = %(isrelease)s
-
-if not release:
-    version = full_version
-"""
-    FULLVERSION, GIT_REVISION = get_version_info()
-
-    a = open(filename, 'w')
-    try:
-        a.write(cnt % {'version': VERSION,
-                       'full_version': FULLVERSION,
-                       'git_revision': GIT_REVISION,
-                       'isrelease': str(ISRELEASED)})
-    finally:
-        a.close()
-
-
-def setup_package():
-    # load README
-    with open("README.md", "r") as fh:
-        long_description = fh.read()
-
-    src_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "src")
-    sys.path.insert(0, src_path)
-
-    # Rewrite the version file everytime
-    write_version_py()
-
-    metadata = dict(
-        name='caosdb',
-        version=get_version_info()[0],
-        description='Deprecated! Please install linkahead.',
-        long_description=long_description,
-        long_description_content_type="text/markdown",
-        author='Timm Fitschen',
-        author_email='t.fitschen@indiscale.com',
-        url='https://www.linkahead.org',
-        license="AGPLv3+",
-        classifiers=[
-            "Programming Language :: Python :: 3",
-            "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
-            "Operating System :: OS Independent",
-            "Topic :: Database",
-            "Topic :: Scientific/Engineering :: Information Analysis",
-        ],
-        packages=find_packages('src'),
-        python_requires='>=3.7',
-        package_dir={'': 'src'},
-        install_requires=['lxml>=4.6.3',
-                          "requests[socks]>=2.26",
-                          "python-dateutil>=2.8.2",
-                          'PyYAML>=5.4.1',
-                          'future',
-                          ],
-        extras_require={'keyring': ['keyring>=13.0.0'],
-                        'jsonschema': ['jsonschema>=4.4.0']},
-        setup_requires=["pytest-runner>=2.0,<3dev"],
-        tests_require=["pytest", "pytest-cov", "coverage>=4.4.2",
-                       "jsonschema>=4.4.0"],
-        package_data={
-            'linkahead': ['cert/indiscale.ca.crt', 'schema-pycaosdb-ini.yml'],
-        },
-        scripts=["src/linkahead/utils/linkahead_admin.py"]
-    )
-    try:
-        setup(**metadata)
-    finally:
-        del sys.path[0]
-    return
-
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/setup.py b/setup.py
index ce7cd70a..22042d8e 100755
--- a/setup.py
+++ b/setup.py
@@ -45,10 +45,10 @@ from setuptools import find_packages, setup
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ########################################################################
 
-ISRELEASED = True
+ISRELEASED = False
 MAJOR = 0
 MINOR = 13
-MICRO = 0
+MICRO = 1
 # Do not tag as pre-release until this commit
 # https://github.com/pypa/packaging/pull/515
 # has made it into a release. Probably we should wait for pypa/packaging>=21.4
@@ -154,10 +154,16 @@ def setup_package():
     # Rewrite the version file everytime
     write_version_py()
 
+    if 'PKGNAME' in os.environ and os.environ['PKGNAME'] == 'caosdb':
+        pname = 'caosdb'
+        pdesc = 'Deprecated! Please install linkahead.'
+    else:
+        pname = 'linkahead'
+        pdesc = 'Python Interface for LinkAhead'
     metadata = dict(
-        name='linkahead',
+        name=pname,
         version=get_version_info()[0],
-        description='Python Interface for LinkAhead',
+        description=pdesc,
         long_description=long_description,
         long_description_content_type="text/markdown",
         author='Timm Fitschen',
diff --git a/src/doc/conf.py b/src/doc/conf.py
index 1b70ef07..68f970fd 100644
--- a/src/doc/conf.py
+++ b/src/doc/conf.py
@@ -29,10 +29,10 @@ copyright = '2023, IndiScale GmbH'
 author = 'Daniel Hornung'
 
 # The short X.Y version
-version = '0.13.0'
+version = '0.13.1'
 # The full version, including alpha/beta/rc tags
 # release = '0.5.2-rc2'
-release = '0.13.0'
+release = '0.13.1'
 
 
 # -- General configuration ---------------------------------------------------
-- 
GitLab