Skip to content

Commit a3570a3

Browse files
committed
Updated gitignore and changed symlinks to copy when using mason as this will eventually be our packaging mechanism
1 parent 647122e commit a3570a3

2 files changed

Lines changed: 50 additions & 23 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ mapnik/paths.py
1818
*.egg-info/
1919
.eggs/
2020
.mason/
21+
mason_packages/

setup.py

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import subprocess
77
import sys
8+
import shutil
89
import re
910

1011
cflags = sysconfig.get_config_var('CFLAGS')
@@ -52,23 +53,33 @@
5253
lib_files = [os.path.join(lib_path, f) for f in lib_files if f.startswith('libmapnik.')]
5354
for f in lib_files:
5455
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:
5758
pass
5859
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
6369
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
6879
if create_paths:
6980
f_paths.write('mapniklibpath = os.path.dirname(os.path.realpath(__file__))\n')
7081
elif create_paths:
71-
f_paths.write("mapniklibpath = '"+lib_path+"/mapnik'\n")
82+
f_paths.write("mapniklibpath = '"+lib_path+"/mapnik/plugins'\n")
7283
f_paths.write('mapniklibpath = os.path.normpath(mapniklibpath)\n')
7384

7485
if create_paths:
@@ -83,30 +94,45 @@
8394
else:
8495
icu_path = 'mason_packages/.link/share/icu/'
8596
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
90106

91107
if not mason_build:
92108
gdal_path = subprocess.check_output([mapnik_config, '--gdal-data']).rstrip('\n')
93109
else:
94110
gdal_path = 'mason_packages/.link/share/gdal/'
95111
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
100121

101122
if not mason_build:
102123
proj_path = subprocess.check_output([mapnik_config, '--proj-lib']).rstrip('\n')
103124
else:
104125
proj_path = 'mason_packages/.link/share/proj/'
105126
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
110136

111137
extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ')
112138

0 commit comments

Comments
 (0)