diff --git a/cli/pyproject.toml b/cli/pyproject.toml new file mode 100644 index 0000000..e544d71 --- /dev/null +++ b/cli/pyproject.toml @@ -0,0 +1,74 @@ +[build-system] +requires = ["setuptools>=72", "wheel", "setuptools_scm[toml]>=8"] + +[project] +name = "etos_client" +dynamic = ["version"] +description = "Test suite execution client for ETOS." +authors = [{name = "Tobias Persson", email = "tobias.persson@axis.com"}] +license = { text = "Apache License, Version 2.0" } +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License" +] +dependencies = [ + "etos_lib==4.0.0", + "docopt~=0.6", + "pydantic~=2.6", + "jmespath~=1.0" +] + +[project.optional-dependencies] +testing = ["pytest", "pytest-cov"] + +[project.urls] +Documentation = "https://etos.readthedocs.io/" +Homepage = "https://github.com/eiffel-community/etos" +Repository = "https://github.com/eiffel-community/etos" + +[options] +zip_safe = false +include_package_data = true +python_requires = ">=3.4" + +[options.packages.find] +where = "src" +exclude = ["tests"] + +[tool.setuptools.package-dir] +"" = "src" + +[project.scripts] +etos_client = "etos_client.__main__:run" +etosctl = "etosctl.__main__:run" + +[test] +extras = true + +[tool.pytest.ini_options] +addopts = "--cov etos_cleint --cov-report term-missing --verbose" +norecursedirs = ["dist", "build", ".tox"] +testpaths = ["tests"] + +[aliases] +dists = "bdist_wheel" + +[bdist_wheel] +universal = 1 + +[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.setuptools_scm] +version_scheme = "setup:version_scheme" +local_scheme = "setup:local_scheme" +root = ".." \ No newline at end of file diff --git a/cli/setup.cfg b/cli/setup.cfg deleted file mode 100644 index ed23153..0000000 --- a/cli/setup.cfg +++ /dev/null @@ -1,97 +0,0 @@ -# This file is used to configure your project. -# Read more about the various options under: -# http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files - -[metadata] -name = etos_client -description = Test suite execution client for 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-starter -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 -# Add here dependencies of your project (semicolon/line-separated), e.g. -install_requires = - etos_lib==4.0.0 - docopt~=0.6 - pydantic~=2.6 - jmespath~=1.0 - -# Require a specific Python version, e.g. Python 2.7 or >= 3.4 -python_requires = >=3.4 - -[options.packages.find] -where = src -exclude = - tests - -[options.extras_require] -testing = - pytest - pytest-cov - -[options.entry_points] -# Add here console scripts like: -console_scripts = - etos_client = etos_client.__main__:run - etosctl = etosctl.__main__:run - -[test] -extras = True - -[tool:pytest] -addopts = - --cov etos_client --cov-report term-missing - --verbose -norecursedirs = - dist - build - .tox -testpaths = tests - -[aliases] -dists = bdist_wheel - -[bdist_wheel] -# Use this option if your package is pure-python -universal = 1 - -[build_sphinx] -source_dir = docs -build_dir = build/sphinx - -[devpi:upload] -no-vcs = 1 -formats = bdist_wheel - -[flake8] -# Some sane defaults for the code style checker 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_client diff --git a/cli/setup.py b/cli/setup.py index b45d671..cb69998 100644 --- a/cli/setup.py +++ b/cli/setup.py @@ -1,23 +1,42 @@ # -*- coding: utf-8 -*- -"""Setup file for etos_client. +"""Setup file for ETOS Client.""" +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={"root": "..", "relative_to": __file__})