Skip to content

Commit

Permalink
add pyproject.toml, fix main module
Browse files Browse the repository at this point in the history
- since the project doesnt have a standard folder structure, the main
  module needs to have some paths appended so that the imports work
- add the necessary deps to build a distribution package
- this commit also comes with a new push to pypi
  https://pypi.org/project/ocptv-ctam/

Signed-off-by: mimir-d <[email protected]>
  • Loading branch information
mimir-d committed Sep 28, 2023
1 parent fe8569b commit 22d4949
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

*.pyc
/.vscode
/workspace/TestRuns/*
/workspace/*
docs/build/*
/.vs
/bin
/venv
/venv
/env
*.egg-info
/dist
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
graft json_spec
global-exclude *.py[cod]
include docs/*.md
1 change: 1 addition & 0 deletions ctam/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
32 changes: 18 additions & 14 deletions ctam/ctam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import argparse
import os
import sys
import traceback
from pathlib import Path

# until the folder structure gets fixed to a more pip/setuptools oriented format
# we need to manually adjust the path so that running the main script's imports work
sys.path.append(str(Path(__file__).resolve().parent))

from test_hierarchy import TestHierarchy
from test_runner import TestRunner
import traceback


def parse_args():
Expand All @@ -28,13 +34,13 @@ def parse_args():
"-test_seq",
"--testcase_sequence",
help="Runs no of test cases with given sequence",
nargs='+',
nargs="+",
)
parser.add_argument(
"-group_seq",
"--group_sequence",
help="Runs no of groups with given sequence",
nargs='+',
nargs="+",
)
parser.add_argument("-s", "--Suite", help="Run full ACT Suite", action="store_true")

Expand All @@ -45,9 +51,7 @@ def parse_args():
type=str,
)

parser.add_argument(
"-d", "--Discovery", help="Perform System Discovery", action="store_true"
)
parser.add_argument("-d", "--Discovery", help="Perform System Discovery", action="store_true")

parser.add_argument(
"-w",
Expand All @@ -66,14 +70,12 @@ def parse_args():
return parser.parse_args()


if __name__ == "__main__":
def main():
args = parse_args()

try:
# builds hierarchy of test groups and associated test cases
test_hierarchy = TestHierarchy(
os.path.join(os.getcwd(), "tests"), os.path.join(os.getcwd(), "interfaces")
)
test_hierarchy = TestHierarchy(os.path.join(os.getcwd(), "tests"), os.path.join(os.getcwd(), "interfaces"))

if args.list:
test_hierarchy.print_test_groups_test_cases(args.group)
Expand All @@ -91,9 +93,7 @@ def parse_args():
]

missing_files = [
file
for file in required_workspace_files
if not os.path.isfile(os.path.join(args.workspace, file))
file for file in required_workspace_files if not os.path.isfile(os.path.join(args.workspace, file))
]

if missing_files:
Expand Down Expand Up @@ -174,3 +174,7 @@ def parse_args():
exception_details = traceback.format_exc()
print(f"Test Run Failed: {exception_details}")
exit(1)


if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ requests
requests-ntlm
requests-toolbelt
requests-unixsocket
alive_progress>=3.1.4
Sphinx
sphinx-rtd-theme
sphinx_autodoc_typehints
Expand All @@ -35,4 +36,6 @@ sphinxcontrib-htmlhelp
sphinxcontrib-jquery
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
sphinxcontrib-serializinghtml
black>=23.3
bumpver>=2023.1126
67 changes: 67 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ocptv-ctam"
version = "0.0.1"
description = "Compliance Tool for Accelerator Management"
readme = "README.md"
authors = [
{ name = "OCP Test & Validation", email = "[email protected]" },
]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: System :: Hardware",
]
keywords = ["ocp", "ocptv", "accelerator", "compliance"]
dependencies = [
"ocptv",
"prettytable",
"redfish",
"requests",
"requests-ntlm",
"requests-toolbelt",
"requests-unixsocket",
"alive_progress>=3.1.4",
]
requires-python = ">=3.10"

[project.optional-dependencies]
dev = ["black", "bumpver", "isort"]

[project.urls]
"Homepage" = "https://github.com/opencomputeproject/ocp-diag-ctam"
"Bug reports" = "https://github.com/opencomputeproject/ocp-diag-ctam/issues"
"Source" = "https://github.com/opencomputeproject/ocp-diag-ctam"

[project.scripts]
ocptv_ctam = "ocptv_ctam.ctam:main"

[tool.setuptools]
packages = ["ocptv_ctam"]

[tool.setuptools.package-dir]
ocptv_ctam = "ctam"

[tool.bumpver]
current_version = "0.0.1"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "bump version {old_version} -> {new_version}"
commit = true
tag = false
push = false

[tool.bumpver.file_patterns]
"pyproject.toml" = ['^current_version = "{version}"', '^version = "{version}"']
"ctam/__init__.py" = ['^__version__ = "{version}"']

[tool.black]
line-length = 120

[tool.isort]
profile = "black"

0 comments on commit 22d4949

Please sign in to comment.