-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update python bindings installer for pypi packaging. Installer has be…
…en updated to support python2 and python3, and will check to see if libiio installed before actually installing the bindings. This is primarily useful for pip users. Signed-off-by: Travis F. Collins <[email protected]>
- Loading branch information
Showing
2 changed files
with
75 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
language: c | ||
sudo: required | ||
python: "3.6" | ||
|
||
env: | ||
global: | ||
|
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 |
---|---|---|
|
@@ -13,11 +13,77 @@ | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
|
||
from distutils.core import setup | ||
|
||
setup(name='libiio', | ||
version='${VERSION}', | ||
description='Library to use the Industrial IO devices', | ||
url='https://github.com/analogdevicesinc/libiio', | ||
py_modules=['iio'], | ||
) | ||
import sys | ||
|
||
if sys.version_info[0] < 3: | ||
from distutils.core import setup | ||
from distutils.command.install import install | ||
|
||
config = dict() | ||
else: | ||
from setuptools import setup | ||
from setuptools.command.install import install | ||
|
||
config = dict(long_description_content_type="text/markdown") | ||
|
||
description = "Library for interfacing with Linux IIO devices" | ||
|
||
try: | ||
with open("${CMAKE_SOURCE_DIR}/README.md", "r") as fh: | ||
long_description = fh.read() | ||
except: | ||
long_description = description | ||
|
||
|
||
class InstallWrapper(install): | ||
"""Before installing we check if the | ||
libiio library is actually installed""" | ||
|
||
def run(self): | ||
self._check_libiio_installed() | ||
# Run the standard PyPi copy | ||
install.run(self) | ||
|
||
def _check_libiio_installed(self): | ||
from platform import system as _system | ||
from ctypes import CDLL as _cdll | ||
from ctypes.util import find_library | ||
|
||
if "Windows" in _system(): | ||
_iiolib = "libiio.dll" | ||
else: | ||
# Non-windows, possibly Posix system | ||
_iiolib = "iio" | ||
try: | ||
_lib = _cdll(find_library(_iiolib), use_errno=True, use_last_error=True) | ||
if not _lib._name: | ||
raise OSError | ||
except OSError: | ||
msg = "The libiio library could not be found.\n\ | ||
libiio needs to be installed first before the python bindings.\n\ | ||
The latest release can be found on GitHub:\n\ | ||
https://github.com/analogdevicesinc/libiio/releases" | ||
raise Exception(msg) | ||
|
||
|
||
config.update( | ||
dict( | ||
name="libiio", | ||
version="${VERSION}", | ||
maintainer="Analog Devices, Inc", | ||
maintainer_email="[email protected]", | ||
description=description, | ||
long_description=long_description, | ||
url="https://github.com/analogdevicesinc/libiio", | ||
py_modules=["iio"], | ||
cmdclass={"install": InstallWrapper}, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", | ||
"Operating System :: OS Independent", | ||
], | ||
) | ||
) | ||
|
||
|
||
setup(**config) |