1+ from setuptools import setup
2+ from setuptools .command .build_py import build_py as build_py_orig
13import os
24import shutil
3- from setuptools import setup
4-
55
66PICA_PKG_DIR = 'pica'
77DATA_FILES_TO_COPY = {
1717 ]
1818}
1919
20- for dest_subdir , files in DATA_FILES_TO_COPY .items ():
21- dest_dir = os .path .join (PICA_PKG_DIR , dest_subdir )
22- if not os .path .exists (dest_dir ):
23- os .makedirs (dest_dir )
24-
25- for file_path in files :
26- if os .path .exists (file_path ):
27- shutil .copy (file_path , dest_dir )
28-
20+ class build_py (build_py_orig ):
21+ """
22+ Custom build command to copy data files into the package source tree.
23+ """
24+ def run (self ):
25+ # First, copy the files
26+ print ("--- Custom build_py: Copying data files ---" )
27+ for dest_subdir , files in DATA_FILES_TO_COPY .items ():
28+ dest_dir = os .path .join (PICA_PKG_DIR , dest_subdir )
29+ if not os .path .exists (dest_dir ):
30+ print (f"Creating directory: { dest_dir } " )
31+ os .makedirs (dest_dir )
32+
33+ for file_path in files :
34+ if os .path .exists (file_path ):
35+ print (f"Copying { file_path } to { dest_dir } " )
36+ shutil .copy (file_path , dest_dir )
37+ else :
38+ print (f"WARNING: File not found, cannot copy: { file_path } " )
39+
40+ # Then run the original build_py command
41+ print ("--- Custom build_py: Running original build command ---" )
42+ build_py_orig .run (self )
2943
30- setup ()
44+ setup (
45+ cmdclass = {'build_py' : build_py }
46+ )
0 commit comments