Skip to content

Commit f7c3601

Browse files
committed
Reformatted setup.py (tab to space, and other minor changes)
1 parent 49a9f89 commit f7c3601

File tree

1 file changed

+113
-69
lines changed

1 file changed

+113
-69
lines changed

setup.py

Lines changed: 113 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
import sys, os, platform
2-
import os.path, shutil
1+
import sys
2+
import os
3+
import platform
4+
import os.path
5+
import shutil
36
from glob import glob
47
from subprocess import call
58
from setuptools import setup, Command, Extension
69

710
try:
811
from Cython.Distutils import build_ext
912
except ImportError:
10-
print("Please install cython and try again.")
11-
raise SystemExit
13+
print("Please install Cython and try again.")
14+
exit(1)
1215

1316
if platform.architecture()[0] == "32bit":
14-
arch = "x86"
17+
arch = "x86"
1518
elif platform.architecture()[0] == "64bit":
16-
arch = "x64"
19+
arch = "x64"
1720

1821
class CythonBuildExt(build_ext):
19-
""" Updated version of cython build_ext command to deal with the
20-
generated API headers. C/C++ header files are all moved to the
21-
temporary build directory before being properly installed on
22-
the system.
22+
""" Updated version of cython build_ext command.
23+
24+
This version of cython build_ext command include generated API headers to
25+
the build process of subsequent extensions. The C/C++ header files are all
26+
moved to the temporary build directory before being properly installed on
27+
the system.
2328
"""
2429

2530
def cython_sources(self, sources, extension):
@@ -42,7 +47,8 @@ def cython_sources(self, sources, extension):
4247
header_files.remove(os.path.join('src', 'sfml', module, module + '_api.h'))
4348

4449
# create the temporary destination in the build directory
45-
destination = os.path.join(self.build_temp, 'include', 'pysfml', module)
50+
destination = os.path.join(
51+
self.build_temp, 'include', 'pysfml', module)
4652

4753
if not os.path.exists(destination):
4854
os.makedirs(destination)
@@ -56,7 +62,8 @@ def cython_sources(self, sources, extension):
5662
pass
5763

5864
# add the temporary header directory to compilation options
59-
self.compiler.include_dirs.append(os.path.join(self.build_temp, 'include'))
65+
self.compiler.include_dirs.append(
66+
os.path.join(self.build_temp, 'include'))
6067

6168
# update data_files to install the files on the system
6269

@@ -68,40 +75,76 @@ def cython_sources(self, sources, extension):
6875

6976
return ret
7077

71-
modules = ['system', 'window', 'graphics', 'audio', 'network']
72-
73-
extension = lambda name, files, libs: Extension(
74-
name='sfml.' + name,
75-
sources= [os.path.join('src', 'sfml', name, filename) for filename in files],
76-
include_dirs=[os.path.join('include', 'Includes')],
77-
library_dirs=[os.path.join('extlibs', 'libs-msvc-universal', arch)] if sys.hexversion >= 0x03050000 else [],
78-
language='c++',
79-
libraries=libs,
80-
define_macros=[('SFML_STATIC', '1')] if platform.system() == 'Windows' else [])
78+
def extension(name, files, libs): return Extension(
79+
name='sfml.' + name,
80+
sources=[os.path.join('src', 'sfml', name, filename) for filename in files],
81+
include_dirs=[os.path.join('include', 'Includes')],
82+
library_dirs=[os.path.join('extlibs', 'libs-msvc-universal', arch)] if sys.hexversion >= 0x03050000 else [],
83+
language='c++',
84+
libraries=libs,
85+
define_macros=[('SFML_STATIC', '1')] if platform.system() == 'Windows' else []
86+
)
8187

8288
if platform.system() == 'Windows':
83-
system_libs = ['winmm', 'sfml-system-s']
84-
window_libs = ['user32', 'advapi32', 'winmm', 'sfml-system-s', 'gdi32', 'opengl32', 'sfml-window-s']
85-
graphics_libs = ['user32', 'advapi32', 'winmm', 'sfml-system-s', 'gdi32', 'opengl32', 'sfml-window-s', 'freetype', 'jpeg', 'sfml-graphics-s']
86-
audio_libs = ['winmm', 'sfml-system-s', 'flac', 'vorbisenc', 'vorbisfile', 'vorbis', 'ogg', 'openal32', 'sfml-audio-s']
87-
network_libs = ['ws2_32', 'sfml-system-s', 'sfml-network-s']
89+
system_libs = [
90+
'winmm',
91+
'sfml-system-s'
92+
]
93+
window_libs = [
94+
'user32',
95+
'advapi32',
96+
'winmm',
97+
'sfml-system-s',
98+
'gdi32',
99+
'opengl32',
100+
'sfml-window-s'
101+
]
102+
graphics_libs = [
103+
'user32',
104+
'advapi32',
105+
'winmm',
106+
'sfml-system-s',
107+
'gdi32',
108+
'opengl32',
109+
'sfml-window-s',
110+
'freetype',
111+
'jpeg',
112+
'sfml-graphics-s'
113+
]
114+
audio_libs = [
115+
'winmm',
116+
'sfml-system-s',
117+
'flac',
118+
'vorbisenc',
119+
'vorbisfile',
120+
'vorbis',
121+
'ogg',
122+
'openal32',
123+
'sfml-audio-s'
124+
]
125+
network_libs = [
126+
'ws2_32',
127+
'sfml-system-s',
128+
'sfml-network-s'
129+
]
88130
else:
89-
system_libs = ['sfml-system']
90-
window_libs = ['sfml-system', 'sfml-window']
91-
graphics_libs = ['sfml-system', 'sfml-window', 'sfml-graphics']
92-
audio_libs = ['sfml-system', 'sfml-audio']
93-
network_libs = ['sfml-system', 'sfml-network']
94-
131+
system_libs = ['sfml-system']
132+
window_libs = ['sfml-system', 'sfml-window']
133+
graphics_libs = ['sfml-system', 'sfml-window', 'sfml-graphics']
134+
audio_libs = ['sfml-system', 'sfml-audio']
135+
network_libs = ['sfml-system', 'sfml-network']
95136

96137
system = extension(
97138
'system',
98139
['system.pyx', 'error.cpp', 'hacks.cpp', 'NumericObject.cpp'],
99-
system_libs)
140+
system_libs
141+
)
100142

101143
window = extension(
102144
'window',
103145
['window.pyx', 'DerivableWindow.cpp'],
104-
window_libs)
146+
window_libs
147+
)
105148

106149
graphics = extension(
107150
'graphics',
@@ -111,14 +154,16 @@ def cython_sources(self, sources, extension):
111154
audio = extension(
112155
'audio',
113156
['audio.pyx', 'DerivableSoundRecorder.cpp', 'DerivableSoundStream.cpp'],
114-
audio_libs)
157+
audio_libs
158+
)
115159

116160
network = extension(
117161
'network',
118162
['network.pyx'],
119-
network_libs)
163+
network_libs
164+
)
120165

121-
major, minor, _, _ , _ = sys.version_info
166+
major, minor, _, _, _ = sys.version_info
122167

123168
data_files = []
124169
if platform.system() == 'Windows':
@@ -128,34 +173,33 @@ def cython_sources(self, sources, extension):
128173
with open('README.md', 'r') as f:
129174
long_description = f.read()
130175

131-
ext_modules=[system, window, graphics, audio, network]
132-
133-
kwargs = dict(
134-
name='pySFML',
135-
ext_modules=ext_modules,
136-
package_dir={'': 'src'},
137-
packages=['sfml'],
138-
data_files=data_files,
139-
version='2.3.2.dev1',
140-
description='Python bindings for SFML',
141-
long_description=long_description,
142-
author='Jonathan de Wachter',
143-
author_email='[email protected]',
144-
url='http://python-sfml.org',
145-
classifiers=['Development Status :: 5 - Production/Stable',
146-
'Intended Audience :: Developers',
147-
'License :: OSI Approved :: zlib/libpng License',
148-
'Operating System :: OS Independent',
149-
'Programming Language :: Python :: 3',
150-
'Programming Language :: Cython',
151-
'Programming Language :: C++',
152-
'Programming Language :: Python',
153-
'Programming Language :: Python :: Implementation :: CPython',
154-
'Topic :: Games/Entertainment',
155-
'Topic :: Multimedia',
156-
'Topic :: Software Development :: Libraries :: Python Modules'],
157-
keywords='sfml SFML simple fast multimedia system window graphics audio network pySFML PySFML python-sfml',
158-
install_requires=['Cython'],
159-
cmdclass={'build_ext': CythonBuildExt})
160-
161-
setup(**kwargs)
176+
setup(
177+
name='pySFML',
178+
ext_modules=[system, window, graphics, audio, network],
179+
package_dir={'': 'src'},
180+
packages=['sfml'],
181+
data_files=data_files,
182+
version='2.3.2.dev1',
183+
description='Python bindings for SFML',
184+
long_description=long_description,
185+
author='Jonathan de Wachter',
186+
author_email='[email protected]',
187+
url='http://python-sfml.org',
188+
classifiers=[
189+
'Development Status :: 5 - Production/Stable',
190+
'Intended Audience :: Developers',
191+
'License :: OSI Approved :: zlib/libpng License',
192+
'Operating System :: OS Independent',
193+
'Programming Language :: Python :: 3',
194+
'Programming Language :: Cython',
195+
'Programming Language :: C++',
196+
'Programming Language :: Python',
197+
'Programming Language :: Python :: Implementation :: CPython',
198+
'Topic :: Games/Entertainment',
199+
'Topic :: Multimedia',
200+
'Topic :: Software Development :: Libraries :: Python Modules'
201+
],
202+
keywords='sfml SFML simple fast multimedia system window graphics audio network pySFML PySFML python-sfml',
203+
install_requires=['Cython'],
204+
cmdclass={'build_ext': CythonBuildExt}
205+
)

0 commit comments

Comments
 (0)