diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ef1db38..3e96655c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,31 +135,21 @@ jobs: matrix: build_type: [Release, Debug] config: - - cc: gcc-10 - cxx: g++-10 - test_luajit: false - os: macos-11 - python2_ver: '2.7' - python3_ver: '3.8' - - cc: gcc-11 cxx: g++-11 test_luajit: false os: macos-11 - python2_ver: '2.7' python3_ver: '3.8' - cc: clang cxx: clang++ test_luajit: true os: macos-11 - python2_ver: '2.7' python3_ver: '3.8' - cc: clang cxx: clang++ os: macos-12 - python2_ver: '2.7' python3_ver: '3.9' runs-on: ${{matrix.config.os}} env: @@ -199,19 +189,6 @@ jobs: SoapySDRUtil --info SoapySDRUtil --check=null SoapySDRUtil --make="driver=null" - - name: Set up Python2 - uses: actions/setup-python@v4 - with: - python-version: ${{matrix.config.python2_ver}} - - name: Test Python2 bindings - run: | - export DYLD_LIBRARY_PATH=/usr/local/lib - export PYTHONPATH=${INSTALL_PREFIX}/$(python${{matrix.config.python2_ver}} ${{github.workspace}}/swig/python/get_python_lib.py ${INSTALL_PREFIX}) - python${{matrix.config.python2_ver}} -c "import SoapySDR; print(SoapySDR.getAPIVersion())" - python${{matrix.config.python2_ver}} -c "from SoapySDR import *; print(SOAPY_SDR_ABI_VERSION)" - python${{matrix.config.python2_ver}} -c "from SoapySDR import *; print(SOAPY_SDR_TIMEOUT)" - python${{matrix.config.python2_ver}} -c "import SoapySDR; print(SoapySDR.errToStr(SoapySDR.SOAPY_SDR_TIMEOUT))" - python${{matrix.config.python2_ver}} -c "import SoapySDR; print(SoapySDR.Device.make('driver=null'))" - name: Set up Python3 uses: actions/setup-python@v4 with: @@ -246,17 +223,6 @@ jobs: fail-fast: false matrix: platform: - - cmake_gen: '"Visual Studio 14 2015" -A "Win32"' - msvc: true - arch: win32 - python_arch: x86 - os: windows-2019 - - - cmake_gen: '"Visual Studio 14 2015" -A "x64"' - msvc: true - arch: x64 - python_arch: x64 - os: windows-2019 - cmake_gen: '"Visual Studio 16 2019" -A "Win32"' msvc: true @@ -282,22 +248,7 @@ jobs: python_arch: x64 os: windows-2022 -# - cmake_gen: '"MinGW Makefiles"' -# msvc: false -# python_arch: x64 -# os: windows-2019 - -# TODO: restore if Github upgrades past buggy 11.2 -# - cmake_gen: 'MinGW Makefiles' -# msvc: false -# python_arch: x64 -# os: windows-2022 - build: - - type: Release - python_version: '2.7.18' - python_name: 'python' - cmake_flags: '-DENABLE_PYTHON2=ON -DENABLE_PYTHON3=OFF' - type: Release python_version: '3.9.13' @@ -404,85 +355,3 @@ jobs: cmake --build . --config ${{matrix.build.type}} cmake --install . --config ${{matrix.build.type}} SoapySDRUtil --check=my_device - freebsd-ci: - name: FreeBSD - runs-on: macos-12 - strategy: - fail-fast: false - matrix: - build_type: [Release, Debug] - release: ['12.3', '13.1'] # Skip 13.0, EOL and has broken Python package - env: - INSTALL_PREFIX: /usr/local - PYTHON3_VER: '3.9' - steps: - - uses: actions/checkout@v2 - - uses: vmactions/freebsd-vm@v0 - name: Test in FreeBSD - with: - envs: 'INSTALL_PREFIX PYTHON3_VER' - release: ${{matrix.release}} - copyback: false - prepare: | - pkg install -y cmake devel/swig lang/python3 lang/luajit - run: | - # We can't separate these steps, so add prints for clarity. - - echo - echo "----------------------------------" - echo "Building..." - echo "----------------------------------" - mkdir build - cd build - cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{github.workspace}} - make - - echo - echo "----------------------------------" - echo "Installing..." - echo "----------------------------------" - make install - - echo - echo "----------------------------------" - echo "Running unit tests..." - echo "----------------------------------" - ctest --output-on-failure - - echo - echo "----------------------------------" - echo "Testing SoapySDRUtil..." - echo "----------------------------------" - SoapySDRUtil --info - SoapySDRUtil --check=null - SoapySDRUtil --make="driver=null" - - echo - echo "----------------------------------" - echo "Testing Python 3 bindings..." - echo "----------------------------------" - python${PYTHON3_VER} -c "import SoapySDR; print(SoapySDR.getAPIVersion())" || exit 1 - python${PYTHON3_VER} -c "from SoapySDR import *; print(SOAPY_SDR_ABI_VERSION)" || exit 1 - python${PYTHON3_VER} -c "from SoapySDR import *; print(SOAPY_SDR_TIMEOUT)" || exit 1 - python${PYTHON3_VER} -c "import SoapySDR; print(SoapySDR.errToStr(SoapySDR.SOAPY_SDR_TIMEOUT))" || exit 1 - python${PYTHON3_VER} -c "import SoapySDR; print(SoapySDR.Device.make('driver=null'))" || exit 1 - - echo - echo "----------------------------------" - echo "Testing LuaJIT bindings..." - echo "----------------------------------" - luajit -e 'SoapySDR = require("SoapySDR"); print(SoapySDR.API_VERSION)' || exit 1 - luajit -e 'SoapySDR = require("SoapySDR"); print(SoapySDR.ABI_VERSION)' || exit 1 - luajit -e 'SoapySDR = require("SoapySDR"); print(SoapySDR.Error.TIMEOUT)' || exit 1 - luajit -e 'SoapySDR = require("SoapySDR"); print(SoapySDR.Error.ToString(SoapySDR.Error.TIMEOUT))' || exit 1 - luajit -e 'SoapySDR = require("SoapySDR"); print(SoapySDR.Device.new("driver=null"))' || exit 1 - - echo - echo "----------------------------------" - echo "Testing module registration..." - echo "----------------------------------" - mkdir -p ${{github.workspace}}/build-example - cd ${{github.workspace}}/build-example - cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{github.workspace}}/ExampleDriver - make install - SoapySDRUtil --check=my_device diff --git a/swig/python/CMakeLists.txt b/swig/python/CMakeLists.txt index c453a9e5..ee9b0b22 100644 --- a/swig/python/CMakeLists.txt +++ b/swig/python/CMakeLists.txt @@ -124,8 +124,13 @@ function(BUILD_PYTHON_MODULE PYTHON_VERSION) target_include_directories(${SWIG_MODULE_SoapySDR${PYTHON_VERSION}_REAL_NAME} PRIVATE ${python_includes}) SWIG_LINK_LIBRARIES(SoapySDR${PYTHON_VERSION} ${python_libraries}) + set(get_python_lib ${SOAPYSDR_PYTHON_DIR}/get_python_lib.py) + if (${PYTHON_VERSION} EQUAL 2) + set(get_python_lib ${SOAPYSDR_PYTHON_DIR}/get_python2_lib.py) + endif() + execute_process( - COMMAND ${Python${PYTHON_VERSION}_EXECUTABLE} ${SOAPYSDR_PYTHON_DIR}/get_python_lib.py ${CMAKE_INSTALL_PREFIX} + COMMAND ${Python${PYTHON_VERSION}_EXECUTABLE} ${get_python_lib} ${CMAKE_INSTALL_PREFIX} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PYTHON_INSTALL_DIR) diff --git a/swig/python/get_python2_lib.py b/swig/python/get_python2_lib.py new file mode 100644 index 00000000..0c716529 --- /dev/null +++ b/swig/python/get_python2_lib.py @@ -0,0 +1,19 @@ +import os +import sys +import site +from distutils.sysconfig import get_python_lib + +if __name__ == '__main__': + prefix = sys.argv[1] + + #ask distutils where to install the python module + install_dir = get_python_lib(plat_specific=True, prefix=prefix) + + #use sites when the prefix is already recognized + try: + paths = [p for p in site.getsitepackages() if p.startswith(prefix)] + if len(paths) == 1: install_dir = paths[0] + except AttributeError: pass + + #strip the prefix to return a relative path + print(os.path.relpath(install_dir, prefix))