diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 38c6e3c..383e214 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -13,13 +13,15 @@ name: Continuous Integration on: push: - branches: + branches: - main - develop + - support-* pull_request: - branches: + branches: - main - develop + - support-* release: types: - published @@ -30,8 +32,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: - - '3.7' + python-version: + - '3.8' - '3.10' steps: @@ -52,7 +54,7 @@ jobs: run: make clean - name: Run tests run: make PYTHON3=python check - + # Build the binary wheel as well as the source tar - name: Build Objects run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c952e8e..a65fd04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.12.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort name: isort (python) diff --git a/case_utils/__init__.py b/case_utils/__init__.py index be9c0fc..e967344 100644 --- a/case_utils/__init__.py +++ b/case_utils/__init__.py @@ -11,6 +11,6 @@ # # We would appreciate acknowledgement if the software is used. -__version__ = "0.6.0" +__version__ = "0.6.1" from . import local_uuid # noqa: F401 diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index e131b2f..2eb4f95 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -39,6 +39,7 @@ DEFAULT_PREFIX = "http://example.org/kb/" + # Shortcut syntax for defining an immutable named tuple is noted here: # https://docs.python.org/3/library/typing.html#typing.NamedTuple # via the "See also" box here: https://docs.python.org/3/library/collections.html#collections.namedtuple diff --git a/case_utils/case_sparql_construct/__init__.py b/case_utils/case_sparql_construct/__init__.py index eb9610f..a96f06b 100644 --- a/case_utils/case_sparql_construct/__init__.py +++ b/case_utils/case_sparql_construct/__init__.py @@ -98,7 +98,7 @@ def main() -> None: construct_query_result = in_graph.query(construct_query_object) _logger.debug("type(construct_query_result) = %r." % type(construct_query_result)) _logger.debug("len(construct_query_result) = %d." % len(construct_query_result)) - for (row_no, row) in enumerate(construct_query_result): + for row_no, row in enumerate(construct_query_result): if row_no == 0: _logger.debug("row[0] = %r." % (row,)) out_graph.add(row) diff --git a/case_utils/case_sparql_select/__init__.py b/case_utils/case_sparql_select/__init__.py index a2023bf..87e2b50 100644 --- a/case_utils/case_sparql_select/__init__.py +++ b/case_utils/case_sparql_select/__init__.py @@ -110,10 +110,10 @@ def main() -> None: select_query_object = rdflib.plugins.sparql.prepareQuery( select_query_text, initNs=nsdict ) - for (row_no, row) in enumerate(graph.query(select_query_object)): + for row_no, row in enumerate(graph.query(select_query_object)): tally = row_no + 1 record = [] - for (column_no, column) in enumerate(row): + for column_no, column in enumerate(row): if column is None: column_value = "" elif ( diff --git a/case_utils/local_uuid.py b/case_utils/local_uuid.py index f526191..3259214 100644 --- a/case_utils/local_uuid.py +++ b/case_utils/local_uuid.py @@ -15,7 +15,7 @@ This library is a wrapper for uuid, provided to generate repeatable UUIDs if requested. """ -__version__ = "0.3.0" +__version__ = "0.3.1" import logging import os @@ -32,9 +32,25 @@ _logger = logging.getLogger(pathlib.Path(__file__).name) +def _is_relative_to(p1: pathlib.Path, p2: pathlib.Path) -> bool: + """ + This function provides pathlib.is_relative_to to Pythons before 3.9. After the End of Life of Python 3.8, this function can be removed. + """ + if sys.version_info < (3, 9): + try: + _ = p1.relative_to(p2) + return True + except ValueError: + return False + else: + return p1.is_relative_to(p2) + + def configure() -> None: global DEMO_UUID_BASE + # _logger.debug("sys.argv = %r.", sys.argv) + if os.getenv("DEMO_UUID_REQUESTING_NONRANDOM") == "NONRANDOM_REQUESTED": warnings.warn( "Environment variable DEMO_UUID_REQUESTING_NONRANDOM is deprecated. See case_utils.local_uuid.demo_uuid for usage notes on its replacement, CASE_DEMO_NONRANDOM_UUID_BASE. Proceeding with random UUIDs.", @@ -82,18 +98,23 @@ def configure() -> None: demo_uuid_base_parts.append(sys.argv[0]) else: command_original_path = pathlib.Path(sys.argv[0]) + # _logger.debug("command_original_path = %r.", command_original_path) command_resolved_path = command_original_path.resolve() + # _logger.debug("command_resolved_path = %r.", command_resolved_path) + + # The command could be a command embedded in a virtual + # environment, or it could be a script external to any virtual + # environment. venv_original_path = pathlib.Path(env_venv_name) venv_resolved_path = venv_original_path.resolve() - try: + if _is_relative_to(command_resolved_path, venv_resolved_path): command_relative_path = command_resolved_path.relative_to( venv_resolved_path ) # _logger.debug("command_relative_path = %r.", command_relative_path) demo_uuid_base_parts.append(str(command_relative_path)) - except ValueError: - # _logger.debug("Command path is not relative to virtual environment path.") - demo_uuid_base_parts.append(str(command_resolved_path)) + else: + demo_uuid_base_parts.append(str(command_original_path)) if len(sys.argv) > 1: # Component: Arguments of argument vector. diff --git a/setup.cfg b/setup.cfg index ecbe655..4f7050b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,11 +21,11 @@ include_package_data = true install_requires = pandas pyshacl - rdflib >= 6.0.2 + rdflib >= 6.0.2, < 6.3.0 requests tabulate packages = find: -python_requires = >=3.7 +python_requires = >=3.8 [options.entry_points] console_scripts = diff --git a/tests/case_utils/case_validate/uco_test_examples/Makefile b/tests/case_utils/case_validate/uco_test_examples/Makefile index 271fca7..948cb4f 100644 --- a/tests/case_utils/case_validate/uco_test_examples/Makefile +++ b/tests/case_utils/case_validate/uco_test_examples/Makefile @@ -15,9 +15,7 @@ SHELL := /bin/bash top_srcdir := $(shell cd ../../../.. ; pwd) -case_srcdir := $(top_srcdir)/dependencies/CASE - -uco_srcdir := $(case_srcdir)/dependencies/UCO +uco_srcdir := $(top_srcdir)/dependencies/CASE/dependencies/UCO examples_srcdir := $(uco_srcdir)/tests/examples