File: setup.py

package info (click to toggle)
renpy 6.10.2.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,468 kB
  • ctags: 5,383
  • sloc: python: 17,801; ansic: 7,116; makefile: 127; sh: 15
file content (224 lines) | stat: -rwxr-xr-x 5,468 bytes parent folder | download
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env python
import distutils.core
import os
import os.path
import platform
import sys

try:
    import bdist_mpkg
except:
    pass


# These control the level of optimization versus debugging.
extra_compile_args = [ "-O3", "-funroll-loops" ]
# extra_compile_args = [ "-O0", "-ggdb" ]
# extra_compile_args = [ "-O0", "-gstabs" ]

# This environment variable should have the full path to the installed
# Ren'Py dependencies.
install = os.environ.get("RENPY_DEPS_INSTALL", None)

if install is None:
    print """
The RENPY_DEPS_INSTALL environment variable has not been set. This
should be set to a double-colon-delimited list of places where the
Ren'Py dependencies can be found. (To use system libraries, this can
be set to a system directory, like /usr.)
"""
    sys.exit(-1)

install = install.split("::")

include_dirs = [ ]
library_dirs = [ ]

def add_include(prefix, file):
    """
    Search for prefix/file underneath <i> and <i>/include, for each of the
    directories <i> in install. When found, puts the directory it was found
    in into include_dirs.
    """

    checked = [ ]
    for i in install:

        dir = os.path.join(i, prefix)
        fn = os.path.join(dir, file)
        fn = os.path.normpath(fn)
        checked.append(fn)
        if os.path.exists(fn):
            break

        dir = os.path.join(i, "include", prefix)
        fn = os.path.join(dir, file)
        fn = os.path.normpath(fn)
        checked.append(fn)

        if os.path.exists(fn):
            break
        
    else:

        print "Could not find include %s." % file
        print "The paths searched were:"
        for i in checked:
            print "-", i
        sys.exit(-1)

    dir = os.path.normpath(dir)
        
    print "Found %s in %s." % (file, dir)
        
    if dir not in include_dirs:
        include_dirs.append(dir)

def add_library(name, optional=False):
    """
    This looks for a library named name in the <i> and <i>/lib, for all
    <i> in install. When found, it adds it to library_dirs.
    """

    checked = [ ]
    
    for i in install:
        for d in ('', 'lib'):
            for suffix in (".so", ".dylib", ".a"):

                dir = os.path.join(i, d)
                fn = os.path.join(dir, name + suffix)
                checked.append(fn)
                
                if os.path.exists(fn):
                    print "Found %s." % fn

                    if dir not in library_dirs:
                        library_dirs.append(dir)
                    return True

    if optional:
        return False
                
    print "Couldn't find library %s." % name
    print "The paths searched were:"
    for i in checked:
        print "-", i
    sys.exit(-1)
        
add_include("", "zlib.h")
add_include("", "png.h")
add_include("SDL", "SDL.h")
add_include("", "ft2build.h")
add_include("freetype2", "freetype/freetype.h")
add_include("", "libavutil/avstring.h")
add_include("", "libavformat/avformat.h")
add_include("", "libavcodec/avcodec.h")
add_include("", "libswscale/swscale.h")

add_library("libSDL")
add_library("libpng")
add_library("libavformat")
add_library("libavcodec")
add_library("libavutil")
has_swscale = add_library("libswscale", True)
add_library("libfreetype")
add_library("libfribidi")            
add_library("libz")

extra_link_args = [ ]

sdl_libraries = [ 'SDL' ]
png_libraries = [ 'png', "z" ]

sound_libraries = [ "avformat", "avcodec", "avutil", "z" ]
if has_swscale:
    sound_libraries.insert(0, "swscale")

# The following turn on optional modules.
winmixer = None
linmixer = None

# Detect win32.
if platform.win32_ver()[0]:
    extra_compile_args.append("-fno-strict-aliasing")
    winmixer = True

# Detect OSS.
try:
    import ossaudiodev
    linmixer = True
except:
    pass

extensions = [ ]
py_modules = [ 'pysdlsound.__init__' ]

rpe = distutils.core.Extension(
    "_renpy",
    [ "IMG_savepng.c", "core.c", "rwobject.c", "_renpy.c", "subpixel.c" ],
    include_dirs=include_dirs,
    library_dirs=library_dirs,
    extra_compile_args=extra_compile_args,
    extra_link_args=extra_link_args,
    libraries=sdl_libraries + png_libraries,
    )

extensions.append(rpe)

renpy_font = distutils.core.Extension(
    "_renpy_font",
    [ "renpy_ttf.c", "renpy_font.c"],
    include_dirs=include_dirs,
    library_dirs=library_dirs,
    extra_compile_args=extra_compile_args,
    extra_link_args=extra_link_args,
    libraries=sdl_libraries + [ 'freetype', 'z' ],
    )

extensions.append(renpy_font)

psse = distutils.core.Extension(
    "pysdlsound.sound",
    [ "pss.c", "rwobject.c", "sound.c", "ffdecode.c" ],
    include_dirs=include_dirs,
    library_dirs=library_dirs,
    extra_compile_args=extra_compile_args,
    extra_link_args=extra_link_args,
    libraries=sound_libraries + sdl_libraries,
    )

extensions.append(psse)

if winmixer:
    wme = distutils.core.Extension(
        "pysdlsound.winmixer",
        [ 'winmixer.c' ],
        libraries=['winmm'],
        )

    extensions.append(wme)

if linmixer:
    py_modules.append('pysdlsound.linmixer')


renpybidi = distutils.core.Extension(
    "_renpybidi",
    ["_renpybidi.c", "renpybidicore.c"],
    include_dirs=include_dirs,
    library_dirs=library_dirs,
    libraries=['fribidi'],
    )

extensions.append(renpybidi)

    
distutils.core.setup(
    name = "renpy_module",
    version = "6.10.1",
    ext_modules = extensions,
    py_modules = py_modules,
    package_dir = { '' : 'lib' },
    )