Open acampbel opened 1 year ago
Hello @acampbel ! Thank you for your comments!
Currently, the PRIMA project implements several optimization solvers in modern Fortran, and provides a MATLAB interface to use the solvers under MATLAB. This interface calls the mexified version of the Fortran code. setup.m basically does the mexification and sets the paths.
I have two questions.
Is there a way to package my project so that users can use the mexified solvers out of the box after downloading the package, without any need to mexify the Fortran code locally? If yes, how? I would like the package to be usable under Linux, macOS, and Windows.
Does the build tool you mentioned help me to build the package towards the above-mentioned objective? If yes, how?
As an example, we may consider the distribution of Python packages that wrap Fortran/C code: we build (compile) the wheels, and make the package available on pypi
; then users can get the package by a simple pip install
, which will obtain the compiled and ready-to-use version of the package without any need for local compilation. Is there a way to distribute MATLAB packages in a similar way?
Thank you very much!
Best regards, Zaikun
Yes, this will likely take some work to get going on your project, but you can create a toolbox package from the code that includes all the Mex files you have created on the 3 platforms you listed. The build tool can help you organize your build pipeline and create those toolbox packages both within your local matlab and the ci build. You will likely need at least 4 jobs to run, one for each platform and one to gather all of the derived artifacts (the Mex files, etc) and package them into a toolbox package (*mltbx) Once you do that you can upload these packages to some location like GitHub releases or to the file exchange. If they are on the file exchange users can install them using add-ons apis.
Does that help?
Thank you @acampbel for the information.
Is it ensured that the MEX files compiled on one Linux machine can run on another one with the same system, but the versions of the system and MATLAB might be different? For example, the MEX files are compiled on Ubuntu 22.04 with MATLAB R2022a, the compiler being gfortran 12. Will the MEX files work on Ubuntu 20.04 with MATLAB R2023a without gfortran installed? I have the same question for macOS and Windows, respectively.
Is it legal to distribute the compiled MEX files? Does it violate the copyright / EULA of MATLAB? (On Windows, I the compiler will be Intel oneAPI, and I am not sure whether Intel has some restriction on the compiled binaries produced by its compilers).
Many thanks and best regards, Zaikun
Hi @zaikunzhang,
Thanks! Andy
Hello @acampbel ! Thank you for your comments!
Currently, the PRIMA project implements several optimization solvers in modern Fortran, and provides a MATLAB interface to use the solvers under MATLAB. This interface calls the mexified version of the Fortran code. setup.m basically does the mexification and sets the paths.
I have two questions.
- Is there a way to package my project so that users can use the mexified solvers out of the box after downloading the package, without any need to mexify the Fortran code locally? If yes, how? I would like the package to be usable under Linux, macOS, and Windows.
- Does the build tool you mentioned help me to build the package towards the above-mentioned objective? If yes, how?
As an example, we may consider the distribution of Python packages that wrap Fortran/C code: we build (compile) the wheels, and make the package available on
pypi
; then users can get the package by a simplepip install
, which will obtain the compiled and ready-to-use version of the package without any need for local compilation. Is there a way to distribute MATLAB packages in a similar way?Thank you very much!
Best regards, Zaikun
Here is an example of a repo that is doing something similar to what you describe:
R2022b shipped a new MATLAB build tool. R2023a added incremental build features. Much more development is ongoing.
The setup.m file in this repository looks like it is doing activities a build tool might be leveraged for. Would definitely be interested in feedback you may have on the new build tool and where it can use improvement for your workflow:
More info: https://www.mathworks.com/help/matlab/build-automation.html