diff --git a/.github/actions/generate_dependabot.py b/.github/actions/generate_dependabot.py new file mode 100755 index 00000000000..91ad8459490 --- /dev/null +++ b/.github/actions/generate_dependabot.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +import os +import glob +import itertools +import yaml + +def find_repo_root(start_path): + """ + Find the repository root by looking for common indicators + like .git directory or spksrc directory + """ + current_path = os.path.abspath(start_path) + + while current_path != os.path.dirname(current_path): # Not at filesystem root + # Check for .git directory (most reliable) + if os.path.isdir(os.path.join(current_path, '.git')): + return current_path + + # Check for spksrc directory (specific to your project) + if os.path.isdir(os.path.join(current_path, 'spksrc')): + return current_path + + # Check for common project files + for indicator in ['.gitignore', 'README.md', 'LICENSE']: + if os.path.isfile(os.path.join(current_path, indicator)): + # Verify spksrc exists at this level + if os.path.isdir(os.path.join(current_path, 'spksrc')): + return current_path + + current_path = os.path.dirname(current_path) + + raise RuntimeError("Could not find repository root") + +# Find absolute directory path of the script +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Find the repository root dynamically +repo_root = find_repo_root(script_dir) + +# The repository root IS the spksrc root (no subdirectory needed) +spksrc_root = repo_root + +# Debug information +# print(f"πŸ” Script location: {script_dir}") +# print(f"πŸ” Repository root: {repo_root}") +# print(f"πŸ” spksrc root: {spksrc_root}") + +# Verify key directories exist +# test_dirs = ["spk", "native"] +# for test_dir in test_dirs: +# test_path = os.path.join(spksrc_root, test_dir) +# if os.path.isdir(test_path): +# print(f"βœ… Found directory: {test_path}") +# else: +# print(f"❌ Missing directory: {test_path}") + +# Configuration +IGNORED_PACKAGES = ["pip", "Cython", "msgpack"] + +globs = [ + "spk/python*/crossenv/requirements-default.txt", + "spk/python*/src/requirements-abi3.txt", + "spk/python*/src/requirements-crossenv.txt", + "spk/python*/src/requirements-pure.txt", + "native/python*/src/requirements.txt" +] + +# Test glob patterns to see what they find +# print(f"\nπŸ” Testing glob patterns:") +# for pattern in globs: +# full_pattern = os.path.join(spksrc_root, pattern) +# matches = glob.glob(full_pattern) +# print(f" Pattern: {pattern}") +# print(f" Full path: {full_pattern}") +# print(f" Matches: {len(matches)}") +# if matches: +# for match in matches[:3]: # Show first 3 matches +# print(f" - {match}") +# if len(matches) > 3: +# print(f" ... and {len(matches) - 3} more") +# print() + +# Iterate on each glob patterns based on spksrc_root +paths = itertools.chain.from_iterable( + glob.glob(os.path.join(spksrc_root, pattern)) for pattern in globs +) + +updates = [] +# found_files = [] # For debugging + +for req_file in paths: + # found_files.append(req_file) + filename = os.path.basename(req_file) + + # Debug: show path calculation + # print(f"πŸ” Processing: {req_file}") + # print(f" Relative to repo_root: {os.path.relpath(req_file, repo_root)}") + # print(f" Directory (absolute): {os.path.dirname(req_file)}") + # print(f" Filename: {filename}") + + # CrΓ©er la liste des packages Γ  ignorer + ignore_list = [] + for package in IGNORED_PACKAGES: + ignore_list.append({ + "dependency-name": package, + "update-types": ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"] + }) + + updates.append({ + "package-ecosystem": "pip", + "directory": os.path.dirname(req_file), + "requirements-file": filename, + "schedule": { + "interval": "weekly" + }, + "groups": { + "all-python-deps": { + "patterns": ["*"] + } + }, + "ignore": ignore_list + }) + +# Debug information +# print(f"πŸ” Found {len(found_files)} requirements files:") +# for file in found_files: +# print(f" - {file}") + +# print(f"πŸ” Generated {len(updates)} dependabot updates") + +dependabot_config = { + "version": 2, + "updates": updates +} + +# Relative output to .github/dependabot.yml +output_path = os.path.join(repo_root, ".github", "dependabot.yml") +os.makedirs(os.path.dirname(output_path), exist_ok=True) + +# Write the configuration +with open(output_path, "w") as f: + yaml.dump(dependabot_config, f, sort_keys=False, default_flow_style=False, indent=2) + +print(f"βœ… dependabot.yml generated at: {output_path}") + +# Show a preview of the generated content +# print("\nπŸ“‹ Generated content preview:") +# print("=" * 50) +# with open(output_path, "r") as f: +# content = f.read() +# print(content[:500] + ("..." if len(content) > 500 else "")) +# print("=" * 50) diff --git a/.github/workflows/generate-dependabot.yml b/.github/workflows/generate-dependabot.yml new file mode 100644 index 00000000000..5d01833743d --- /dev/null +++ b/.github/workflows/generate-dependabot.yml @@ -0,0 +1,56 @@ +name: Generate Dependabot Config + +on: + workflow_dispatch: # allow to manually execute within GitHub + schedule: + - cron: '0 2 * * 1' # Every Monday at 2 AM UTC (optional) + push: + paths: + - 'spk/python*/crossenv/requirements-default.txt' + - 'spk/python*/src/requirements-*.txt' + - 'native/python*/src/requirements.txt' + - '.github/actions/generate_dependabot.py' + - '.github/workflows/generate-dependabot.yml' + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install PyYAML + + - name: Run generate_dependabot.py + run: | + python .github/actions/generate_dependabot.py + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "πŸ€– Auto-generate updated dependabot.yml" + branch: auto/update-dependabot-config + title: "πŸ€– Auto-update dependabot.yml" + body: | + ## Auto-generated Dependabot Configuration Update + + This PR updates the `.github/dependabot.yml` configuration file based on the current Python requirements files found in the repository. + + ### Scanned Files + - `spk/python*/src/requirements-*.txt` + - `native/python*/src/requirements.txt` + + ### Configuration + - **Schedule**: Weekly updates + - **Grouping**: All Python dependencies grouped together per package + + --- + *Auto-generated by [generate_dependabot.py](.github/actions/generate_dependabot.py)* diff --git a/native/python310/Makefile b/native/python310/Makefile index bef8887163d..5e2fb6bd0a5 100644 --- a/native/python310/Makefile +++ b/native/python310/Makefile @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3 PIP = $(WORK_DIR)/install/usr/local/bin/pip PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip -PIP_VERSION = "24.3.1" -PIP_WHEELS = setuptools==80.9.0 -PIP_WHEELS += wheel==0.45.1 -PIP_WHEELS += crossenv==1.5.0 +REQUIREMENTS = src/requirements.txt +PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS))) .PHONY: python310_native_post_install python310_native_post_install: $(WORK_DIR)/python-native.mk - @$(MSG) Installing pip @$(RUN) wget https://bootstrap.pypa.io/get-pip.py - @$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check - @$(MSG) Installing setuptools, wheel, cffi and crossenv - @$(PIP) --disable-pip-version-check install $(PIP_WHEELS) +ifeq ($(PIP_WHEEL),) + @$(MSG) Installing latest pip + @$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check +else + @$(MSG) Installing $(PIP_WHEEL) + @$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check +endif + @$(MSG) Installing wheels from requirements file + @$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS) $(WORK_DIR)/python-native.mk: @echo PIP=$(PIP_NATIVE) >> $@ diff --git a/native/python310/src/requirements.txt b/native/python310/src/requirements.txt new file mode 100644 index 00000000000..b90b7b72d7d --- /dev/null +++ b/native/python310/src/requirements.txt @@ -0,0 +1,4 @@ +pip==24.3.1 +setuptools==80.9.0 +wheel==0.45.1 +crossenv==1.5.0 diff --git a/native/python311/Makefile b/native/python311/Makefile index 0c20fc17285..7038e1ee680 100644 --- a/native/python311/Makefile +++ b/native/python311/Makefile @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3 PIP = $(WORK_DIR)/install/usr/local/bin/pip PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip -PIP_VERSION = "24.3.1" -PIP_WHEELS = setuptools==80.9.0 -PIP_WHEELS += wheel==0.45.1 -PIP_WHEELS += crossenv==1.5.0 +REQUIREMENTS = src/requirements.txt +PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS))) .PHONY: python311_native_post_install python311_native_post_install: $(WORK_DIR)/python-native.mk - @$(MSG) Installing pip @$(RUN) wget https://bootstrap.pypa.io/get-pip.py - @$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check - @$(MSG) Installing setuptools, wheel, cffi and crossenv - @$(PIP) --disable-pip-version-check install $(PIP_WHEELS) +ifeq ($(PIP_WHEEL),) + @$(MSG) Installing latest pip + @$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check +else + @$(MSG) Installing $(PIP_WHEEL) + @$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check +endif + @$(MSG) Installing wheels from requirements file + @$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS) $(WORK_DIR)/python-native.mk: @echo PIP=$(PIP_NATIVE) >> $@ diff --git a/native/python311/src/requirements.txt b/native/python311/src/requirements.txt new file mode 100644 index 00000000000..b90b7b72d7d --- /dev/null +++ b/native/python311/src/requirements.txt @@ -0,0 +1,4 @@ +pip==24.3.1 +setuptools==80.9.0 +wheel==0.45.1 +crossenv==1.5.0 diff --git a/native/python312/Makefile b/native/python312/Makefile index fca4187f19a..5fe46d1d3af 100644 --- a/native/python312/Makefile +++ b/native/python312/Makefile @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3 PIP = $(WORK_DIR)/install/usr/local/bin/pip PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip -PIP_VERSION = "24.3.1" -PIP_WHEELS = setuptools==80.9.0 -PIP_WHEELS += wheel==0.45.1 -PIP_WHEELS += crossenv==1.5.0 +REQUIREMENTS = src/requirements.txt +PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS))) .PHONY: python312_native_post_install python312_native_post_install: $(WORK_DIR)/python-native.mk - @$(MSG) Installing pip @$(RUN) wget https://bootstrap.pypa.io/get-pip.py - @$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check - @$(MSG) Installing setuptools, wheel, cffi and crossenv - @$(PIP) --disable-pip-version-check install $(PIP_WHEELS) +ifeq ($(PIP_WHEEL),) + @$(MSG) Installing latest pip + @$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check +else + @$(MSG) Installing $(PIP_WHEEL) + @$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check +endif + @$(MSG) Installing wheels from requirements file + @$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS) $(WORK_DIR)/python-native.mk: @echo PIP=$(PIP_NATIVE) >> $@ diff --git a/native/python312/src/requirements.txt b/native/python312/src/requirements.txt new file mode 100644 index 00000000000..b90b7b72d7d --- /dev/null +++ b/native/python312/src/requirements.txt @@ -0,0 +1,4 @@ +pip==24.3.1 +setuptools==80.9.0 +wheel==0.45.1 +crossenv==1.5.0 diff --git a/native/python313/Makefile b/native/python313/Makefile index 841dbab26ca..8d746d4c821 100644 --- a/native/python313/Makefile +++ b/native/python313/Makefile @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3 PIP = $(WORK_DIR)/install/usr/local/bin/pip PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip -PIP_VERSION = "24.3.1" -PIP_WHEELS = setuptools==80.9.0 -PIP_WHEELS += wheel==0.45.1 -PIP_WHEELS += crossenv==1.5.0 +REQUIREMENTS = src/requirements.txt +PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS))) .PHONY: python313_native_post_install python313_native_post_install: $(WORK_DIR)/python-native.mk - @$(MSG) Installing pip @$(RUN) wget https://bootstrap.pypa.io/get-pip.py - @$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check - @$(MSG) Installing setuptools, wheel, cffi and crossenv - @$(PIP) --disable-pip-version-check install $(PIP_WHEELS) +ifeq ($(PIP_WHEEL),) + @$(MSG) Installing latest pip + @$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check +else + @$(MSG) Installing $(PIP_WHEEL) + @$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check +endif + @$(MSG) Installing wheels from requirements file + @$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS) $(WORK_DIR)/python-native.mk: @echo PIP=$(PIP_NATIVE) >> $@ diff --git a/native/python313/src/requirements.txt b/native/python313/src/requirements.txt new file mode 100644 index 00000000000..b90b7b72d7d --- /dev/null +++ b/native/python313/src/requirements.txt @@ -0,0 +1,4 @@ +pip==24.3.1 +setuptools==80.9.0 +wheel==0.45.1 +crossenv==1.5.0