-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
119 lines (95 loc) · 3.92 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
#!/usr/bin/env python
# Copyright 2013, Gabriele Facciolo <[email protected]>
#
# This file is part of pvflip.
#
# Pvflip is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pvflip is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with pvflip. If not, see <http://www.gnu.org/licenses/>.
############################################################################
#from distutils.core import setup
from distutils.core import setup, Extension
import sys
import os
import shutil
command = sys.argv[1] if len(sys.argv) >= 2 else ""
is_build = command.startswith("build") or command.startswith("install") or command.startswith("bdist")
if sys.platform == "win32":
package_data = {"glfw": ["glfw.dll"]}
# pre-built
## MISSING!
shutil.copyfile("glfw-3.0.3/lib/win32/glfw.dll", "glfw/glfw.dll")
elif sys.platform == "darwin":
package_data = {"glfw": ["libglfw.dylib"]}
if not os.path.exists("glfw/libglfw.dylib") and is_build:
# let's cross our fingers and hope the build goes smooth (without user intervention)
if not os.path.exists('glfw/build'):
os.mkdir('glfw/build')
os.chdir('glfw/build')
if os.system("cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_UNIVERSAL=ON ../glfw_src") :
print("Error while building libglfw.dylib")
sys.exit(1)
if os.system("make") :
print("Error while building libglfw.dylib")
sys.exit(1)
os.chdir("..")
os.chdir("..")
shutil.copyfile("glfw/build/src/libglfw.dylib", "glfw/libglfw.dylib")
os.system("rm -fr glfw/build")
else:
package_data = {"glfw": ["libglfw.so"]}
if not os.path.exists("glfw/libglfw.so") and is_build:
if not os.path.exists('glfw/build'):
os.mkdir('glfw/build')
os.chdir('glfw/build')
if os.system("cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF ../glfw_src") :
print("Error while building libglfw.so")
sys.exit(1)
if os.system("make") :
print("Error while building libglfw.so")
sys.exit(1)
os.chdir("..")
os.chdir("..")
shutil.copyfile("glfw/build/src/libglfw.so", "glfw/libglfw.so")
os.system("rm -fr glfw/build")
iiomodule = Extension('piio.libiio',
libraries = ['png','jpeg','tiff'],
language=['c99'],
extra_compile_args = ['-std=gnu99','-DNDEBUG','-O3'],
sources = ['piio/iio.c','piio/freemem.c']
)
setup_info = {
"name": "pyglfw3",
"version": "1.0.0",
"author": "Gabriele Facciolo",
"author_email": "[email protected]",
"url": "",
"description": "GLFW3 bindings for Python",
"license": "BSD-style attribution-only license",
"classifiers": [
"Environment :: MacOS X",
"Environment :: Win32 (MS Windows)",
"Environment :: X11 Applications",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Topic :: Games/Entertainment",
"Topic :: Software Development :: Libraries :: Python Modules",
],
"packages": ['glfw', 'piio'],
"ext_modules": [iiomodule],
"package_data": package_data,
"scripts" : ['v.py'],
}
setup(**setup_info)