diff --git a/etc/__init__.py b/etc/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack_image_manager/main.py b/openstack_image_manager/main.py index 3fee704e..1f73318a 100644 --- a/openstack_image_manager/main.py +++ b/openstack_image_manager/main.py @@ -12,6 +12,7 @@ from typing import Dict, Set import yamale import urllib.parse +import pkgutil from datetime import datetime, date from decimal import Decimal, ROUND_UP @@ -1114,7 +1115,13 @@ def manage_outdated_images(self, managed_images: set) -> list: def validate_yaml_schema(self): """Validate all image.yaml files against the SCS Metadata spec""" - schema = yamale.make_schema("etc/schema.yaml") + try: + # We are a pip package + schema_data = pkgutil.get_data(__name__, "etc/schema.yaml").decode("utf-8") + schema = yamale.make_schema(content=schema_data) + except Exception: + # We are a cloned repo + schema = yamale.make_schema("etc/schema.yaml") try: validation_error_log = [] for file in os.listdir(self.CONF.images): diff --git a/pyproject.toml b/pyproject.toml index 5c9be298..cbcb449b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,12 +30,15 @@ dynamic = ["dependencies", "version"] [tool.mypy] exclude = ["doc"] +[tool.setuptools] +packages = ["openstack_image_manager", "openstack_image_manager.etc"] +package-dir = {"openstack_image_manager.etc" = "etc"} + [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} -[tool.setuptools.packages.find] -where = ["."] -include = ["openstack_image_manager"] +[tool.setuptools.package-data] +"openstack_image_manager.etc" = ["**/*"] [tool.setuptools-git-versioning] enabled = true