-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·60 lines (56 loc) · 2.35 KB
/
setup.py
File metadata and controls
executable file
·60 lines (56 loc) · 2.35 KB
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
from setuptools import setup, Extension
import subprocess
import glob
import platform
import os.path
import urllib.request, urllib.parse, urllib.error
from zipfile import ZipFile
sources = glob.glob('src/*.cpp') + glob.glob('src/randomc/*.cpp') + glob.glob('src/*.i')
sources = [source for source in sources if '_wrap' not in source]
include_dirs = ['src']
if platform.system() == 'Darwin':
extra_compile_args = subprocess.check_output(['xml2-config', '--cflags']).decode('utf-8').split()
extra_link_args = subprocess.check_output(['xml2-config', '--libs']).decode('utf-8').split()
libraries = []
elif platform.system() == 'Linux':
extra_compile_args = [x.decode('utf-8') for x in subprocess.check_output(['xml2-config', '--cflags']).split()]
extra_link_args = [x.decode('utf-8') for x in subprocess.check_output(['xml2-config', '--libs']).split()]
libraries = []
elif platform.system() == 'Windows':
if not os.path.exists("extern"):
os.mkdir("extern")
if not os.path.exists("extern/swigwin-3.0.7.zip"):
urllib.request.urlretrieve("http://prdownloads.sourceforge.net/swig/swigwin-3.0.7.zip", "extern/swigwin-3.0.7.zip")
if not os.path.exists("extern/swigwin-3.0.7"):
with ZipFile("extern/swigwin-3.0.7.zip") as zipfile:
zipfile.extractall("extern")
os.environ['PATH'] += ';' + os.path.abspath("extern/swigwin-3.0.7")
libraries = ["libeay32", "libxml2"]
extra_compile_args = ['/D_USE_MATH_DEFINES']
extra_link_args = [r"/LIBPATH:C:\extern\lib\vc\static", r"/LIBPATH:C:\extern\lib"]
include_dirs.append(r"C:\extern\include")
elif "CYGWIN" in platform.system():
extra_compile_args = subprocess.check_output(['xml2-config', '--cflags']).split()
extra_link_args = subprocess.check_output(['xml2-config', '--libs']).split()
libraries = ['uuid', 'crypto']
else:
libraries = [] # hope for the best
extra_compile_args = []
extra_link_args = []
print(extra_compile_args)
setup(
name = 'stylusengine',
ext_modules = [
Extension(
'_stylusengine',
sources = sources,
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args,
include_dirs = include_dirs,
swig_opts = ['-c++'],
libraries = libraries
)
],
py_modules = ['stylusengine'],
package_dir = {'' : 'src'}
)