Automatic installation of Python dependencies with CMake
I had a quick glance, but due to the terminology, like dependencies and packages being used in different ways, it is rather difficult to find an answer.
I am creating a mixed language source (Fortran, some C and Python) and Fortran calls a Python script that depends on the networkx
Python package in PyPI. Usually, I just installed networkx
, so this is not a problem for me when restoring.
However, for distribution, I want the best possible way:
- Install
pip
or its equivalent if not installed. - Maybe install
virtualenv
and create a virtual environment if needed. - Download and install
networkx
using the--user
c optionpip
.
Is there a standard way? Or should I just use CMake dependencies with custom commands that install pip
, etc.?
source to share
it depends. for a "manual" installation, you should definitely determine if all the necessary (for building) tools are installed and throw an error if they do not. then use execute_process()
to launch pip
and whatever you want. on the other hand, if you are going to build a real package for a specific Linux, you just package your binaries and require (with the appropriate syntax of a specific package format such as *.rpm
or *.deb
that your package depends on some other packages. so you can be sure that they will be installed via w / (or even before) your package.
source to share