-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from waveform80/pypi
Ensure clean sdist and wheel builds
- Loading branch information
Showing
4 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,48 @@ | |
setup.py file for SWIG lgpio | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
from textwrap import dedent | ||
|
||
from setuptools import setup, Extension | ||
from setuptools.command.build_py import build_py as _build_py | ||
|
||
with open('README.md') as f: | ||
long_description = f.read() | ||
class build_py(_build_py): | ||
# The package's module lgpio.py is produced by SWIG, hence build_ext must | ||
# run prior to the build_py command | ||
def run(self): | ||
self.run_command('build_ext') | ||
return super().run() | ||
|
||
lgpio_module = Extension('_lgpio', sources=['lgpio_wrap.c',], libraries=['lgpio',],) | ||
if int(os.environ.get('PYPI', '0')): | ||
# If building for PyPI, build a statically linked module that incorporates | ||
# the liblgpio library | ||
Path('MANIFEST.in').write_text(dedent("""\ | ||
include lgpio_extra.py | ||
include src/lg*.h | ||
include src/rgpiod.h | ||
""")) | ||
lgpio_module = Extension( | ||
'_lgpio', | ||
sources=[str(p) for p in Path('src').glob('lg*.c')] + | ||
['lgpio.i', 'src/rgpiod.c'], | ||
libraries=['rt', 'dl'], | ||
include_dirs=['src'], | ||
extra_compile_args=['-O3', '-pthread'], | ||
) | ||
else: | ||
# Otherwise, build a dynamically linked module | ||
Path('MANIFEST.in').write_text(dedent("""\ | ||
include lgpio_extra.py | ||
include src/lgpio.h | ||
""")) | ||
lgpio_module = Extension( | ||
'_lgpio', | ||
sources=['lgpio.i'], | ||
libraries=['lgpio'], | ||
include_dirs=['src'], | ||
) | ||
|
||
setup (name = 'lgpio', | ||
version = '0.2.2.0', | ||
|
@@ -20,16 +56,16 @@ | |
maintainer_email='[email protected]', | ||
url='http://abyz.me.uk/lg/py_lgpio.html', | ||
description='Linux SBC GPIO module', | ||
long_description=long_description, | ||
long_description=Path('README.md').read_text(), | ||
long_description_content_type="text/markdown", | ||
download_url='http://abyz.me.uk/lg/lg.zip', | ||
license='unlicense.org', | ||
keywords=['linux', 'sbc', 'gpio',], | ||
classifiers=[ | ||
"Programming Language :: Python :: 2", | ||
"Programming Language :: Python :: 3", | ||
], | ||
ext_modules = [lgpio_module], | ||
py_modules = ["lgpio"], | ||
ext_modules=[lgpio_module], | ||
py_modules=["lgpio"], | ||
cmdclass={'build_py': build_py}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters