Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Mark Liffiton | 3644907 | 2017-08-12 16:47:21 -0500 | [diff] [blame] | 3 | from setuptools import setup, Extension |
Mark Liffiton | f43bfce | 2017-08-12 23:34:01 -0500 | [diff] [blame^] | 4 | from setuptools.command.build_py import build_py |
Phil Howard | 60cc642 | 2015-03-11 12:20:54 +0000 | [diff] [blame] | 5 | from glob import glob |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 6 | |
Phil Howard | 3f99ba1 | 2016-02-29 12:12:28 +0000 | [diff] [blame] | 7 | sources = glob('WiringPi/devLib/*.c') |
| 8 | sources += glob('WiringPi/wiringPi/*.c') |
Mark Liffiton | 3644907 | 2017-08-12 16:47:21 -0500 | [diff] [blame] | 9 | sources += ['wiringpi.i'] |
Phil Howard | 3f99ba1 | 2016-02-29 12:12:28 +0000 | [diff] [blame] | 10 | |
Mark Liffiton | 3644907 | 2017-08-12 16:47:21 -0500 | [diff] [blame] | 11 | try: |
| 12 | sources.remove('WiringPi/devLib/piFaceOld.c') |
| 13 | except ValueError: |
| 14 | # the file is already excluded in the source distribution |
| 15 | pass |
Phil Howard | 3f99ba1 | 2016-02-29 12:12:28 +0000 | [diff] [blame] | 16 | |
Mark Liffiton | f43bfce | 2017-08-12 23:34:01 -0500 | [diff] [blame^] | 17 | |
| 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/ |
| 25 | class Build_ext_first(build_py): |
| 26 | def run(self): |
| 27 | self.run_command("build_ext") |
| 28 | return build_py.run(self) |
| 29 | |
| 30 | |
Phil Howard | 77ce6cd | 2016-03-09 11:49:38 +0000 | [diff] [blame] | 31 | _wiringpi = Extension( |
| 32 | '_wiringpi', |
Phil Howard | 2204176 | 2014-07-18 11:48:01 +0000 | [diff] [blame] | 33 | include_dirs=['WiringPi/wiringPi','WiringPi/devLib'], |
neuralassembly | 91b71d7 | 2017-03-29 17:25:14 +0900 | [diff] [blame] | 34 | sources=sources, |
| 35 | extra_link_args=['-lcrypt', '-lrt'] |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 36 | ) |
| 37 | |
| 38 | setup( |
Phil Howard | 77ce6cd | 2016-03-09 11:49:38 +0000 | [diff] [blame] | 39 | name = 'wiringpi', |
Mark Liffiton | f43bfce | 2017-08-12 23:34:01 -0500 | [diff] [blame^] | 40 | version = '2.44.3', |
Phil Howard | 77ce6cd | 2016-03-09 11:49:38 +0000 | [diff] [blame] | 41 | ext_modules = [ _wiringpi ], |
| 42 | py_modules = ["wiringpi"], |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 43 | install_requires=[], |
Mark Liffiton | f43bfce | 2017-08-12 23:34:01 -0500 | [diff] [blame^] | 44 | cmdclass = {'build_py' : Build_ext_first}, |
Philip Howard | 567ee00 | 2013-03-27 22:22:00 +0000 | [diff] [blame] | 45 | ) |