Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pypi installer support #380

Merged
merged 4 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: c
sudo: required
python: "3.6"

env:
global:
Expand Down Expand Up @@ -34,6 +35,7 @@ matrix:
# TODO do `check` or `check_hw` here too, not just `check_sw` (as part of `coverage`)
- CHECK_RULE=coverage GCOV=1
- PKG_RULE=gzip
- PYPI=yes
- COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
- COVERITY_SCAN_BRANCH_PATTERN="master"
- COVERITY_SCAN_NOTIFICATION_EMAIL="[email protected]"
Expand Down Expand Up @@ -113,6 +115,7 @@ before_deploy:
- eval "$(ssh-agent -s)"
- chmod 600 /tmp/deploy.rsa
- ssh-add /tmp/deploy.rsa
- if [[ "$PYPI" == "yes" ]]; then cd "build/bindings/python"; fi
deploy:
- provider: releases
api_key:
Expand Down Expand Up @@ -151,6 +154,16 @@ deploy:
on:
condition: "$TRAVIS_OS_NAME = osx"
all_branches: true
- provider: pypi
if: tag IS present
skip_cleanup: true
on:
tags: true
condition: "$PYPI = yes"
username: __token__
password:
secure: KfORvnPyLlMANLpcwJjcO44Kt6meP614omJk2GloD+B51SuV64O6N31VDOTi2xqioEk9Cajq7tmNte5YoHVUjL9iWFsBblpzxZoXcy40dn4pFN0kMiE8scszxckbDwuBZhokUVZ2fhfLKf/8xORcwjS3vKqSj5HwQKKvVgukSbQ=
distributions: sdist

after_deploy:
- ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy
37 changes: 18 additions & 19 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,15 @@ build_script:
- cmake --build . --config %configuration%

- cd bindings/python
- python.exe setup.py bdist_wininst
- ps: Get-ChildItem dist\libiio-*.exe | Rename-Item -NewName "libiio-py37-win32.exe"
- ps: cp dist\*.exe .
- ps: rm dist\*.exe
- python.exe setup.py sdist
- ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-win32.tar.gz"
- ps: cp dist\*.tar.gz .
- ps: rm dist\*.tar.gz
- set PATH=C:\\Python36;C:\\Python36\\libs;%PATH%
- python.exe setup.py bdist_wininst
- ls dist
- ps: Get-ChildItem dist\libiio-*.exe | Rename-Item -NewName "libiio-py36-win32.exe"
- ps: cp dist\*.exe .
- ps: rm dist\*.exe
- python.exe setup.py sdist
- ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-win32.tar.gz"
- ps: cp dist\*.tar.gz .
- ps: rm dist\*.tar.gz

#MSVC 64 bit
- set PATH=C:\Python37-x64;C:\\Python37-x64\\libs;%PATH%
Expand All @@ -111,15 +110,15 @@ build_script:
- cmake --build . --config %configuration%

- cd bindings/python
- python.exe setup.py bdist_wininst
- ps: Get-ChildItem dist\libiio-*.exe | Rename-Item -NewName "libiio-py37-amd64.exe"
- ps: cp dist\*.exe .
- ps: rm dist\*.exe
- python.exe setup.py sdist
- ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-amd64.tar.gz"
- ps: cp dist\*.tar.gz .
- ps: rm dist\*.tar.gz
- set PATH=C:\Python36-x64;C:\\Python36-x64\\libs;%PATH%
- python.exe setup.py bdist_wininst
- ps: Get-ChildItem dist\libiio-*.exe | Rename-Item -NewName "libiio-py36-amd64.exe"
- ps: cp dist\*.exe .
- ps: rm dist\*.exe
- python.exe setup.py sdist
- ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-amd64.tar.gz"
- ps: cp dist\*.tar.gz .
- ps: rm dist\*.tar.gz
- cd c:\projects\libiio\build-win64

#Create the installer
Expand All @@ -138,8 +137,8 @@ build_script:
- copy build-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MS64
- copy build-win32\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS32
- copy build-win64\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS64
- copy build-win32\bindings\python\*.exe c:\%ARCHIVE_NAME%\MS32
- copy build-win64\bindings\python\*.exe c:\%ARCHIVE_NAME%\MS64
- copy build-win32\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS32
- copy build-win64\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS64
- copy build-mingw-win32\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW32
- copy build-mingw-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW64
- del c:\%ARCHIVE_NAME%\MinGW32\libiio.iss
Expand Down
82 changes: 74 additions & 8 deletions bindings/python/setup.py.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 0 additions & 9 deletions libiio.iss.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"

[Files]
Source: "C:\projects\libiio\build-win32\bindings\python\libiio-py37-win32.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
Source: "C:\projects\libiio\build-win64\bindings\python\libiio-py37-amd64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;

Source: "C:\projects\libiio\build-win32\Release\libiio.dll"; DestDir: "{sys}"; Flags: 32bit
Source: "C:\projects\libiio\build-win64\Release\libiio.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode

Expand All @@ -71,9 +68,3 @@ Source: "C:\projects\libiio\build-win32\bindings\csharp\libiio-sharp.dll"; DestD
Source: "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT\msvcr120.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit
Source: "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT\msvcr120.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist

[Tasks]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my only question here is: do we lose any test/build coverage by removing these?
and if yes, any way to compensate? we could also add a CI run somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could actually install the built wheel... This would require installing the dll (then removing it for each variant)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess it should work;
let's see later

Name: "install_python_bindings"; Description: "Install libiio Python 3.7 bindings"

[Run]
Filename: "{tmp}\libiio-py37-amd64.exe"; StatusMsg: "Installing Python bindings"; Check: Is64BitInstallMode; Tasks: install_python_bindings; Flags: skipifsilent
Filename: "{tmp}\libiio-py37-win32.exe"; StatusMsg: "Installing Python bindings"; Check: not Is64BitInstallMode; Tasks: install_python_bindings; Flags: skipifsilent