diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 49f65ab..53c4092 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: - name: Install Tox run: pip install tox - name: Upgrade setuptools - run: pip install -U setuptools + run: pip install -U setuptools setuptools_scm[toml] - name: Run Tox on suite runner run: tox working-directory: ./projects/etos_suite_runner diff --git a/Dockerfile b/Dockerfile index 3d731fb..4b1bcc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.9-bookworm AS build COPY . /src WORKDIR /src/projects/etos_suite_runner -RUN python3 setup.py bdist_wheel +RUN pip install --no-cache-dir build==1.2.2 && python3 -m build FROM python:3.9-slim-bookworm diff --git a/Dockerfile.log_listener b/Dockerfile.log_listener index 6e3edb8..332935c 100644 --- a/Dockerfile.log_listener +++ b/Dockerfile.log_listener @@ -2,7 +2,7 @@ FROM python:3.9-bookworm AS build COPY . /src WORKDIR /src/projects/log_listener -RUN python3 setup.py bdist_wheel +RUN pip install --no-cache-dir build==1.2.2 && python3 -m build FROM python:3.9-slim-bookworm diff --git a/projects/etos_suite_runner/pyproject.toml b/projects/etos_suite_runner/pyproject.toml new file mode 100644 index 0000000..031f807 --- /dev/null +++ b/projects/etos_suite_runner/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +requires = ["setuptools>72", "wheel", "setuptools_scm[toml]>=8"] + +[project] +name = "etos_suite_runner" +dynamic = ["version"] +description = "ETOS Suite Runner" +authors = [{name = "Tobias Persson", email = "tobias.persson@axis.com"}] +license = { text = "Apache License, Version 2.0" } +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License" +] +dependencies = [ + "packageurl-python~=0.11", + "cryptography>=42.0.4,<43.0.0", + "etos_lib==4.3.6", + "etos_environment_provider==5.1.1", + "opentelemetry-api~=1.21", + "opentelemetry-exporter-otlp~=1.21", + "opentelemetry-sdk~=1.21", +] + +[options] +zip_safe = false +include_package_data = true +python_requires = ">=3.4" + +[options.packages.find] +where = "src" +exclude = ["tests"] + +[project.urls] +Documentation = "https://etos.readthedocs.io/" +Homepage = "https://github.com/eiffel-community/etos-suite-runner" +Repository = "https://github.com/eiffel-community/etos-suite-runner" + +[project.scripts] + +[project.optional-dependencies] +testing = ["pytest", "pytest-cov"] + +[test] +extras = true + +[tool.build_sphinx] +source_dir = "docs" +build_dir = "build/sphinx" + +[tool.devpi.upload] +no-vcs = 1 +formats = "bdist_wheel" + +[tool.flake8] +exclude = [".tox", "build", "dist", ".eggs", "docs/conf.py"] + +[tool.pytest.ini_options] +addopts = "--cov etos_suite_runner --cov-report term-missing --verbose" +norecursedirs = ["dist", "build", ".tox"] +testpaths = ["tests"] + +[tool.setuptools_scm] +root = "../.." \ No newline at end of file diff --git a/projects/etos_suite_runner/requirements.txt b/projects/etos_suite_runner/requirements.txt deleted file mode 100644 index 6627794..0000000 --- a/projects/etos_suite_runner/requirements.txt +++ /dev/null @@ -1,25 +0,0 @@ -# ============================================================================= -# DEPRECATION WARNING: -# -# The file `requirements.txt` does not influence the package dependencies and -# will not be automatically created in the next version of PyScaffold (v4.x). -# -# Please have look at the docs for better alternatives -# (`Dependency Management` section). -# ============================================================================= -# -# Add your pinned requirements so that they can be easily installed with: -# pip install -r requirements.txt -# Remember to also add them in setup.cfg but unpinned. -# Example: -# numpy==1.13.3 -# scipy==1.0 -# -PyScaffold==3.2.3 -packageurl-python~=0.11 -cryptography>=42.0.4,<43.0.0 -etos_lib==4.3.6 -etos_environment_provider==5.1.1 -opentelemetry-api~=1.21 -opentelemetry-exporter-otlp~=1.21 -opentelemetry-sdk~=1.21 diff --git a/projects/etos_suite_runner/setup.cfg b/projects/etos_suite_runner/setup.cfg deleted file mode 100644 index cb74ce0..0000000 --- a/projects/etos_suite_runner/setup.cfg +++ /dev/null @@ -1,91 +0,0 @@ -[metadata] -name = etos_suite_runner -description = Tool for running test suites within the eiffel event system. -author = Tobias Persson -author-email = tobias.persson@axis.com -license = Apache License, Version 2.0 -long-description = file: README.rst -long-description-content-type = text/x-rst; charset=UTF-8 -url = https://github.com/eiffel-community/etos-suite-runner -project-urls = - Documentation = https://etos.readthedocs.io/ -platforms = Linux -classifiers = - Development Status :: 4 - Beta - Programming Language :: Python :: 3 - License:: OSI Approved :: Apache Software License - -[options] -zip_safe = False -packages = find: -include_package_data = True -package_dir = - =src -# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD! -setup_requires = pyscaffold>=3.2a0,<3.3a0 - -install_requires = - PyScaffold==3.2.3 - packageurl-python~=0.11 - cryptography>=42.0.4,<43.0.0 - etos_lib==4.3.6 - etos_environment_provider==5.1.1 - opentelemetry-api~=1.21 - opentelemetry-exporter-otlp~=1.21 - opentelemetry-sdk~=1.21 - -python_requires = >=3.4 - -[options.packages.find] -where = src -exclude = - tests - -[options.extras_require] -testing = - pytest - pytest-cov - -[options.entry_points] - -[test] -extras = True - -[tool:pytest] -addopts = - --cov etos_suite_runner --cov-report term-missing - --verbose - -s -norecursedirs = - dist - build - .tox -testpaths = tests - -[aliases] -docs = build_sphinx - -[bdist_wheel] -universal = 1 - -[build_sphinx] -source_dir = docs -build_dir = build/sphinx - -[devpi:upload] -no-vcs = 1 -formats = bdist_wheel - -[flake8] -exclude = - .tox - build - dist - .eggs - docs/conf.py - -[pyscaffold] -# PyScaffold's parameters when the project was created. -# This will be used when updating. Do not change! -version = 3.2.3 -package = etos_suite_runner diff --git a/projects/etos_suite_runner/setup.py b/projects/etos_suite_runner/setup.py index bb27894..0fc3b87 100644 --- a/projects/etos_suite_runner/setup.py +++ b/projects/etos_suite_runner/setup.py @@ -1,24 +1,42 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -"""Setup file for etos_suite_runner. +"""Setup file for etos-suite-runner.""" +from setuptools import setup +from setuptools_scm.version import get_local_dirty_tag -Use setup.cfg to configure your project. -This file was generated with PyScaffold 3.2.3. -PyScaffold helps you to put up the scaffold of your new Python project. -Learn more under: https://pyscaffold.org/ -""" -import sys +def version_scheme(version) -> str: + """Get version component for the current commit. -from pkg_resources import VersionConflict, require -from setuptools import setup + Used by setuptools_scm. + """ + if version.tag and version.distance == 0: + # If the current commit has a tag, use the tag as version, regardless of branch. + # Note: Github CI creates releases from detached HEAD, not from a particular branch. + return f"{version.tag}" + elif version.branch == "main" and version.tag and version.distance > 0: + # For untagged commits on the release branch always add a distance like ".post3" + return f"{version.tag}.post{version.distance}" + else: + # For non-release branches, mark the version as dev and distance: + return f"{version.tag}.dev{version.distance}" + + +def local_scheme(version) -> str: + """Get local version component for the current Git commit. + + Used by setuptools_scm. + """ + # If current version is dirty, always add dirty suffix, regardless of branch. + dirty_tag = get_local_dirty_tag(version) if version.dirty else "" + if dirty_tag: + return f"{dirty_tag}.{version.node}" -try: - require("setuptools>=38.3") -except VersionConflict: - print("Error: version of setuptools is too old (<38.3)!") - sys.exit(1) + if version.distance == 0: + # If the current commit has a tag, do not add a local component, regardless of branch. + return "" + # For all other cases, always add the git reference (like "g7839952") + return f"+{version.node}" if __name__ == "__main__": - setup(use_pyscaffold=True) + setup(use_scm_version={"local_scheme": local_scheme, "version_scheme": version_scheme}) diff --git a/projects/etos_suite_runner/test-requirements.txt b/projects/etos_suite_runner/test-requirements.txt index 820b2fe..122105a 100644 --- a/projects/etos_suite_runner/test-requirements.txt +++ b/projects/etos_suite_runner/test-requirements.txt @@ -2,3 +2,5 @@ mock pytest pytest-cov mongomock +setuptools>=72 +setuptools_scm~=8.0 \ No newline at end of file diff --git a/projects/log_listener/pyproject.toml b/projects/log_listener/pyproject.toml new file mode 100644 index 0000000..fb3bbb5 --- /dev/null +++ b/projects/log_listener/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["setuptools>=72", "wheel", "setuptools_scm[toml]>=8"] + +[project] +name = "etos_log_listener" +dynamic = ["version"] +description = "Tool for listening to logs within ETOS." +authors = [{name = "Tobias Persson", email = "tobias.persson@axis.com"}] +license = { text = "Apache License, Version 2.0" } +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License" +] +dependencies = [ + "eiffellib[rabbitmq]==2.4.1", + "fastapi==0.109.1", + "uvicorn==0.22.0", +] + +[options] +zip_safe = false +include_package_data = true +python_requires = ">=3.4" + +[options.packages.find] +where = "src" +exclude = ["tests"] + +[project.urls] +Documentation = "https://etos.readthedocs.io/" +Homepage = "https://github.com/eiffel-community/etos-suite-runner" +Repository = "https://github.com/eiffel-community/etos-suite-runner" + +[project.scripts] + +[project.optional-dependencies] +testing = ["pytest", "pytest-cov"] + +[test] +extras = true + +[tool.build_sphinx] +source_dir = "docs" +build_dir = "build/sphinx" + +[tool.devpi.upload] +no-vcs = 1 +formats = "bdist_wheel" + +[tool.flake8] +exclude = [".tox", "build", "dist", ".eggs", "docs/conf.py"] + +[tool.pytest.ini_options] +addopts = "--cov etos_suite_runner --cov-report term-missing --verbose" +norecursedirs = ["dist", "build", ".tox"] +testpaths = ["tests"] + +[tool.setuptools_scm] +root = "../.." \ No newline at end of file diff --git a/projects/log_listener/requirements.txt b/projects/log_listener/requirements.txt deleted file mode 100644 index 064fcfa..0000000 --- a/projects/log_listener/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -# ============================================================================= -# DEPRECATION WARNING: -# -# The file `requirements.txt` does not influence the package dependencies and -# will not be automatically created in the next version of PyScaffold (v4.x). -# -# Please have look at the docs for better alternatives -# (`Dependency Management` section). -# ============================================================================= -# -# Add your pinned requirements so that they can be easily installed with: -# pip install -r requirements.txt -# Remember to also add them in setup.cfg but unpinned. -# Example: -# numpy==1.13.3 -# scipy==1.0 -# -PyScaffold==3.2.3 -eiffellib[rabbitmq]==2.4.1 -fastapi==0.109.1 -uvicorn==0.22.0 diff --git a/projects/log_listener/setup.cfg b/projects/log_listener/setup.cfg deleted file mode 100644 index fca48ba..0000000 --- a/projects/log_listener/setup.cfg +++ /dev/null @@ -1,87 +0,0 @@ -[metadata] -name = etos_log_listener -description = Tool for listening to logs within ETOS. -author = Tobias Persson -author-email = tobias.persson@axis.com -license = Apache License, Version 2.0 -long-description = file: README.rst -long-description-content-type = text/x-rst; charset=UTF-8 -url = https://github.com/eiffel-community/etos-suite-runner -project-urls = - Documentation = https://etos.readthedocs.io/ -platforms = Linux -classifiers = - Development Status :: 4 - Beta - Programming Language :: Python :: 3 - License:: OSI Approved :: Apache Software License - -[options] -zip_safe = False -packages = find: -include_package_data = True -package_dir = - =src -# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD! -setup_requires = pyscaffold>=3.2a0,<3.3a0 - -install_requires = - PyScaffold==3.2.3 - eiffellib[rabbitmq]==2.4.1 - fastapi==0.109.1 - uvicorn==0.22.0 - -python_requires = >=3.4 - -[options.packages.find] -where = src -exclude = - tests - -[options.extras_require] -testing = - pytest - pytest-cov - -[options.entry_points] - -[test] -extras = True - -[tool:pytest] -addopts = - --cov etos_suite_runner --cov-report term-missing - --verbose - -s -norecursedirs = - dist - build - .tox -testpaths = tests - -[aliases] -docs = build_sphinx - -[bdist_wheel] -universal = 1 - -[build_sphinx] -source_dir = docs -build_dir = build/sphinx - -[devpi:upload] -no-vcs = 1 -formats = bdist_wheel - -[flake8] -exclude = - .tox - build - dist - .eggs - docs/conf.py - -[pyscaffold] -# PyScaffold's parameters when the project was created. -# This will be used when updating. Do not change! -version = 3.2.3 -package = log_listener diff --git a/projects/log_listener/setup.py b/projects/log_listener/setup.py index bb27894..0fc3b87 100644 --- a/projects/log_listener/setup.py +++ b/projects/log_listener/setup.py @@ -1,24 +1,42 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -"""Setup file for etos_suite_runner. +"""Setup file for etos-suite-runner.""" +from setuptools import setup +from setuptools_scm.version import get_local_dirty_tag -Use setup.cfg to configure your project. -This file was generated with PyScaffold 3.2.3. -PyScaffold helps you to put up the scaffold of your new Python project. -Learn more under: https://pyscaffold.org/ -""" -import sys +def version_scheme(version) -> str: + """Get version component for the current commit. -from pkg_resources import VersionConflict, require -from setuptools import setup + Used by setuptools_scm. + """ + if version.tag and version.distance == 0: + # If the current commit has a tag, use the tag as version, regardless of branch. + # Note: Github CI creates releases from detached HEAD, not from a particular branch. + return f"{version.tag}" + elif version.branch == "main" and version.tag and version.distance > 0: + # For untagged commits on the release branch always add a distance like ".post3" + return f"{version.tag}.post{version.distance}" + else: + # For non-release branches, mark the version as dev and distance: + return f"{version.tag}.dev{version.distance}" + + +def local_scheme(version) -> str: + """Get local version component for the current Git commit. + + Used by setuptools_scm. + """ + # If current version is dirty, always add dirty suffix, regardless of branch. + dirty_tag = get_local_dirty_tag(version) if version.dirty else "" + if dirty_tag: + return f"{dirty_tag}.{version.node}" -try: - require("setuptools>=38.3") -except VersionConflict: - print("Error: version of setuptools is too old (<38.3)!") - sys.exit(1) + if version.distance == 0: + # If the current commit has a tag, do not add a local component, regardless of branch. + return "" + # For all other cases, always add the git reference (like "g7839952") + return f"+{version.node}" if __name__ == "__main__": - setup(use_pyscaffold=True) + setup(use_scm_version={"local_scheme": local_scheme, "version_scheme": version_scheme})