Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a84a680b authored by hhakim's avatar hhakim
Browse files

Add package postinstall script to automatize py wrapper setup.

No need anymore to set PYTHONPATH or the cwd to py wrapper directory.
The user can normally from anywhere import faust py directly after bin package installation.
parent 67c8808a
Branches
Tags
No related merge requests found
......@@ -844,19 +844,37 @@ ELSE(WIN32 AND NOT UNIX)
SET(CPACK_PACKAGE_FILE_NAME "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Mac")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Mac")
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "4")
file(REMOVE ${PROJECT_BINARY_DIR}/postinstall) # needed to remove possible postinstall script left here
# really needed only when BUILD_WRAPPER_MATLAB==OFF and BUILD_WRAPPER_PYTHON==ON
if(BUILD_WRAPPER_MATLAB)
# prepare script to set matlab path for faust automatically after package installation
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/macosx/postinst_matlab.sh.in ${PROJECT_BINARY_DIR}/postinstall @ONLY)
endif()
if(BUILD_WRAPPER_PYTHON)
# prepare the script allowing the user to avoid PYTHONPATH setting
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/postinst_py.sh ${PROJECT_BINARY_DIR}/postinstall2 @ONLY)
file(READ ${PROJECT_BINARY_DIR}/postinstall2 POSTINST2_LINES)
file(APPEND ${PROJECT_BINARY_DIR}/postinstall "${POSTINST2_LINES}")
file(REMOVE ${PROJECT_BINARY_DIR}/postinstall2)
endif()
ELSE(APPLE)
SET(CPACK_GENERATOR "DEB;RPM")
#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "python, python-numpy, libfftw3-3, libsndfile1")
#SET(CPACK_DEBIAN_PACKAGE_SECTION "math")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "FAuST is a C++ toolbox, useful to decompose a given dense matrix into a product of sparse matrices in order to reduce its computational complexity (both for storage and manipulation). ")
if(BUILD_WRAPPER_MATLAB)
file(REMOVE ${PROJECT_BINARY_DIR}/postinst) # needed to remove possible postinstall script left here
# really needed only when BUILD_WRAPPER_MATLAB==OFF and BUILD_WRAPPER_PYTHON==ON
if(BUILD_WRAPPER_MATLAB)
# prepare script to set matlab path for faust automatically after package installation
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/debrpm/postinst_matlab.sh.in ${PROJECT_BINARY_DIR}/postinst @ONLY)
endif()
if(BUILD_WRAPPER_PYTHON)
# prepare the script allowing the user to avoid PYTHONPATH setting
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/postinst_py.sh ${PROJECT_BINARY_DIR}/postinst2 @ONLY)
file(READ ${PROJECT_BINARY_DIR}/postinst2 POSTINST2_LINES)
file(APPEND ${PROJECT_BINARY_DIR}/postinst "${POSTINST2_LINES}")
file(REMOVE ${PROJECT_BINARY_DIR}/postinst2)
endif()
#SET(CPACK_RPM_PACKAGE_DEPENDS "libmat, libmex, libmx ")
#CPACK_RPM_PACKAGE_GROUP
#SET (CPACK_RPM_PACKAGE_REQUIRES )
......
#!/bin/bash
uid=$(id -u)
[[ ! "$uid" = 0 ]] && echo "Error: need to be root." >&2 && exit 1 # not needed, we're supposed to be root at installation time
[[ -n "$1" && -d "$1" ]] && FAUST_PY_WRAPPER_PATH="$1" || FAUST_PY_WRAPPER_PATH="@CMAKE_INSTALL_PYTHON_PREFIX@"
[[ -z "$FAUST_PY_WRAPPER_PATH" ]] && echo "USAGE: $0 <path>" && exit 2
[[ ! -d "$FAUST_PY_WRAPPER_PATH" ]] && echo "ERROR: directory $FAUST_PY_WRAPPER_PATH doesn't exist" && exit 3
function link_py_files(){
PY_MAJOR_VER=$1
PY_MAJOR_MINOR_VER=$(python$PY_MAJOR_VER --version 2>&1 | sed -e 's/.*[[:blank:]]\{1,\}\([[:digit:]]\.[[:digit:]]\)\.[[:digit:]]\{1,\}/\1/')
PY_SITE_PACKAGES_PATH=$(python$PY_MAJOR_VER -c 'import os,site,re;print([path for path in site.getsitepackages() if re.match(".*"+os.path.sep+"site-packages$", path) and os.path.exists(path) ][0])')
PYFILES=${FAUST_PY_WRAPPER_PATH}/FaustPy.py
[[ "$PY_MAJOR_MINOR_VER" = 3* ]] && PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.cpython-3*so" || \
PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.so"
for PYFILE in $PYFILES
do
[[ -n "$DEBUG" ]] && echo ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
[[ -r "$PYFILE" ]] && ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
done && echo "Linked py wrapper version $PY_MAJOR_VER into ${PY_SITE_PACKAGES_PATH}."
}
for V in 2 3
do
which python$V 2>&1 > /dev/null && link_py_files $V
done
exit 0 # to avoid exit failure result when only one version of py is found (or it'll make the macOS installer fail)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment