Skip to content

Commit 72cfc35

Browse files
committed
Update platform detection. See #74
1 parent d836abe commit 72cfc35

File tree

2 files changed

+84
-28
lines changed

2 files changed

+84
-28
lines changed

docs/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ python-openzwave 0.4.0 is coming !!!
4242

4343
.. code-block:: bash
4444
45-
sudo apt-get install --force-yes -y build-essential libudev-dev g++ libyaml-dev
45+
sudo apt-get install --force-yes -y make libudev-dev g++ libyaml-dev
4646
4747
- Make your virtualenv and activate it :
4848

pyozw_setup.py

Lines changed: 83 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ def system_context(ctx, openzwave=None, static=False):
114114
#~ os.environ["CC"] = "gcc"
115115
#~ os.environ["CXX"] = "g++"
116116
#~ os.environ["PKG_CONFIG_PATH"] = "PKG_CONFIG_PATH:/usr/local/lib/x86_64-linux-gnu/pkgconfig/"
117+
log.info("Found platform {0}".format(sys.platform))
117118
if static:
118119
ctx['include_dirs'] += [
119120
"{0}/cpp/src".format(openzwave),
120121
"{0}/cpp/src/value_classes".format(openzwave),
121122
"{0}/cpp/src/platform".format(openzwave) ]
122-
if sys.platform == "win32":
123+
if sys.platform.startswith("win"):
123124
ctx['libraries'] += [ "setupapi", "msvcrt", "ws2_32", "dnsapi" ]
124125

125126
if static:
@@ -133,7 +134,20 @@ def system_context(ctx, openzwave=None, static=False):
133134
for ssubstitute in ['/', '/value_classes/', '/platform/']:
134135
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
135136

136-
elif sys.platform == "darwin":
137+
elif sys.platform.startswith("cygwin"):
138+
if static:
139+
ctx['libraries'] += [ "udev", "stdc++",'resolv' ]
140+
ctx['extra_objects'] = [ "{0}/libopenzwave.a".format(openzwave) ]
141+
ctx['include_dirs'] += [ "{0}/cpp/build/linux".format(openzwave) ]
142+
else:
143+
import pyozw_pkgconfig
144+
ctx['libraries'] += [ "openzwave" ]
145+
extra = pyozw_pkgconfig.cflags('libopenzwave')
146+
if extra != '':
147+
for ssubstitute in ['/', '/value_classes/', '/platform/']:
148+
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
149+
150+
elif sys.platform.startswith("darwin") :
137151
ctx['extra_link_args'] += [ "-framework", "CoreFoundation", "-framework", "IOKit" ]
138152
ctx['extra_compile_args'] += [ "-stdlib=libc++", "-mmacosx-version-min=10.7" ]
139153

@@ -148,7 +162,7 @@ def system_context(ctx, openzwave=None, static=False):
148162
for ssubstitute in ['/', '/value_classes/', '/platform/']:
149163
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
150164

151-
elif sys.platform == "freebsd":
165+
elif sys.platform.startswith("freebsd"):
152166
if static:
153167
ctx['libraries'] += [ "usb", "stdc++",'resolv' ]
154168
ctx['extra_objects'] = [ "{0}/libopenzwave.a".format(openzwave) ]
@@ -161,7 +175,7 @@ def system_context(ctx, openzwave=None, static=False):
161175
for ssubstitute in ['/', '/value_classes/', '/platform/']:
162176
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
163177

164-
elif sys.platform[:5] == "linux":
178+
elif sys.platform.startswith("sunos"):
165179
if static:
166180
ctx['libraries'] += [ "udev", "stdc++",'resolv' ]
167181
ctx['extra_objects'] = [ "{0}/libopenzwave.a".format(openzwave) ]
@@ -173,9 +187,23 @@ def system_context(ctx, openzwave=None, static=False):
173187
if extra != '':
174188
for ssubstitute in ['/', '/value_classes/', '/platform/']:
175189
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
190+
191+
elif sys.platform.startswith("linux"):
192+
if static:
193+
ctx['libraries'] += [ "udev", "stdc++",'resolv' ]
194+
ctx['extra_objects'] = [ "{0}/libopenzwave.a".format(openzwave) ]
195+
ctx['include_dirs'] += [ "{0}/cpp/build/linux".format(openzwave) ]
196+
else:
197+
import pyozw_pkgconfig
198+
ctx['libraries'] += [ "openzwave" ]
199+
extra = pyozw_pkgconfig.cflags('libopenzwave')
200+
if extra != '':
201+
for ssubstitute in ['/', '/value_classes/', '/platform/']:
202+
ctx['extra_compile_args'] += [ extra.replace('//', ssubstitute) ]
203+
176204
else:
177205
# Unknown systemm
178-
raise RuntimeError("Can't detect plateform")
206+
raise RuntimeError("Can't detect plateform {0}".format(sys.platform))
179207

180208
return ctx
181209

@@ -264,17 +292,24 @@ def printer():
264292
sys.stderr.write('{0}\n'.format(line))
265293
log.error('{0}\n'.format(line))
266294

267-
if sys.platform == "win32":
295+
if sys.platform.startswith("win"):
268296
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
269297

270-
elif sys.platform == "darwin":
298+
elif sys.platform.startswith("cygwin"):
271299
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
272300

273-
elif sys.platform == "freebsd":
301+
elif sys.platform.startswith("darwin"):
274302
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
275303

276-
elif sys.platform[:5] == "linux":
304+
elif sys.platform.startswith("freebsd"):
277305
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
306+
307+
elif sys.platform.startswith("sunos"):
308+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
309+
310+
elif sys.platform.startswith("linux"):
311+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
312+
278313
else:
279314
# Unknown systemm
280315
raise RuntimeError("Can't detect plateform {0}".format(sys.platform))
@@ -284,11 +319,11 @@ def printer():
284319
Thread(target=stream_watcher, name='stderr-watcher',
285320
args=('STDERR', proc.stderr)).start()
286321

287-
printer = Thread(target=printer, name='printer')
288-
printer.start()
289-
while printer.is_alive():
322+
tprinter = Thread(target=printer, name='printer')
323+
tprinter.start()
324+
while tprinter.is_alive():
290325
time.sleep(1)
291-
printer.join()
326+
tprinter.join()
292327
return True
293328

294329
def install_so(self):
@@ -325,17 +360,24 @@ def printer():
325360
if identifier == 'STDERR':
326361
sys.stderr.write('{0}\n'.format(line))
327362
log.error('{0}\n'.format(line))
328-
if sys.platform == "win32":
363+
if sys.platform.startswith("win"):
329364
proc = Popen([ 'make', 'install' ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
330365

331-
elif sys.platform == "darwin":
366+
elif sys.platform.startswith("cygwin"):
332367
proc = Popen([ 'make', 'install' ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
333368

334-
elif sys.platform == "freebsd":
369+
elif sys.platform.startswith("darwin"):
335370
proc = Popen([ 'make', 'install' ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
336371

337-
elif sys.platform[:5] == "linux":
372+
elif sys.platform.startswith("freebsd"):
338373
proc = Popen([ 'make', 'install' ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
374+
375+
elif sys.platform.startswith("sunos"):
376+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
377+
378+
elif sys.platform.startswith("linux"):
379+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
380+
339381
else:
340382
# Unknown systemm
341383
raise RuntimeError("Can't detect plateform {0}".format(sys.platform))
@@ -354,17 +396,24 @@ def printer():
354396
try:
355397
import pyozw_pkgconfig
356398
ldpath = pyozw_pkgconfig.libs_only_l('libopenzwave')[2:]
357-
if sys.platform == "win32":
399+
if sys.platform.startswith("win"):
358400
proc = Popen([ 'ldconfig', ldpath ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
359401

360-
elif sys.platform == "darwin":
402+
elif sys.platform.startswith("cygwin"):
361403
proc = Popen([ 'ldconfig', ldpath ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
362404

363-
elif sys.platform == "freebsd":
405+
elif sys.platform.startswith("darwin"):
364406
proc = Popen([ 'ldconfig', ldpath ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
365407

366-
elif sys.platform[:5] == "linux":
408+
elif sys.platform.startswith("freebsd"):
367409
proc = Popen([ 'ldconfig', ldpath ], stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
410+
411+
elif sys.platform.startswith("sunos"):
412+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
413+
414+
elif sys.platform.startswith("linux"):
415+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
416+
368417
else:
369418
# Unknown systemm
370419
raise RuntimeError("Can't detect plateform {0}".format(sys.platform))
@@ -427,17 +476,24 @@ def printer():
427476
sys.stderr.write('{0}\n'.format(line))
428477
log.error('{0}\n'.format(line))
429478

430-
if sys.platform == "win32":
479+
if sys.platform.startswith("win"):
431480
proc = Popen('make clean', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
432481

433-
elif sys.platform == "darwin":
482+
elif sys.platform.startswith("cygwin"):
434483
proc = Popen('make clean', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
435484

436-
elif sys.platform == "freebsd clean":
437-
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
485+
elif sys.platform.startswith("darwin"):
486+
proc = Popen('make clean', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
438487

439-
elif sys.platform[:5] == "linux":
488+
elif sys.platform.startswith("freebsd"):
440489
proc = Popen('make clean', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
490+
491+
elif sys.platform.startswith("sunos"):
492+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
493+
494+
elif sys.platform.startswith("linux"):
495+
proc = Popen('make', stdout=PIPE, stderr=PIPE, cwd='{0}'.format(self.openzwave))
496+
441497
else:
442498
# Unknown systemm
443499
raise RuntimeError("Can't detect plateform {0}".format(sys.platform))
@@ -941,7 +997,7 @@ def finalize_options(self):
941997

942998
def run(self):
943999
#In case of --uninstall, it will build openzwave to remove it ... stupid.
944-
#In develop mode, build is donr by the makefile
1000+
#In develop mode, build is done by the makefile
9451001
#~ build_openzwave = self.distribution.get_command_obj('build_openzwave')
9461002
#~ build_openzwave.develop = True
9471003
#~ self.run_command('build_openzwave')

0 commit comments

Comments
 (0)