forked from shapely/shapely
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
129 lines (113 loc) · 4.06 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import glob
import warnings
try:
from distribute_setup import use_setuptools
use_setuptools()
except:
warnings.warn(
"Failed to import distribute_setup, continuing without distribute.",
Warning)
from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
from setuptools import setup, find_packages
import sys
import platform
readme_text = file('README.rst', 'rb').read()
changes_text = file('CHANGES.txt', 'rb').read()
setup_args = dict(
metadata_version = '1.2',
name = 'Shapely',
version = '1.2.13',
requires_python = '>=2.5,<3',
requires_external = 'libgeos_c (>=3.1)',
description = 'Geometric objects, predicates, and operations',
license = 'BSD',
keywords = 'geometry topology gis',
author = 'Sean Gillies',
author_email = '[email protected]',
maintainer = 'Sean Gillies',
maintainer_email = '[email protected]',
url = 'https://github.com/sgillies/shapely',
long_description = readme_text + "\n" + changes_text,
packages = find_packages(),
test_suite = 'shapely.tests.test_suite',
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: GIS',
],
)
# Add DLLs for Windows
if sys.platform == 'win32':
if '(AMD64)' in sys.version:
setup_args.update(
data_files=[('DLLs', glob.glob('DLLs_AMD64_VC9/*.dll'))]
)
elif platform.python_version().startswith('2.5.'):
setup_args.update(
data_files=[('DLLs', glob.glob('DLLs_x86_VC7/*.dll'))]
)
else:
setup_args.update(
data_files=[('DLLs', glob.glob('DLLs_x86_VC9/*.dll'))]
)
# Optional compilation of speedups
# setuptools stuff from Bob Ippolito's simplejson project
if sys.platform == 'win32' and sys.version_info > (2, 6):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
IOError)
else:
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
class BuildFailed(Exception):
pass
class ve_build_ext(build_ext):
# This class allows C extension building to fail.
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError, x:
raise BuildFailed(x)
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors, x:
raise BuildFailed(x)
if sys.platform == 'win32':
# geos DLL is geos.dll instead of geos_c.dll on Windows
ext_modules = [
Extension("shapely.speedups._speedups",
["shapely/speedups/_speedups.c"], libraries=['geos']),
]
elif (hasattr(platform, 'python_implementation')
and platform.python_implementation() == 'PyPy'):
# python_implementation >= 2.6
ext_modules = []
else:
ext_modules = [
Extension("shapely.speedups._speedups",
["shapely/speedups/_speedups.c"], libraries=['geos_c']),
]
try:
# try building with speedups
setup(
cmdclass={'build_ext': ve_build_ext},
ext_modules=ext_modules,
**setup_args
)
except BuildFailed, ex:
BUILD_EXT_WARNING = "Warning: The C extension could not be compiled, speedups are not enabled."
print ex
print BUILD_EXT_WARNING
print "Failure information, if any, is above."
print "I'm retrying the build without the C extension now."
setup(**setup_args)
print BUILD_EXT_WARNING
print "Plain-Python installation succeeded."