Mentions légales du service

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

Specify automatically the exact python 3 major-minor version used in README doxygen/html doc.

The info. is important for the user to know with what version of python3 he must use the wrapper.
For python 2.7 it's not important because we are stuck to this version of python (except that the micro/patch version could change).
parent 3164e6a9
Branches
Tags
No related merge requests found
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
<h3>1.1 For Python</h3> <h3>1.1 For Python</h3>
<p>FAµST supports at least Python 2.7 and is also compiled for Python 3.6.</p> <p>FAµST supports at least Python 2.7 and is also compiled for Python @PY3_VER@.</p>
<p>If you want to use FAµST with Python 3 you must use this exact version because the FAµST Python wrapper delivered within the binary package is compiled for that version only.</p> <p>If you want to use FAµST with Python 3 you must use this exact version @PY3_VER@ because the FAµST Python wrapper delivered within the binary package is compiled for that version only.</p>
<p>FAµST is designed for the Python ecosystem which as usual relies on numpy and scipy packages. So you have to ensure these packages are installed on your system.</p> <p>FAµST is designed for the Python ecosystem which as usual relies on numpy and scipy packages. So you have to ensure these packages are installed on your system.</p>
......
# Quick Guide to Install and Use FAµST Wrappers
[1. Prerequisites](#prerequisites)
[2. Installation](#installation)
[3. Installation Testing](#installation_testing)
[4. Usage](#usage)
## <a name="prerequisites">1. Prerequisites<a/>
### 1.1 For Python
FAµST supports at least Python 2.7 and is also compiled for Python @PY3_VER@.
If you want to use FAµST with Python 3 you must use this exact version @PY3_VER@ because the FAµST Python wrapper delivered within the binary package is compiled for that version only.
FAµST is designed for the Python ecosystem which as usual relies on numpy and scipy packages. So you have to ensure these packages are installed on your system.
### 1.2 For Matlab
The FAµST wrapper for Matlab has been tested on several Matlab versions starting from version 2016 up to version 2018. However it's not totally excluded that FAµST works with older versions.
## <a name="installation"> 2. Installation</a>
@OS_SPECIFIC_INSTALL_GUIDE_INSTRUCS@
## <a name="installation_testing">3. Installation Testing<a/>
Normally, after installing, nothing is left to do. The installation process should have seamlessly set up the Faust wrappers for Python and Matlab into your environment.
Neverthless, it could be useful to check that it really worked and set the environment manually if needed like explained below.
### 3.1 Testing Python Wrapper Auto-Setup
Here is how to test the FaµST Python wrapper has been setup properly from a Bash terminal:
$ python2 -c "import pyfaust" && echo "It works"
Obviously, if the wrapper is set up properly you'll see the message "It works" as a result from the command above.
If you see the following error message, then it didn't work:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pyfaust'
Likewise, for python3 you can use the previous command for setup checking (currently on macOS only FAµST for Python 2 is supported).
If the auto-setup has failed you need to add the Python wrapper manually in your Python path, here is how to proceed:
$ export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/python
# and test again
$ python2 -c "import pyfaust" && echo "It works"
If it fails again you are likely on a different version of Python. Returns to the Prerequisites section and check your Python versions match FAµST requirements.
### 3.2 Testing Matlab Wrapper Auto-Setup
$ matlab -nodisplay -nojvm -r "import matfaust.Faust;F = Faust.rand(1, 10, .5, 'dense', false);exit"
It works only if you see an output similar to:
F =
Faust size 10x10, density 0.56999, nnz_sum 57, 1 factor(s):
- FACTOR 0 (complex) DENSE, size 10x10, density 0.57, nnz 57
In other case it didn't work. So here is how to setup the wrapper manually :
First, you launch Matlab terminal, then you go in the FAµST directory :
>> cd @CMAKE_INSTALL_PREFIX@/matlab
And finally you launch the script that is responsible to add FAµST path in your Matlab path.
>> setup_FAUST
OK! You can follow the quick start usage now.
## <a name="usage">4. Usage<a/>
### 4.1 Matlab Wrapper
Let's test FAµST with the quickstart script:
>> quick_start
And then type further instructions to test a bit of FAµST API:
Let's see what variables quickstart script has added.
>> whos
Now call some functions on FAµST object A:
>> rcg(A)
>> density(A)
>> get_num_factors(A)
Retrieve the product factors (as full matrices):
>> F1 = get_fact(A,1);
>> F2 = get_fact(A,2);
Check the sizes:
>> size(F1)
>> size(F2)
>> size(A)
For more information on FAµST API, and whole function listing, consult the doc:
>> doc('Faust')
N.B.: to access the documentation, you need to be in the graphical interface of matlab.
You should rather consult the doxygen doc for the API in [@CMAKE_INSTALL_PREFIX@/doc/html/index.html](file://@CMAKE_INSTALL_PREFIX@/doc/html/index.html) from your web browser.
### 4.2 Python Wrapper
In the same idea, you can execute the quick start script for Python.
$ python2.7 @CMAKE_INSTALL_PREFIX@/python/quickstart.py
You can also go through the python terminal to build a FAµST product and call its object methods.
$ python2.7
>>> import pyfaust
>>> import pyfaust
>>> A = pyfaust.Faust('@CMAKE_INSTALL_PREFIX@/python/A.mat') # A is the FAµST created through quickstart script
>>> A.rcg()
6.666666666666667
>>> A.density()
0.15
>>> A.get_num_factors()
2
>>> F1 = A.get_factor(0)
>>> F2 = A.get_factor(1)
>>> A.shape
(1000, 2000)
...@@ -53,7 +53,7 @@ add_custom_target(${FAUST_PYTHON_TARGET} ALL DEPENDS ${FAUST_TARGET}) ...@@ -53,7 +53,7 @@ add_custom_target(${FAUST_PYTHON_TARGET} ALL DEPENDS ${FAUST_TARGET})
list(LENGTH PYTHON_EXES PYTHON_EXES_LEN) list(LENGTH PYTHON_EXES PYTHON_EXES_LEN)
list(LENGTH CYTHON_EXES CYTHON_EXES_LEN) list(LENGTH CYTHON_EXES CYTHON_EXES_LEN)
#TODO: check that the two LEN are equal #TODO: check that the two LENGHTS are equal
#message(STATUS "PYTHON_EXES_LEN=${PYTHON_EXES_LEN}, PYTHON_EXES=${PYTHON_EXES}") #message(STATUS "PYTHON_EXES_LEN=${PYTHON_EXES_LEN}, PYTHON_EXES=${PYTHON_EXES}")
#message(STATUS "CYTHON_EXES_LEN=${CYTHON_EXES_LEN}, CYTHON_EXES=${CYTHON_EXES}") #message(STATUS "CYTHON_EXES_LEN=${CYTHON_EXES_LEN}, CYTHON_EXES=${CYTHON_EXES}")
...@@ -61,7 +61,12 @@ if(UNIX) ...@@ -61,7 +61,12 @@ if(UNIX)
foreach(PYTHON_EXE IN LISTS PYTHON_EXES) foreach(PYTHON_EXE IN LISTS PYTHON_EXES)
exec_program("${PYTHON_EXE}" ARGS "--version" OUTPUT_VARIABLE PY_VER RETURN_VALUE PY_RES) exec_program("${PYTHON_EXE}" ARGS "--version" OUTPUT_VARIABLE PY_VER RETURN_VALUE PY_RES)
#message(STATUS "PY_VER=${PY_VER}") #message(STATUS "PY_VER=${PY_VER}")
string(REGEX REPLACE "Python ([0-9]\\.[0-9]).*$" "\\1" PY_VER_WITH_POINTS ${PY_VER})
string(REGEX REPLACE "Python ([0-9])\\.([0-9]).*$" "\\1\\2" PY_VER ${PY_VER}) string(REGEX REPLACE "Python ([0-9])\\.([0-9]).*$" "\\1\\2" PY_VER ${PY_VER})
if(PY_VER MATCHES 3)
set(PY_DYNLIB "FaustCorePy.cp${PY_VER}-win_amd64.pyd")
set(PY3_VER ${PY_VER_WITH_POINTS} PARENT_SCOPE)
endif()
add_custom_command(TARGET ${FAUST_PYTHON_TARGET} add_custom_command(TARGET ${FAUST_PYTHON_TARGET}
COMMAND ${PYTHON_EXE} COMMAND ${PYTHON_EXE}
ARGS "${FAUST_PYTHON_BIN_DIR}/setup.py" "build_ext" "--inplace" ARGS "${FAUST_PYTHON_BIN_DIR}/setup.py" "build_ext" "--inplace"
...@@ -87,6 +92,7 @@ elseif(WIN32 AND ${CMAKE_GENERATOR} MATCHES "MinGW Makefiles") ...@@ -87,6 +92,7 @@ elseif(WIN32 AND ${CMAKE_GENERATOR} MATCHES "MinGW Makefiles")
# get abbreviated python version # get abbreviated python version
exec_program("${PYTHON_EXE}" ARGS "--version" OUTPUT_VARIABLE PY_VER RETURN_VALUE PY_RES) exec_program("${PYTHON_EXE}" ARGS "--version" OUTPUT_VARIABLE PY_VER RETURN_VALUE PY_RES)
#message(STATUS "PY_VER=${PY_VER}") #message(STATUS "PY_VER=${PY_VER}")
string(REGEX REPLACE "Python ([0-9]\\.[0-9]).*$" "\\1." PY_VER_WITH_POINTS ${PY_VER})
string(REGEX REPLACE "Python ([0-9])\\.([0-9]).*$" "\\1\\2" PY_VER ${PY_VER}) string(REGEX REPLACE "Python ([0-9])\\.([0-9]).*$" "\\1\\2" PY_VER ${PY_VER})
#message(STATUS "PY_VER=${PY_VER}") #message(STATUS "PY_VER=${PY_VER}")
# set header inclusion flags # set header inclusion flags
...@@ -109,6 +115,7 @@ elseif(WIN32 AND ${CMAKE_GENERATOR} MATCHES "MinGW Makefiles") ...@@ -109,6 +115,7 @@ elseif(WIN32 AND ${CMAKE_GENERATOR} MATCHES "MinGW Makefiles")
#message(STATUS "PYTHON_STATIC_LIB_PATH=${PYTHON_STATIC_LIB_PATH}") #message(STATUS "PYTHON_STATIC_LIB_PATH=${PYTHON_STATIC_LIB_PATH}")
if(PY_VER MATCHES 3) if(PY_VER MATCHES 3)
set(PY_DYNLIB "FaustCorePy.cp${PY_VER}-win_amd64.pyd") set(PY_DYNLIB "FaustCorePy.cp${PY_VER}-win_amd64.pyd")
set(PY3_VER ${PY_VER_WITH_POINTS})
else() #py 2.7.x else() #py 2.7.x
set(PY_DYNLIB "FaustCorePy.pyd") set(PY_DYNLIB "FaustCorePy.pyd")
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment