diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..342d598 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = ["setuptools>=72", "wheel", "setuptools_scm[toml]>=8"] + +[project] +name = "etos_test_runner" +dynamic = ["version"] +description = "ETOS Test 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 = [ + "etos_lib==4.3.6", + "cryptography>=42.0.4,<43.0.0", + "packageurl-python==0.9.1", + "jsontas==1.3.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-test-runner" +Repository = "https://github.com/eiffel-community/etos-test-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_test_runner --cov-report term-missing --verbose" +norecursedirs = ["dist", "build", ".tox"] +testpaths = ["tests"] + +[tool.setuptools.package-data] +"*" = ["*.sh"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 898c5b3..0000000 --- a/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 -# -packageurl-python==0.9.1 -cryptography>=42.0.4,<43.0.0 -etos_lib==3.2.2 -jsontas==1.3.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9d9b957..0000000 --- a/setup.cfg +++ /dev/null @@ -1,86 +0,0 @@ -[metadata] -name = etos_test_runner -description = ETOS Test Runner -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-test-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 = - etos_lib==4.3.6 - cryptography>=42.0.4,<43.0.0 - packageurl-python==0.9.1 - jsontas==1.3.0 - -[options.package_data] -* = *.sh - -[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_test_runner --cov-report term-missing - --verbose -norecursedirs = - dist - build - .tox -testpaths = tests - -[aliases] -dists = bdist_wheel - -[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_test_runner diff --git a/setup.py b/setup.py index 2b686a9..0a90675 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,42 @@ # -*- coding: utf-8 -*- -"""Setup file for etos_test_runner. +"""Setup file for etos-test-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/src/etos_test_runner/lib/executor.py b/src/etos_test_runner/lib/executor.py index 2fa6f2e..216b661 100644 --- a/src/etos_test_runner/lib/executor.py +++ b/src/etos_test_runner/lib/executor.py @@ -249,7 +249,7 @@ def _finished(self, test_name, result): def _call( self, cmd, shell=False, env=None, executable=None, output=None, wait_output=True - ): # pylint:disable=too-many-arguments + ): # pylint:disable=too-many-positional-arguments,too-many-arguments """Call a system command. :param cmd: Command to run. @@ -280,7 +280,7 @@ def _call( def _iterable_call( self, cmd, shell=False, env=None, executable=None, output=None, wait_output=True - ): # pylint:disable=too-many-arguments + ): # pylint:disable=too-many-positional-arguments,too-many-arguments """Call a system command and yield the output. :param cmd: Command to run. diff --git a/src/etos_test_runner/lib/log_area.py b/src/etos_test_runner/lib/log_area.py index ece6f29..f80acf8 100644 --- a/src/etos_test_runner/lib/log_area.py +++ b/src/etos_test_runner/lib/log_area.py @@ -244,7 +244,7 @@ def upload_artifacts(self, artifacts): def __upload( self, context, log, name, main_suite_id, sub_suite_id - ): # pylint:disable=too-many-arguments + ): # pylint:disable=too-many-positional-arguments,too-many-arguments """Upload log to a storage location. :param context: Context for the http request. @@ -303,7 +303,7 @@ def __upload( def __retry_upload( self, verb, url, file_contents, timeout=None, as_json=True, **requests_kwargs - ): # pylint:disable=too-many-arguments + ): # pylint:disable=too-many-positional-arguments,too-many-arguments """Attempt to connect to url for x time. :param verb: Which HTTP verb to use. GET, PUT, POST