somexlab / fastddm

Python library for Differential Dynamic Microscopy analysis
https://fastddm.readthedocs.io/
GNU General Public License v3.0
3 stars 0 forks source link

Add conda env config file #196

Closed enrico-lattuada closed 7 months ago

enrico-lattuada commented 7 months ago

Description Provide configuration file for conda environment creation. Add user instructions in the documentation.

Proposed solution

Additional context This provides an additional way to create a safe environment.

enrico-lattuada commented 7 months ago

I found some possible solutions for the conda environment YAML config file. These solutions only work for the moment for the Python and C++ cores. Hopefully, in the future, I will be able to figure out how to implement the installation for the CUDA core.

I propose to add this to the documentation, possibly with group tabs for the different OSs, instead of directly creating YAML files. @krauthex What do you think?

Ubuntu

The fastddm-test.yml file is as follows:

name: fddm-test
channels:
  - defaults
dependencies:
  - gcc
  - g++
  - python>=3.8

Create the environment

conda env create -f fastddm-test.yml

Activate the environment

conda activate fddm-test

Set the appropriate environment variables

conda env config vars set CC=$CONDA_PREFIX/bin/gcc
conda env config vars set CXX=$CONDA_PREFIX/bin/g++

To compile the C++ core, set also the corresponding flag

conda env config vars set ENABLE_CPP=ON

Deactivate and reactivate the environment to make the changes effective

conda deactivate
conda activate fddm-test

From the fastddm project root directory, run

python3 -m pip install .[test]

This will also install the dependencies to run the tests.

Finally, run the tests, again from the project source directory

pytest -v

MacOS

The fastddm-test.yml file is as follows:

name: fddm-test
channels:
  - defaults
dependencies:
  - clang
  - clangxx
  - python>=3.8

Everything is the same as for the Ubuntu OS, except for the environment variables setup, which should be

conda env config vars set CC=$CONDA_PREFIX/bin/clang
conda env config vars set CXX=$CONDA_PREFIX/bin/clang++

Windows

For Windows, I could not find any C++ compiler distributed via conda channels. Therefore, it seems that one still has to download and install Visual Studio Community Edition, as indicated in the documentation. The config file is simply:

name: fddm-test
channels:
  - defaults
dependencies:
  - python>=3.8

Additionally, there is no need to set the environment variables for the compilers, since they are automatically set by Visual Studio.

CUDA

As a note for the future, the conda-forge channel has a cudatoolkit-dev package, which contains the CUDA Toolkit libraries and the nvcc compiler. I tried it on Windows, but CMake falls back to the system's CUDA Toolkit and nvcc compiler. It might be worth investigating the appropriate environment variables that must be set so that CMake detects the environment libraries and compiler.

krauthex commented 7 months ago

looks very good to me! What is your intended audience for this environment? Developers/Contributors? Or normal users? because if the latter is the case, I'd at least remove the -test in the environment name. :-)