Skip to content

Commit

Permalink
use old get python lib for v2 (#437)
Browse files Browse the repository at this point in the history
* cmake: use original get python lib for v2
* ci: no python2 in the windows matrix
* ci: remove python2 from osx
* ci: remove freebsd (would not build)
  • Loading branch information
guruofquality authored Apr 24, 2024
1 parent b5227a9 commit 8c6cb7c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 132 deletions.
131 changes: 0 additions & 131 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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
7 changes: 6 additions & 1 deletion swig/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions swig/python/get_python2_lib.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 8c6cb7c

Please sign in to comment.