diff --git a/.github/workflows/build-wheel.yml b/.github/workflows/build-wheel.yml index e6fe4360..ca6aae2d 100644 --- a/.github/workflows/build-wheel.yml +++ b/.github/workflows/build-wheel.yml @@ -25,34 +25,50 @@ permissions: packages: read actions: read +env: + GITHUB_TOKEN: ${{ secrets.github-token }} + jobs: build: runs-on: ${{ inputs.runs-on }} - env: - GITHUB_TOKEN: ${{ secrets.github-token }} steps: - uses: actions/checkout@v4 - name: Build Linux wheels if: runner.os == 'Linux' run: | - docker run --rm -v $PWD:/io quay.io/pypa/manylinux_2_28_x86_64 bash -c " + # Create necessary directories + mkdir -p artifacts + mkdir -p src/c2pa/libs + rm -rf dist build + + # Set Docker image and platform tag based on architecture + if [ "${{ inputs.architecture }}" = "aarch64" ]; then + DOCKER_IMAGE="quay.io/pypa/manylinux_2_28_aarch64" + PLATFORM_TAG="manylinux_2_28_aarch64" + else + DOCKER_IMAGE="quay.io/pypa/manylinux_2_28_x86_64" + PLATFORM_TAG="manylinux_2_28_x86_64" + fi + + # Build wheel in Docker container + docker run --rm -v $PWD:/io $DOCKER_IMAGE bash -c " yum install -y gcc gcc-c++ make && mkdir -p /io/artifacts /io/src/c2pa/libs && rm -rf /io/dist /io/build && cd /io && /opt/python/cp310-cp310/bin/pip install -r requirements.txt -r requirements-dev.txt && - /opt/python/cp310-cp310/bin/python scripts/download_artifacts.py c2pa-v0.55.0 && + /opt/python/cp310-cp310/bin/pip install toml && + C2PA_LIBS_PLATFORM=\"${{ inputs.architecture == 'aarch64' && 'aarch64-unknown-linux-gnu' || 'x86_64-unknown-linux-gnu' }}\" /opt/python/cp310-cp310/bin/python scripts/download_artifacts.py c2pa-v0.55.0 && for PYBIN in /opt/python/cp3{10,11}-*/bin; do \${PYBIN}/pip install --upgrade pip wheel && - CFLAGS=\"-I/opt/python/cp310-cp310/include/python3.10\" LDFLAGS=\"-L/opt/python/cp310-cp310/lib\" \${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64 + \${PYBIN}/pip install toml && + CFLAGS=\"-I/opt/python/cp310-cp310/include/python3.10\" LDFLAGS=\"-L/opt/python/cp310-cp310/lib\" \${PYBIN}/python setup.py bdist_wheel --plat-name $PLATFORM_TAG done && rm -f /io/dist/*-linux_*.whl " - - name: Verify Linux wheels - if: runner.os == 'Linux' - run: | + # Verify the wheel was built echo "Contents of dist directory:" ls -la dist/ echo "Number of wheels found:" @@ -60,7 +76,7 @@ jobs: echo "Wheel filenames:" find dist -name "*.whl" -exec basename {} \; - - name: Build Windows wheel + - name: Build Windows wheel (x64) if: runner.os == 'Windows' shell: pwsh run: | @@ -81,25 +97,6 @@ jobs: # Build wheel python setup.py bdist_wheel --plat-name win_amd64 - - name: Build macOS wheel (Intel) - if: runner.os == 'macOS' && runner.arch == 'x64' - run: | - # Create necessary directories - mkdir -p artifacts - mkdir -p src/c2pa/libs - rm -rf dist build - - # Install dependencies - pip install -r requirements.txt - pip install -r requirements-dev.txt - pip install wheel - - # Download native artifacts - python scripts/download_artifacts.py c2pa-v0.55.0 - - # Build wheel - python setup.py bdist_wheel --plat-name macosx_10_9_x86_64 - - name: Build macOS wheel (Apple Silicon) if: runner.os == 'macOS' && runner.arch == 'arm64' run: | @@ -119,6 +116,13 @@ jobs: # Build wheel python setup.py bdist_wheel --plat-name macosx_11_0_arm64 + # Rename wheel to ensure unique filename + cd dist + for wheel in *.whl; do + mv "$wheel" "${wheel/macosx_11_0_arm64/macosx_11_0_arm64}" + done + cd .. + - name: Log wheel filename if: runner.os == 'Linux' || runner.os == 'macOS' shell: bash @@ -130,4 +134,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ inputs.artifact-name }} - path: dist \ No newline at end of file + path: dist + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66c9c566..625040b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,13 +154,16 @@ jobs: needs: tests-unix with: python-version: "3.10" + architecture: ${{ matrix.target }} artifact-name: wheels-linux-${{ matrix.target }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.runs-on }} secrets: github-token: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: - target: [x86_64, aarch64] + include: + - target: x86_64 + runs-on: ubuntu-24.04 if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -171,10 +174,12 @@ jobs: test-built-linux-wheel: name: Test Linux built wheel needs: build-linux-wheel - runs-on: ubuntu-latest + runs-on: ${{ matrix.runs-on }} strategy: matrix: - target: [x86_64, aarch64] + include: + - target: x86_64 + runs-on: ubuntu-24.04 if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -236,7 +241,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: - target: [x64, x86] + target: [x64] if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -250,7 +255,7 @@ jobs: runs-on: windows-latest strategy: matrix: - target: [x64, x86] + target: [x64] if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -313,7 +318,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: - target: [x86_64, aarch64] + target: [aarch64] if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -327,7 +332,7 @@ jobs: runs-on: macos-latest strategy: matrix: - target: [x86_64, aarch64] + target: [aarch64] if: | github.event_name != 'pull_request' || github.event.pull_request.author_association == 'COLLABORATOR' || @@ -394,6 +399,8 @@ jobs: cache: "pip" - name: Install dependencies run: pip install -r requirements.txt + - name: Install dev dependencies for build + run: pip install -r requirements-dev.txt - name: Build sdist run: python setup.py sdist - name: Upload sdist @@ -415,41 +422,12 @@ jobs: - uses: actions/checkout@v4 - name: Create dist directory run: mkdir -p dist - - name: Debug - List dist before download - run: | - echo "=== Dist directory before download ===" - ls -la dist/ || echo "dist is empty" - name: Download all wheels uses: actions/download-artifact@v4 with: pattern: wheels-* path: dist merge-multiple: true - - name: Debug - List downloaded artifacts - run: | - echo "=== Downloaded artifacts structure ===" - find dist -type f -ls - echo "=== Downloaded artifacts contents ===" - ls -R dist/ - echo "=== Artifact details ===" - for file in dist/*; do - echo "File: $file" - echo "Size: $(stat -f %z "$file")" - echo "Last modified: $(stat -f %Sm "$file")" - echo "---" - done - echo "=== Platform-specific artifacts ===" - echo "Linux x86_64: $(ls -l dist/wheels-linux-x86_64/* 2>/dev/null || echo 'Not found')" - echo "Linux aarch64: $(ls -l dist/wheels-linux-aarch64/* 2>/dev/null || echo 'Not found')" - echo "macOS x86_64: $(ls -l dist/wheels-macos-x86_64/* 2>/dev/null || echo 'Not found')" - echo "macOS aarch64: $(ls -l dist/wheels-macos-aarch64/* 2>/dev/null || echo 'Not found')" - echo "Windows x64: $(ls -l dist/wheels-windows-x64/* 2>/dev/null || echo 'Not found')" - echo "Windows x86: $(ls -l dist/wheels-windows-x86/* 2>/dev/null || echo 'Not found')" - echo "SDist: $(ls -l dist/wheels-sdist/* 2>/dev/null || echo 'Not found')" - - name: Debug - List final dist directory - run: | - echo "=== Final dist directory contents ===" - ls -la dist/ || echo "dist is empty" - name: Publish to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/pyproject.toml b/pyproject.toml index dfc1d43b..04390229 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=68.0.0", "wheel"] +requires = ["setuptools>=68.0.0", "wheel", "toml>=0.10.2"] build-backend = "setuptools.build_meta" [project] name = "c2pa-python" -version = "0.10.9" +version = "0.10.12" requires-python = ">=3.10" description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library" readme = { file = "README.md", content-type = "text/markdown" } @@ -37,5 +37,6 @@ test = [ [project.scripts] download-artifacts = "c2pa.build:download_artifacts" +# Workaround to prevent setuptools from automatically including invalid metadata [tool.setuptools] license-files = [] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 844b16b5..00000000 --- a/setup.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[metadata] -name = c2pa -version = 1.0.0 -description = Python bindings for the C2PA library -long_description = file: README.md -long_description_content_type = text/markdown -license = MIT OR Apache-2.0 - -[options] -package_dir = - = src -packages = find: -include_package_data = True - -[options.packages.find] -where = src \ No newline at end of file diff --git a/setup.py b/setup.py index 8f042026..489c070d 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,16 @@ from setuptools import setup, find_namespace_packages import sys -import os import platform import shutil from pathlib import Path +import toml + +# Read version from pyproject.toml +def get_version(): + pyproject = toml.load("pyproject.toml") + return pyproject["project"]["version"] + +VERSION = get_version() # Define platform to library extension mapping (for reference only) PLATFORM_EXTENSIONS = { @@ -158,7 +165,7 @@ def find_available_platforms(): print("No platform-specific libraries found. Building wheel without platform-specific libraries.") setup( name="c2pa-python", - version="0.10.9", + version=VERSION, package_dir={"": "src"}, packages=find_namespace_packages(where="src"), include_package_data=True, @@ -190,7 +197,7 @@ def find_available_platforms(): # Build the wheel setup( name="c2pa-python", - version="0.10.9", + version=VERSION, package_dir={"": "src"}, packages=find_namespace_packages(where="src"), include_package_data=True, @@ -215,7 +222,7 @@ def find_available_platforms(): # For sdist and development installation setup( name="c2pa-python", - version="0.10.9", + version=VERSION, package_dir={"": "src"}, packages=find_namespace_packages(where="src"), include_package_data=True, diff --git a/src/c2pa/__init__.py b/src/c2pa/__init__.py index d39ad799..f5cd278e 100644 --- a/src/c2pa/__init__.py +++ b/src/c2pa/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.10.9" +__version__ = "0.10.12" from .c2pa import ( Builder, diff --git a/tests/_test_api.py b/tests/_test_api.py index a5a6c265..059564aa 100644 --- a/tests/_test_api.py +++ b/tests/_test_api.py @@ -63,7 +63,7 @@ def getitem(d, key): class TestC2paSdk(unittest.TestCase): def test_version(self): - assert version() == "0.10.9" + assert version() == "0.10.12" def test_sdk_version(self): assert "c2pa-rs/" in sdk_version()