1515 'linux_aarch64' : 'so' ,
1616}
1717
18+ # Based on what c2pa-rs repo publishes
19+ PLATFORM_FOLDERS = {
20+ 'universal-apple-darwin' : 'dylib' ,
21+ 'aarch64-apple-darwin' : 'dylib' ,
22+ 'x86_64-apple-darwin' : 'dylib' ,
23+ 'x86_64-pc-windows-msvc' : 'dll' ,
24+ 'x86_64-unknown-linux-gnu' : 'so' ,
25+ }
26+
1827# Directory structure
1928ARTIFACTS_DIR = Path ('artifacts' ) # Where downloaded libraries are stored
2029PACKAGE_LIBS_DIR = Path ('src/c2pa/libs' ) # Where libraries will be copied for the wheel
@@ -53,6 +62,17 @@ def get_platform_identifier(cpu_arch = None) -> str:
5362 else :
5463 raise ValueError (f"Unsupported operating system: { system } " )
5564
65+ def get_platform_classifier (platform_name ):
66+ """Get the appropriate classifier for a platform."""
67+ if platform_name .startswith ('win' ) or platform_name .endswith ('windows-msvc' ):
68+ return "Operating System :: Microsoft :: Windows"
69+ elif platform_name .startswith ('macosx' ) or platform_name .endswith ('apple-darwin' ):
70+ return "Operating System :: MacOS"
71+ elif platform_name .startswith ('linux' ) or platform_name .endswith ('linux-gnu' ):
72+ return "Operating System :: POSIX :: Linux"
73+ else :
74+ raise ValueError (f"Unknown platform: { platform_name } " )
75+
5676def get_current_platform ():
5777 """Determine the current platform name."""
5878 if sys .platform == "win32" :
@@ -76,13 +96,19 @@ def copy_platform_libraries(platform_name, clean_first=False):
7696 clean_first: If True, remove existing files in PACKAGE_LIBS_DIR first
7797 """
7898 platform_dir = ARTIFACTS_DIR / platform_name
99+ print (" " )
100+ print ('##### Found platform dir: ' , platform_dir )
101+ print (" " )
79102
80103 # Ensure the platform directory exists and contains files
81104 if not platform_dir .exists ():
82105 raise ValueError (f"Platform directory not found: { platform_dir } " )
83106
84107 # Get list of all files in the platform directory
85108 platform_files = list (platform_dir .glob ('*' ))
109+ print (" " )
110+ print ('##### Platform files: ' , platform_files )
111+ print (" " )
86112 if not platform_files :
87113 raise ValueError (f"No files found in platform directory: { platform_dir } " )
88114
@@ -91,31 +117,23 @@ def copy_platform_libraries(platform_name, clean_first=False):
91117 shutil .rmtree (PACKAGE_LIBS_DIR )
92118
93119 # Ensure the package libs directory exists
120+ print (" " )
121+ print ('##### Package libs dir will be in: ' , PACKAGE_LIBS_DIR )
122+ print (" " )
94123 PACKAGE_LIBS_DIR .mkdir (parents = True , exist_ok = True )
95124
96125 # Copy files from platform-specific directory to the package libs directory
97126 for file in platform_files :
98127 if file .is_file ():
99128 shutil .copy2 (file , PACKAGE_LIBS_DIR / file .name )
100129
101- def get_platform_classifier (platform_name ):
102- """Get the appropriate classifier for a platform."""
103- if platform_name .startswith ('win' ):
104- return "Operating System :: Microsoft :: Windows"
105- elif platform_name .startswith ('macosx' ) or platform_name .startswith ('apple-darwin' ):
106- return "Operating System :: MacOS"
107- elif platform_name .startswith ('linux' ):
108- return "Operating System :: POSIX :: Linux"
109- else :
110- raise ValueError (f"Unknown platform: { platform_name } " )
111-
112130def find_available_platforms ():
113131 """Scan the artifacts directory for available platform-specific libraries."""
114132 if not ARTIFACTS_DIR .exists ():
115133 raise ValueError (f"Artifacts directory not found: { ARTIFACTS_DIR } " )
116134
117135 available_platforms = []
118- for platform_name in PLATFORM_EXTENSIONS .keys ():
136+ for platform_name in PLATFORM_FOLDERS .keys ():
119137 platform_dir = ARTIFACTS_DIR / platform_name
120138 if platform_dir .exists () and any (platform_dir .iterdir ()):
121139 available_platforms .append (platform_name )
@@ -140,14 +158,17 @@ def find_available_platforms():
140158 print (f"\n Building wheel for { platform_name } ..." )
141159 try :
142160 # Copy libraries for this platform (cleaning first)
161+ print (" " )
162+ print ('##### Preparing to copy libraries to where they belong (bdist_wheel)' )
163+ print (" " )
143164 copy_platform_libraries (platform_name , clean_first = True )
144165
145166 # Build the wheel
146167 setup (
147168 name = "c2pa" ,
148169 version = "1.0.0" ,
149170 package_dir = {"" : "src" },
150- packages = find_packages (where = "src" ),
171+ packages = find_packages (where = "src" ) + [ "c2pa.libs" ] ,
151172 include_package_data = True ,
152173 package_data = {
153174 "c2pa" : ["libs/*" ], # Include all files in libs directory
@@ -168,7 +189,7 @@ def find_available_platforms():
168189 name = "c2pa" ,
169190 version = "1.0.0" ,
170191 package_dir = {"" : "src" },
171- packages = find_packages (where = "src" ),
192+ packages = find_packages (where = "src" ) + [ "c2pa.libs" ] ,
172193 include_package_data = True ,
173194 package_data = {
174195 "c2pa" : ["libs/*" ], # Include all files in libs directory
0 commit comments