|
5 | 5 | import os |
6 | 6 | import subprocess |
7 | 7 | import sys |
| 8 | +import shutil |
8 | 9 | import re |
9 | 10 |
|
10 | 11 | cflags = sysconfig.get_config_var('CFLAGS') |
|
52 | 53 | lib_files = [os.path.join(lib_path, f) for f in lib_files if f.startswith('libmapnik.')] |
53 | 54 | for f in lib_files: |
54 | 55 | try: |
55 | | - os.symlink(f, os.path.join('mapnik', os.path.basename(f))) |
56 | | - except OSError: |
| 56 | + shutil.copyfile(f, os.path.join('mapnik', os.path.basename(f))) |
| 57 | + except shutil.Error: |
57 | 58 | pass |
58 | 59 | input_plugin_path = subprocess.check_output([mapnik_config, '--input-plugins']).rstrip('\n') |
59 | | - try: |
60 | | - os.symlink(input_plugin_path, os.path.join('mapnik', 'input')) |
61 | | - except OSError: |
62 | | - pass |
| 60 | + input_plugin_files = os.listdir(input_plugin_path) |
| 61 | + input_plugin_files = [os.path.join(input_plugin_path, f) for f in input_plugin_files] |
| 62 | + if not os.path.exists(os.path.join('mapnik','plugins','input')): |
| 63 | + os.makedirs(os.path.join('mapnik','plugins', 'input')) |
| 64 | + for f in input_plugin_files: |
| 65 | + try: |
| 66 | + shutil.copyfile(f, os.path.join('mapnik', 'plugins', 'input', os.path.basename(f))) |
| 67 | + except shutil.Error: |
| 68 | + pass |
63 | 69 | font_path = subprocess.check_output([mapnik_config, '--fonts']).rstrip('\n') |
64 | | - try: |
65 | | - os.symlink(input_plugin_path, os.path.join('mapnik', 'fonts')) |
66 | | - except OSError: |
67 | | - pass |
| 70 | + font_files = os.listdir(font_path) |
| 71 | + font_files = [os.path.join(font_path, f) for f in font_files] |
| 72 | + if not os.path.exists(os.path.join('mapnik','plugins','fonts')): |
| 73 | + os.makedirs(os.path.join('mapnik','plugins','fonts')) |
| 74 | + for f in font_files: |
| 75 | + try: |
| 76 | + shutil.copyfile(f, os.path.join('mapnik','plugins','fonts', os.path.basename(f))) |
| 77 | + except shutil.Error: |
| 78 | + pass |
68 | 79 | if create_paths: |
69 | 80 | f_paths.write('mapniklibpath = os.path.dirname(os.path.realpath(__file__))\n') |
70 | 81 | elif create_paths: |
71 | | - f_paths.write("mapniklibpath = '"+lib_path+"/mapnik'\n") |
| 82 | + f_paths.write("mapniklibpath = '"+lib_path+"/mapnik/plugins'\n") |
72 | 83 | f_paths.write('mapniklibpath = os.path.normpath(mapniklibpath)\n') |
73 | 84 |
|
74 | 85 | if create_paths: |
|
83 | 94 | else: |
84 | 95 | icu_path = 'mason_packages/.link/share/icu/' |
85 | 96 | if icu_path: |
86 | | - try: |
87 | | - os.symlink(icu_path, os.path.join('mapnik', 'icu')) |
88 | | - except OSError: |
89 | | - pass |
| 97 | + icu_files = os.listdir(icu_path) |
| 98 | + icu_files = [os.path.join(icu_path, f) for f in icu_files] |
| 99 | + if not os.path.exists(os.path.join('mapnik','plugins','icu')): |
| 100 | + os.makedirs(os.path.join('mapnik','plugins','icu')) |
| 101 | + for f in icu_files: |
| 102 | + try: |
| 103 | + shutil.copyfile(f, os.path.join('mapnik','plugins','icu', os.path.basename(f))) |
| 104 | + except shutil.Error: |
| 105 | + pass |
90 | 106 |
|
91 | 107 | if not mason_build: |
92 | 108 | gdal_path = subprocess.check_output([mapnik_config, '--gdal-data']).rstrip('\n') |
93 | 109 | else: |
94 | 110 | gdal_path = 'mason_packages/.link/share/gdal/' |
95 | 111 | if gdal_path: |
96 | | - try: |
97 | | - os.symlink(gdal_path, os.path.join('mapnik', 'gdal')) |
98 | | - except OSError: |
99 | | - pass |
| 112 | + gdal_files = os.listdir(gdal_path) |
| 113 | + gdal_files = [os.path.join(gdal_path, f) for f in gdal_files] |
| 114 | + if not os.path.exists(os.path.join('mapnik','plugins','gdal')): |
| 115 | + os.makedirs(os.path.join('mapnik','plugins','gdal')) |
| 116 | + for f in gdal_files: |
| 117 | + try: |
| 118 | + shutil.copyfile(f, os.path.join('mapnik','plugins','gdal', os.path.basename(f))) |
| 119 | + except shutil.Error: |
| 120 | + pass |
100 | 121 |
|
101 | 122 | if not mason_build: |
102 | 123 | proj_path = subprocess.check_output([mapnik_config, '--proj-lib']).rstrip('\n') |
103 | 124 | else: |
104 | 125 | proj_path = 'mason_packages/.link/share/proj/' |
105 | 126 | if proj_path: |
106 | | - try: |
107 | | - os.symlink(proj_path, os.path.join('mapnik', 'proj')) |
108 | | - except OSError: |
109 | | - pass |
| 127 | + proj_files = os.listdir(proj_path) |
| 128 | + proj_files = [os.path.join(proj_path, f) for f in proj_files] |
| 129 | + if not os.path.exists(os.path.join('mapnik','plugins','proj')): |
| 130 | + os.makedirs(os.path.join('mapnik','plugins','proj')) |
| 131 | + for f in proj_files: |
| 132 | + try: |
| 133 | + shutil.copyfile(f, os.path.join('mapnik','plugins','proj', os.path.basename(f))) |
| 134 | + except shutil.Error: |
| 135 | + pass |
110 | 136 |
|
111 | 137 | extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ') |
112 | 138 |
|
|
0 commit comments