Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include src/c2pa/libs/*.dylib
include src/c2pa/libs/*.dll
include src/c2pa/libs/*.so
include src/c2pa/libs/*.so
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
build-python:
python3 -m pip uninstall -y maturin
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements-dev.txt
pip install -e .

test:
python3 ./tests/test_unit_tests.py
python3 ./tests/test_api.py

publish: release
python3 -m pip install twine
Expand Down
9 changes: 9 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Build dependencies
wheel==0.41.2 # For building wheels
setuptools==68.0.0 # For building packages

# Testing dependencies
pytest==7.4.0

# for downloading the library artifacts
requests>=2.0.0
11 changes: 2 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@

wheel==0.41.2 # For building wheels
setuptools==68.0.0 # For building packages
# Testing dependencies
pytest==7.4.0
# only used in the training example
cryptography>=41.0.0
# for downloading the library artifacts
requests>=2.0.0
# only used in the training example
cryptography>=41.0.0
22 changes: 11 additions & 11 deletions src/c2pa/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,48 @@ def get_latest_release() -> dict:
def download_artifact(url: str, platform_name: str) -> None:
"""Download and extract an artifact to the appropriate platform directory."""
print(f"Downloading artifact for {platform_name}...")

# Create platform directory
platform_dir = ARTIFACTS_DIR / platform_name
platform_dir.mkdir(parents=True, exist_ok=True)

# Download the zip file
response = requests.get(url)
response.raise_for_status()

# Extract the zip file
with zipfile.ZipFile(io.BytesIO(response.content)) as zip_ref:
# Extract all files to the platform directory
zip_ref.extractall(platform_dir)

print(f"Successfully downloaded and extracted artifacts for {platform_name}")

def download_artifacts() -> None:
"""Main function to download artifacts. Can be called as a script or from hatch."""
try:
# Create artifacts directory if it doesn't exist
ARTIFACTS_DIR.mkdir(exist_ok=True)

# Get latest release
print("Fetching latest release information...")
release = get_latest_release()
print(f"Found release: {release['tag_name']}")

# Download each asset
for asset in release['assets']:
# Skip non-zip files
if not asset['name'].endswith('.zip'):
continue

# Determine platform from asset name
# Example: c2pa-rs-v1.0.0-macosx-arm64.zip
platform_name = asset['name'].split('-')[-1].replace('.zip', '')

# Download and extract the artifact
download_artifact(asset['browser_download_url'], platform_name)

print("\nAll artifacts have been downloaded successfully!")

except requests.exceptions.RequestException as e:
print(f"Error downloading artifacts: {e}", file=sys.stderr)
sys.exit(1)
Expand All @@ -77,4 +77,4 @@ def initialize_build() -> None:
download_artifacts()

if __name__ == "__main__":
download_artifacts()
download_artifacts()
4 changes: 2 additions & 2 deletions src/c2pa/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def dynamically_load_library(lib_name: Optional[str] = None) -> Optional[ctypes.
# Package directory
Path(__file__).parent,
# Additional library directory
Path(__file__).parent / "lib",
Path(__file__).parent / "libs",
# System library paths
*[Path(p) for p in os.environ.get("LD_LIBRARY_PATH", "").split(os.pathsep) if p],
]
Expand All @@ -95,7 +95,7 @@ def dynamically_load_library(lib_name: Optional[str] = None) -> Optional[ctypes.
raise RuntimeError(f"Could not find {lib_name} in any of the search paths")
return lib

# Default paht (no library name provided in the environment)
# Default path (no library name provided in the environment)
c2pa_lib = _load_single_library(c2pa_lib_name, possible_paths)
if not c2pa_lib:
raise RuntimeError(f"Could not find {c2pa_lib_name} in any of the search paths")
Expand Down
Loading