blob: 7d05e0e157fbf2721a4b5af7243787bf088f8702 [file] [log] [blame]
Philip Howard567ee002013-03-27 22:22:00 +00001#!/usr/bin/env python
2
Mark Liffiton36449072017-08-12 16:47:21 -05003from setuptools import setup, Extension
Mark Liffitonf43bfce2017-08-12 23:34:01 -05004from setuptools.command.build_py import build_py
Phil Howard60cc6422015-03-11 12:20:54 +00005from glob import glob
Philip Howard567ee002013-03-27 22:22:00 +00006
Phil Howard3f99ba12016-02-29 12:12:28 +00007sources = glob('WiringPi/devLib/*.c')
8sources += glob('WiringPi/wiringPi/*.c')
Mark Liffiton36449072017-08-12 16:47:21 -05009sources += ['wiringpi.i']
Phil Howard3f99ba12016-02-29 12:12:28 +000010
Mark Liffiton36449072017-08-12 16:47:21 -050011try:
12 sources.remove('WiringPi/devLib/piFaceOld.c')
13except ValueError:
14 # the file is already excluded in the source distribution
15 pass
Phil Howard3f99ba12016-02-29 12:12:28 +000016
Mark Liffitonf43bfce2017-08-12 23:34:01 -050017
18# Fix so that build_ext runs before build_py
19# Without this, wiringpi.py is generated too late and doesn't
20# end up in the distribution when running setup.py bdist or bdist_wheel.
21# Based on:
22# https://stackoverflow.com/a/29551581/7938656
23# and
24# https://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/
25class Build_ext_first(build_py):
26 def run(self):
27 self.run_command("build_ext")
28 return build_py.run(self)
29
30
Phil Howard77ce6cd2016-03-09 11:49:38 +000031_wiringpi = Extension(
32 '_wiringpi',
Phil Howard22041762014-07-18 11:48:01 +000033 include_dirs=['WiringPi/wiringPi','WiringPi/devLib'],
neuralassembly91b71d72017-03-29 17:25:14 +090034 sources=sources,
35 extra_link_args=['-lcrypt', '-lrt']
Philip Howard567ee002013-03-27 22:22:00 +000036)
37
38setup(
Phil Howard77ce6cd2016-03-09 11:49:38 +000039 name = 'wiringpi',
Mark Liffitonf43bfce2017-08-12 23:34:01 -050040 version = '2.44.3',
Phil Howard77ce6cd2016-03-09 11:49:38 +000041 ext_modules = [ _wiringpi ],
42 py_modules = ["wiringpi"],
Philip Howard567ee002013-03-27 22:22:00 +000043 install_requires=[],
Mark Liffitonf43bfce2017-08-12 23:34:01 -050044 cmdclass = {'build_py' : Build_ext_first},
Philip Howard567ee002013-03-27 22:22:00 +000045)