From 6ec79f8df648175dd789714cc84358893b210087 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 17 Oct 2025 10:46:15 +0200 Subject: [PATCH] Include docs/api-spec.yaml inside the shippable package --- .github/workflows/pypi-release.yml | 2 +- MANIFEST.in | 2 +- setup.py | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index e434e5c2..8d9632c2 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -28,7 +28,7 @@ jobs: test-pypi-package: - name: Test the built 📦 package works basically. + name: Test the built package works basically. runs-on: ubuntu-latest needs: - build diff --git a/MANIFEST.in b/MANIFEST.in index 5868ee05..830be651 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ recursive-include changedetectionio/api * -include docs/api-spec.yaml +recursive-include changedetectionio/docs * recursive-include changedetectionio/blueprint * recursive-include changedetectionio/conditions * recursive-include changedetectionio/content_fetchers * diff --git a/setup.py b/setup.py index 4767e845..31ec3176 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,8 @@ import re import sys from setuptools import setup, find_packages +from setuptools.command.build_py import build_py +import shutil here = os.path.abspath(os.path.dirname(__file__)) @@ -22,6 +24,20 @@ def find_version(*file_paths): raise RuntimeError("Unable to find version string.") +class BuildPyCommand(build_py): + """Custom build command to copy api-spec.yaml to the package.""" + def run(self): + build_py.run(self) + # Ensure the docs directory exists in the build output + docs_dir = os.path.join(self.build_lib, 'changedetectionio', 'docs') + os.makedirs(docs_dir, exist_ok=True) + # Copy api-spec.yaml to the package + shutil.copy( + os.path.join(here, 'docs', 'api-spec.yaml'), + os.path.join(docs_dir, 'api-spec.yaml') + ) + + install_requires = open('requirements.txt').readlines() setup( @@ -37,9 +53,10 @@ setup( scripts=["changedetection.py"], author='dgtlmoon', url='https://changedetection.io', - packages=['changedetectionio'], + packages=find_packages(include=['changedetectionio', 'changedetectionio.*']), include_package_data=True, install_requires=install_requires, + cmdclass={'build_py': BuildPyCommand}, license="Apache License 2.0", python_requires=">= 3.10", classifiers=['Intended Audience :: Customer Service',