Skip to content

Commit 952a235

Browse files
committed
Added fix for keyboard interrupts close #9
1 parent 5d52162 commit 952a235

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

setup.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def _single_compile(obj):
1717
try:
1818
pool = multiprocessing.pool.ThreadPool(N)
1919
list(pool.imap(_single_compile,objects))
20-
except KeyboardInterrupt:
20+
except KeyboardInterrupt as e:
2121
print "Caught KeyboardInterrupt, terminating workers"
2222
pool.terminate()
23-
pool.join()
23+
raise e
2424
return objects
2525
import distutils.ccompiler
2626
distutils.ccompiler.CCompiler.compile=parallelCCompile
@@ -72,14 +72,20 @@ def _single_compile(obj):
7272
lib_files = os.listdir(lib_path)
7373
lib_files = [os.path.join(lib_path, f) for f in lib_files if f.startswith('libmapnik.')]
7474
for f in lib_files:
75-
if not os.path.exists(os.path.join('mapink', os.path.basename(f))):
75+
try:
7676
os.symlink(f, os.path.join('mapnik', os.path.basename(f)))
77+
except OSError:
78+
pass
7779
input_plugin_path = subprocess.check_output([mapnik_config, '--input-plugins']).rstrip('\n')
78-
if not os.path.exists(os.path.join('mapnik', 'input')):
80+
try:
7981
os.symlink(input_plugin_path, os.path.join('mapnik', 'input'))
82+
except OSError:
83+
pass
8084
font_path = subprocess.check_output([mapnik_config, '--fonts']).rstrip('\n')
81-
if not os.path.exists(os.path.join('mapnik', 'fonts')):
85+
try:
8286
os.symlink(input_plugin_path, os.path.join('mapnik', 'fonts'))
87+
except OSError:
88+
pass
8389
if create_paths:
8490
f_paths.write('mapniklibpath = os.path.dirname(os.path.realpath(__file__))\n')
8591
elif create_paths:
@@ -97,31 +103,37 @@ def _single_compile(obj):
97103
icu_path = subprocess.check_output([mapnik_config, '--icu-data']).rstrip('\n')
98104
else:
99105
icu_path = 'mason_packages/.link/share/icu/'
100-
if icu_path and not os.path.exists(os.path.join('mapnik', 'icu')):
106+
if icu_path:
107+
try:
101108
os.symlink(icu_path, os.path.join('mapnik', 'icu'))
109+
except OSError:
110+
pass
102111

103112
if not mason_build:
104113
gdal_path = subprocess.check_output([mapnik_config, '--gdal-data']).rstrip('\n')
105114
else:
106115
gdal_path = 'mason_packages/.link/share/gdal/'
107-
if gdal_path and not os.path.exists(os.path.join('mapnik', 'gdal')):
116+
if gdal_path:
117+
try:
108118
os.symlink(gdal_path, os.path.join('mapnik', 'gdal'))
119+
except OSError:
120+
pass
109121

110122
if not mason_build:
111123
proj_path = subprocess.check_output([mapnik_config, '--proj-lib']).rstrip('\n')
112124
else:
113125
proj_path = 'mason_packages/.link/share/proj/'
114-
if proj_path and not os.path.exists(os.path.join('mapnik', 'proj')):
126+
if proj_path:
127+
try:
115128
os.symlink(proj_path, os.path.join('mapnik', 'proj'))
129+
except OSError:
130+
pass
116131

117-
try:
118-
extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ')
132+
extra_comp_args = subprocess.check_output([mapnik_config, '--cflags']).rstrip('\n').split(' ')
119133

120-
if sys.platform == 'darwin':
121-
extra_comp_args.append('-mmacosx-version-min=10.8')
122-
linkflags.append('-mmacosx-version-min=10.8')
123-
except:
124-
extra_comp_args = []
134+
if sys.platform == 'darwin':
135+
extra_comp_args.append('-mmacosx-version-min=10.8')
136+
linkflags.append('-mmacosx-version-min=10.8')
125137

126138
if not mason_build:
127139
os.environ["CC"] = subprocess.check_output([mapnik_config, '--cxx']).rstrip('\n')

0 commit comments

Comments
 (0)