Skip to content

Commit c843775

Browse files
committed
fix: Dev rebuild
1 parent 44b5229 commit c843775

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
- run: python -m pip install -r requirements.txt
5353
- run: python -m pip install pytest
5454
- run: pytest
55+
5556
linux:
5657
runs-on: ubuntu-latest
5758

@@ -71,7 +72,7 @@ jobs:
7172
with:
7273
python-version: "3.10"
7374
cache: "pip"
74-
- run:
75+
- run:
7576
pip install -r requirements.txt
7677
python setup.py bdist_wheel
7778

@@ -102,7 +103,7 @@ jobs:
102103
python-version: '3.10'
103104
architecture: ${{ matrix.target }}
104105
cache: "pip"
105-
- run:
106+
- run:
106107
pip install -r requirements.txt
107108
python setup.py bdist_wheel
108109

@@ -128,7 +129,7 @@ jobs:
128129
with:
129130
python-version: '3.10'
130131
cache: "pip"
131-
- run:
132+
- run:
132133
pip install -r requirements.txt
133134
python setup.py bdist_wheel
134135
- name: Upload wheels
@@ -207,12 +208,13 @@ jobs:
207208
merge-multiple: true
208209
- name: List contents of dist directory
209210
run: ls -la dist/
210-
- name: Publish to PyPI
211+
- name: Publish to TestPyPI
211212
uses: pypa/gh-action-pypi-publish@release/v1
212213
with:
213214
packages-dir: dist
214-
# verbose: true
215-
# print-hash: true
215+
# Uncomment to use TestPyPI
216+
repository-url: https://test.pypi.org/legacy/
217+
verbose: true
216218
# Uncomment below for test runs, otherwise fails on existing packages being reuploaded
217219
skip-existing: true
218220

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
clean:
77
rm -rf artifacts/ build/ dist/
88

9-
clean-c2pa-env:
9+
clean-c2pa-env: clean
1010
python3 -m pip uninstall -y c2pa
1111
python3 -m pip cache purge
1212

@@ -15,6 +15,9 @@ build-python:
1515
python3 -m pip install -r requirements-dev.txt
1616
pip install -e .
1717

18+
rebuild: clean-c2pa-env download-native-artifacts build-python
19+
@echo "Development rebuild done!"
20+
1821
test:
1922
python3 ./tests/test_unit_tests.py
2023

@@ -39,3 +42,5 @@ publish: release
3942
format:
4043
autopep8 --aggressive --aggressive --in-place src/c2pa/*.py
4144

45+
download-native-artifacts:
46+
python3 scripts/download_artifacts.py c2pa-v0.55.0

setup.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,40 @@
1919
ARTIFACTS_DIR = Path('artifacts') # Where downloaded libraries are stored
2020
PACKAGE_LIBS_DIR = Path('src/c2pa/libs') # Where libraries will be copied for the wheel
2121

22+
23+
def get_platform_identifier(cpu_arch = None) -> str:
24+
"""Get a platform identifier (arch-os) for the current system,
25+
matching downloaded identifiers used by the Github publisher.
26+
27+
Args:
28+
Only used on macOS systems.:
29+
cpu_arch: Optional CPU architecture for macOS. If not provided, returns universal build.
30+
31+
Returns one of:
32+
- universal-apple-darwin (for Mac, when cpu_arch is None, fallback)
33+
- aarch64-apple-darwin (for Mac ARM64)
34+
- x86_64-apple-darwin (for Mac x86_64)
35+
- x86_64-pc-windows-msvc (for Windows 64-bit)
36+
- x86_64-unknown-linux-gnu (for Linux 64-bit)
37+
"""
38+
system = platform.system().lower()
39+
40+
if system == "darwin":
41+
if cpu_arch is None:
42+
return "universal-apple-darwin"
43+
elif cpu_arch == "arm64":
44+
return "aarch64-apple-darwin"
45+
elif cpu_arch == "x86_64":
46+
return "x86_64-apple-darwin"
47+
else:
48+
raise ValueError(f"Unsupported CPU architecture for macOS: {cpu_arch}")
49+
elif system == "windows":
50+
return "x86_64-pc-windows-msvc"
51+
elif system == "linux":
52+
return "x86_64-unknown-linux-gnu"
53+
else:
54+
raise ValueError(f"Unsupported operating system: {system}")
55+
2256
def get_current_platform():
2357
"""Determine the current platform name."""
2458
if sys.platform == "win32":
@@ -93,7 +127,8 @@ def find_available_platforms():
93127

94128
# For development installation
95129
if 'develop' in sys.argv or 'install' in sys.argv:
96-
current_platform = get_current_platform()
130+
current_platform = get_platform_identifier()
131+
print("Installing in development mode for platform ", current_platform)
97132
copy_platform_libraries(current_platform)
98133

99134
# For wheel building

0 commit comments

Comments
 (0)